diff options
author | Robert Schilling <rschilling@student.tugraz.at> | 2014-09-21 23:06:38 +0400 |
---|---|---|
committer | Robert Schilling <rschilling@student.tugraz.at> | 2014-09-21 23:06:38 +0400 |
commit | 28ba985ef936bfffcb83025b2a093e048c761938 (patch) | |
tree | 3db5d447c8727f6dc6707f9ec660bd0a52438616 | |
parent | 90741c8892f5f8fd5d5154c8cd9d3fda9397df56 (diff) |
Save last scrollposition and scroll back when leaving ZEN mode
-rw-r--r-- | app/assets/javascripts/zen_mode.js.coffee | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/app/assets/javascripts/zen_mode.js.coffee b/app/assets/javascripts/zen_mode.js.coffee index d28b635355e..21ac212df0e 100644 --- a/app/assets/javascripts/zen_mode.js.coffee +++ b/app/assets/javascripts/zen_mode.js.coffee @@ -4,10 +4,16 @@ class @ZenMode constructor: -> @active_zen_area = 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) => checkbox = e.currentTarget if checkbox.checked + # Disable other keyboard shortcuts in ZEN mode Mousetrap.pause() @udpateActiveZenArea(checkbox) else @@ -34,6 +40,7 @@ class @ZenMode @active_zen_area = null @active_checkbox = null window.location.hash = '' + window.scrollTo(window.pageXOffset, @scroll_position) checkboxFromLocationHash: (e) -> id = $.trim(window.location.hash.replace('#' + ZenMode.fullscreen_prefix, '')) |