Commit 28ba985e authored by Robert Schilling's avatar Robert Schilling

Save last scrollposition and scroll back when leaving ZEN mode

parent 90741c88
...@@ -4,10 +4,16 @@ class @ZenMode ...@@ -4,10 +4,16 @@ class @ZenMode
constructor: -> constructor: ->
@active_zen_area = null @active_zen_area = null
@active_checkbox = null @active_checkbox = null
@scroll_position = 0
$(window).scroll =>
if not @active_checkbox
@scroll_position = window.pageYOffset
$('body').on 'change', '.zennable input[type=checkbox]', (e) => $('body').on 'change', '.zennable input[type=checkbox]', (e) =>
checkbox = e.currentTarget checkbox = e.currentTarget
if checkbox.checked if checkbox.checked
# Disable other keyboard shortcuts in ZEN mode
Mousetrap.pause() Mousetrap.pause()
@udpateActiveZenArea(checkbox) @udpateActiveZenArea(checkbox)
else else
...@@ -34,6 +40,7 @@ class @ZenMode ...@@ -34,6 +40,7 @@ class @ZenMode
@active_zen_area = null @active_zen_area = null
@active_checkbox = null @active_checkbox = null
window.location.hash = '' window.location.hash = ''
window.scrollTo(window.pageXOffset, @scroll_position)
checkboxFromLocationHash: (e) -> checkboxFromLocationHash: (e) ->
id = $.trim(window.location.hash.replace('#' + ZenMode.fullscreen_prefix, '')) id = $.trim(window.location.hash.replace('#' + ZenMode.fullscreen_prefix, ''))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment