]> git.ipfire.org Git - thirdparty/foundation/foundation-sites.git/commitdiff
Use pull request #11622 from ben-z/fix-smooth-scroll-options for v6.5.0
authorBen Zhang <benzhangniu@gmail.com>
Fri, 11 Jan 2019 23:33:50 +0000 (00:33 +0100)
committerNicolas Coden <nicolas@ncoden.fr>
Fri, 11 Jan 2019 23:33:50 +0000 (00:33 +0100)
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 <nicolas@ncoden.fr>
js/foundation.smoothScroll.js

index 4674061c1f9b667e0308a0ead41508f0eb0d948f..68e38a70dea6a65ba9f36345c00e17c2e3b54bc5 100644 (file)
@@ -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);
     }
 }