Skip to content
Snippets Groups Projects
Commit 28ba985e authored by Robert Schilling's avatar Robert Schilling
Browse files

Save last scrollposition and scroll back when leaving ZEN mode

parent 90741c88
No related branches found
No related tags found
No related merge requests found
Loading
@@ -4,10 +4,16 @@ class @ZenMode
Loading
@@ -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
Loading
@@ -34,6 +40,7 @@ class @ZenMode
Loading
@@ -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, ''))
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment