From 0caa4752effbccdda8666b077db242d1622524be Mon Sep 17 00:00:00 2001 From: Igal Sapir Date: Tue, 29 Aug 2017 23:49:43 -0700 Subject: [PATCH] merged .disable-scroll into .is-reveal-open and removed obsolete code --- js/foundation.reveal.js | 29 ++++++++--------------------- scss/components/_reveal.scss | 26 ++++++++------------------ 2 files changed, 16 insertions(+), 39 deletions(-) diff --git a/js/foundation.reveal.js b/js/foundation.reveal.js index adfa2700c..0ba3e4e77 100644 --- a/js/foundation.reveal.js +++ b/js/foundation.reveal.js @@ -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}; diff --git a/scss/components/_reveal.scss b/scss/components/_reveal.scss index a74c545f3..897e7d542 100644 --- a/scss/components/_reveal.scss +++ b/scss/components/_reveal.scss @@ -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; -} -- 2.47.2