]> git.ipfire.org Git - thirdparty/foundation/foundation-sites.git/commitdiff
merged .disable-scroll into .is-reveal-open and removed obsolete code 10583/head
authorIgal Sapir <dev@21solutions.net>
Wed, 30 Aug 2017 06:49:43 +0000 (23:49 -0700)
committerIgal Sapir <dev@21solutions.net>
Wed, 30 Aug 2017 06:49:43 +0000 (23:49 -0700)
js/foundation.reveal.js
scss/components/_reveal.scss

index adfa2700ce3f911a238c61932a3d9584df3497f3..0ba3e4e7718b1bb5db00e5991e8171079e26e22c 100644 (file)
@@ -47,7 +47,6 @@ class Reveal extends Plugin {
     this.id = this.$element.attr('id');
     this.isActive = false;
     this.cached = {mq: MediaQuery.current};
-    this.isMobile = mobileSniff();
 
     this.$anchor = $(`[data-open="${this.id}"]`).length ? $(`[data-open="${this.id}"]`) : $(`[data-toggle="${this.id}"]`);
     this.$anchor.attr({
@@ -186,7 +185,6 @@ class Reveal extends Plugin {
     if ($(document).height() > $(window).height()) {
       var scrollTop = $(window).scrollTop();
       $("html")
-        .addClass("disable-scroll")
         .css("top", -scrollTop);
     }
   }
@@ -195,11 +193,12 @@ class Reveal extends Plugin {
   * Reenables the scroll when Reveal closes
   */
   _enableScroll(){
-    var scrollTop = parseInt($("html").css("top"));
-    $("html")
-      .removeClass("disable-scroll")
-      .css("top", "");
-    $(window).scrollTop(-scrollTop);
+    if ($(document).height() > $(window).height()) {
+      var scrollTop = parseInt($("html").css("top"));
+      $("html")
+        .css("top", "");
+      $(window).scrollTop(-scrollTop);
+    }
   }
 
 
@@ -267,7 +266,7 @@ class Reveal extends Plugin {
 
     function addRevealOpenClasses() {
 
-      $('body').addClass('is-reveal-open');
+      $('html').addClass('is-reveal-open');
     }
 
     // Motion UI method of reveal
@@ -396,7 +395,7 @@ class Reveal extends Plugin {
     function finishUp() {
 
       if ($('.reveal:visible').length  === 0) {
-        $('body').removeClass('is-reveal-open');
+        $('html').removeClass('is-reveal-open');
       }
 
       Keyboard.releaseFocus(_this.$element);
@@ -580,16 +579,4 @@ Reveal.defaults = {
   additionalOverlayClasses: ''
 };
 
-function iPhoneSniff() {
-  return /iP(ad|hone|od).*OS/.test(window.navigator.userAgent);
-}
-
-function androidSniff() {
-  return /Android/.test(window.navigator.userAgent);
-}
-
-function mobileSniff() {
-  return iPhoneSniff() || androidSniff();
-}
-
 export {Reveal};
index a74c545f3af12d98b74f86346b2309203b01db6b..897e7d5428fbf30fa69faf5729e680adf1e8646b 100644 (file)
@@ -125,18 +125,16 @@ $reveal-overlay-background: rgba($black, 0.45) !default;
 }
 
 @mixin foundation-reveal {
-  // [TODO] Is this necessary?
-  body.is-reveal-open { // sass-lint:disable-line no-qualifying-elements
-    overflow: hidden;
-  }
 
-  // html gets this class only in iOS
-  html.is-reveal-open,
-  html.is-reveal-open body {
-    min-height: 100%;
-    overflow: hidden;
+  /// Disables the scroll when Reveal is shown to prevent the background from shifting
+  html.is-reveal-open {
     position: fixed;
-    user-select: none;
+    width: 100%;
+    overflow-y: scroll;
+
+    body { // sass-lint:disable-line no-qualifying-elements
+      overflow: hidden;
+    }
   }
 
   // Overlay
@@ -178,11 +176,3 @@ $reveal-overlay-background: rgba($black, 0.45) !default;
     }
   }
 }
-
-
-/// Disables the scroll when Reveal is shown to prevent the background from shifting
-html.disable-scroll {
-    position: fixed;
-    width: 100%;
-    overflow-y: scroll;
-}