From: Ben Zhang Date: Fri, 11 Jan 2019 23:33:50 +0000 (+0100) Subject: Use pull request #11622 from ben-z/fix-smooth-scroll-options for v6.5.0 X-Git-Tag: v6.5.2^2~20 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=76e8b0d3a35e8fc52b87f1cb21fd874e39af030e;p=thirdparty%2Ffoundation%2Ffoundation-sites.git Use pull request #11622 from ben-z/fix-smooth-scroll-options for v6.5.0 ae8363a3f Fix smoothscroll not applying custom options 8dd706557 fix: correctly remove the event listener in _destroy 9767057c2 fix: fix spelling Signed-off-by: Nicolas Coden --- diff --git a/js/foundation.smoothScroll.js b/js/foundation.smoothScroll.js index 4674061c1..68e38a70d 100644 --- a/js/foundation.smoothScroll.js +++ b/js/foundation.smoothScroll.js @@ -39,8 +39,9 @@ class SmoothScroll extends Plugin { * @private */ _events() { - this.$element.on('click.zf.smoothScroll', this._handleLinkClick) - this.$element.on('click.zf.smoothScroll', 'a[href^="#"]', this._handleLinkClick); + this._linkClickListener = this._handleLinkClick.bind(this); + this.$element.on('click.zf.smoothScroll', this._linkClickListener); + this.$element.on('click.zf.smoothScroll', 'a[href^="#"]', this._linkClickListener); } /** @@ -97,8 +98,8 @@ class SmoothScroll extends Plugin { * @function */ _destroy() { - this.$element.off('click.zf.smoothScroll', this._handleLinkClick) - this.$element.off('click.zf.smoothScroll', 'a[href^="#"]', this._handleLinkClick); + this.$element.off('click.zf.smoothScroll', this._linkClickListener) + this.$element.off('click.zf.smoothScroll', 'a[href^="#"]', this._linkClickListener); } }