]> git.ipfire.org Git - thirdparty/foundation/foundation-sites.git/commitdiff
Port new smoothscroll module to the new approach
authorKevin Ball <kmball11@gmail.com>
Tue, 18 Apr 2017 23:31:45 +0000 (16:31 -0700)
committerKevin Ball <kmball11@gmail.com>
Tue, 18 Apr 2017 23:31:45 +0000 (16:31 -0700)
docs/layout/default.html
gulp/tasks/javascript.js
js/entries/foundation.js
js/entries/plugins/foundation.smoothScroll.js [new file with mode: 0644]
js/foundation.magellan.js
js/foundation.smoothScroll.js

index d14d97f7048112216f2154043c40019ee3479b57..cc3a22e213132cb779a48eaf0670c6c44679dd9e 100644 (file)
@@ -97,6 +97,7 @@
   <script src="assets/js/plugins/foundation.dropdownMenu.js"></script>
   <script src="assets/js/plugins/foundation.equalizer.js"></script>
   <script src="assets/js/plugins/foundation.interchange.js"></script>
+  <script src="assets/js/plugins/foundation.smoothScroll.js"></script>
   <script src="assets/js/plugins/foundation.magellan.js"></script>
   <script src="assets/js/plugins/foundation.offcanvas.js"></script>
   <script src="assets/js/plugins/foundation.orbit.js"></script>
index 1a10eda491fd23d8cdae18c08d911afb9e6d2f41..d65ee789d12c0b292281db92723551035633bc20 100644 (file)
@@ -34,6 +34,7 @@ var pluginsAsExternals = {
   './foundation.accordionMenu' : '{AccordionMenu: window.Foundation.AccordionMenu}',
   './foundation.accordion' : '{Accordion: window.Foundation.Accordion}',
   './foundation.tabs' : '{Tabs: window.Foundation.Tabs}',
+  './foundation.smoothScroll' : '{SmoothScroll: window.Foundation.SmoothScroll}',
 }
 
 // Core has to be dealt with slightly differently due to bootstrapping externals
index 59311b4bc4d41c628fd055e7c6e7c488fd75401b..990b055e89fa5595f2bffb6f4b131cb14cb1287f 100644 (file)
@@ -82,6 +82,9 @@ Foundation.plugin(Reveal, 'Reveal');
 import { Slider } from '../foundation.slider';
 Foundation.plugin(Slider, 'Slider');
 
+import { SmoothScroll } from '../foundation.smoothScroll';
+Foundation.plugin(SmoothScroll, 'SmoothScroll');
+
 import { Sticky } from '../foundation.sticky';
 Foundation.plugin(Sticky, 'Sticky');
 
diff --git a/js/entries/plugins/foundation.smoothScroll.js b/js/entries/plugins/foundation.smoothScroll.js
new file mode 100644 (file)
index 0000000..3804abb
--- /dev/null
@@ -0,0 +1,5 @@
+import { Foundation } from './foundation.core';
+
+import { SmoothScroll } from '../../foundation.smoothScroll';
+Foundation.plugin(SmoothScroll, 'SmoothScroll');
+
index cb828911eb5ab7625344011a69c44279a09d84b6..b46d2f5863a4eee09d76bf099d4e626f2af31512 100644 (file)
@@ -4,6 +4,7 @@
 import $ from 'jquery';
 import { GetYoDigits } from './foundation.util.core';
 import { Plugin } from './foundation.plugin';
+import { SmoothScroll } from './foundation.smoothScroll';
 
 /**
  * Magellan module.
@@ -121,7 +122,7 @@ class Magellan extends Plugin {
       offset: this.options.offset
     };
 
-    Foundation.SmoothScroll.scrollToLoc(loc, options, function() {
+    SmoothScroll.scrollToLoc(loc, options, function() {
       _this._inTransition = false;
       _this._updateActive();
     })
index f81a8a14c1f4b49409859ff7cc3b6d1fa1d3273c..b81e3d30188ff74408a717cd04cb52d9b1cc6114 100644 (file)
@@ -1,19 +1,19 @@
 'use strict';
 
-!function($) {
+import $ from 'jquery';
+import { GetYoDigits } from './foundation.util.core';
+import { Plugin } from './foundation.plugin';
 
 /**
  * SmoothScroll module.
  * @module foundation.smooth-scroll
  */
-class SmoothScroll {
-    constructor(element, options) {
+class SmoothScroll extends Plugin {
+    _setup(element, options) {
         this.$element = element;
         this.options = $.extend({}, SmoothScroll.defaults, this.$element.data(), options);
 
         this._init();
-
-        Foundation.registerPlugin(this, 'SmoothScroll');
     }
 
     /**
@@ -21,7 +21,7 @@ class SmoothScroll {
      * @private
      */
     _init() {
-        var id = this.$element[0].id || Foundation.GetYoDigits(6, 'smooth-scroll');
+        var id = this.$element[0].id || GetYoDigits(6, 'smooth-scroll');
         var _this = this;
         this.$element.attr({
             'id': id
@@ -86,14 +86,6 @@ class SmoothScroll {
             }
         );
     }
-
-   /**
-    * Destroys an instance of SmoothScroll.
-    * @function
-    */
-    destory() {
-        Foundation.unregisterPlugin(this);
-    }
 }
 
 /**
@@ -131,6 +123,4 @@ SmoothScroll.defaults = {
   offset: 0
 }
 
-// Window exports
-Foundation.plugin(SmoothScroll, 'SmoothScroll');
-}(jQuery);
+export {SmoothScroll}