Fix 4chan X scrolling to wrong position when back button is used.
This commit is contained in:
parent
8aa46de5eb
commit
51d8851f8d
@ -81,7 +81,7 @@ Header =
|
|||||||
el: editCustomNav
|
el: editCustomNav
|
||||||
]
|
]
|
||||||
|
|
||||||
$.on window, 'load hashchange', Header.hashScroll
|
$.on window, 'load popstate', Header.hashScroll
|
||||||
$.on d, 'CreateNotification', @createNotification
|
$.on d, 'CreateNotification', @createNotification
|
||||||
|
|
||||||
$.asap (-> d.body), =>
|
$.asap (-> d.body), =>
|
||||||
@ -422,11 +422,15 @@ Header =
|
|||||||
settings = $.id 'fourchanx-settings'
|
settings = $.id 'fourchanx-settings'
|
||||||
$('[name=boardnav]', settings).focus()
|
$('[name=boardnav]', settings).focus()
|
||||||
|
|
||||||
hashScroll: ->
|
hashScroll: (e) ->
|
||||||
|
# Don't scroll when navigating to an already visited state.
|
||||||
|
return if e.state
|
||||||
|
history.replaceState {}, '' unless history.state
|
||||||
|
|
||||||
hash = @location.hash[1..]
|
hash = @location.hash[1..]
|
||||||
return unless /^p\d+$/.test(hash) and post = $.id hash
|
return unless /^p\d+$/.test(hash) and post = $.id hash
|
||||||
return if (Get.postFromRoot post).isHidden
|
return if (Get.postFromRoot post).isHidden
|
||||||
Header.scrollTo post
|
$.queueTask -> Header.scrollTo post
|
||||||
|
|
||||||
scrollTo: (root, down, needed) ->
|
scrollTo: (root, down, needed) ->
|
||||||
if down
|
if down
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user