]> git.ipfire.org Git - thirdparty/foundation/foundation-sites.git/commitdiff
fix: show/hide Reveal scrollbar on window resizing
authorNicolas Coden <nicolas@ncoden.fr>
Mon, 18 Jun 2018 21:08:12 +0000 (23:08 +0200)
committerNicolas Coden <nicolas@ncoden.fr>
Mon, 18 Jun 2018 21:08:12 +0000 (23:08 +0200)
js/foundation.reveal.js

index 3b5943183250aa6ec5a72b05b12aa5df28cb386f..caf222c71c4c94d41c50530c2de7d4f39aa487bf 100644 (file)
@@ -325,13 +325,17 @@ class Reveal extends Plugin {
   }
 
   _addRevealOpenClasses() {
-    if ($(document).height() > $(window).height()) {
-      $('html').addClass('zf-has-scroll');
-    }
+    const updateScrollbarClass = () => {
+      $('html').toggleClass('zf-has-scroll', !!($(document).height() > $(window).height()));
+    };
+
+    this.$element.on('resizeme.zf.trigger.revealScrollbarListener', () => updateScrollbarClass());
+    updateScrollbarClass();
     $('html').addClass('is-reveal-open');
   }
 
   _removeRevealOpenClasses() {
+    this.$element.off('resizeme.zf.trigger.revealScrollbarListener');
     $('html').removeClass('is-reveal-open');
     $('html').removeClass('zf-has-scroll');
   }