From 4f277331858ad817a855106e00a7169d4f749df3 Mon Sep 17 00:00:00 2001 From: Nicolas Coden Date: Sat, 20 Jan 2018 15:42:43 +0100 Subject: [PATCH] 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. --- js/foundation.reveal.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) 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; -- 2.47.2