From: Nicolas Coden Date: Sat, 20 Jan 2018 14:42:43 +0000 (+0100) Subject: refactor: add defaults to `_enableScroll`/`_disableScroll` properties in Reveal X-Git-Tag: v6.6.0~3^2~314^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4f2773318;p=thirdparty%2Ffoundation%2Ffoundation-sites.git refactor: add defaults to `_enableScroll`/`_disableScroll` properties in Reveal Try to keep a more or less enclosed behavior by using defaults properties. The functions behaviors can be changed when needed. --- diff --git a/js/foundation.reveal.js b/js/foundation.reveal.js index 369b2ebc7..3c1bad753 100644 --- a/js/foundation.reveal.js +++ b/js/foundation.reveal.js @@ -186,7 +186,8 @@ class Reveal extends Plugin { * Disables the scroll when Reveal is shown to prevent the background from shifting * @param {number} scrollTop */ - _disableScroll(scrollTop){ + _disableScroll(scrollTop) { + scrollTop = scrollTop || $(window).scrollTop(); if ($(document).height() > $(window).height()) { $("html") .css("top", -scrollTop); @@ -197,7 +198,8 @@ class Reveal extends Plugin { * Reenables the scroll when Reveal closes * @param {number} scrollTop */ - _enableScroll(scrollTop){ + _enableScroll(scrollTop) { + scrollTop = scrollTop || parseInt($("html").css("top")); if ($(document).height() > $(window).height()) { $("html") .css("top", ""); @@ -264,9 +266,7 @@ class Reveal extends Plugin { this.$element.trigger('closeme.zf.reveal', this.id); } - var scrollTop = $(window).scrollTop(); - - this._disableScroll(scrollTop); + this._disableScroll(); var _this = this;