From: Kevin Ball Date: Tue, 18 Apr 2017 23:31:45 +0000 (-0700) Subject: Port new smoothscroll module to the new approach X-Git-Tag: v6.4.0-rc1~51^2~15 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f7bc7979f1ec05823624aeacff57ddc91bad751f;p=thirdparty%2Ffoundation%2Ffoundation-sites.git Port new smoothscroll module to the new approach --- diff --git a/docs/layout/default.html b/docs/layout/default.html index d14d97f70..cc3a22e21 100644 --- a/docs/layout/default.html +++ b/docs/layout/default.html @@ -97,6 +97,7 @@ + diff --git a/gulp/tasks/javascript.js b/gulp/tasks/javascript.js index 1a10eda49..d65ee789d 100644 --- a/gulp/tasks/javascript.js +++ b/gulp/tasks/javascript.js @@ -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 diff --git a/js/entries/foundation.js b/js/entries/foundation.js index 59311b4bc..990b055e8 100644 --- a/js/entries/foundation.js +++ b/js/entries/foundation.js @@ -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 index 000000000..3804abbb2 --- /dev/null +++ b/js/entries/plugins/foundation.smoothScroll.js @@ -0,0 +1,5 @@ +import { Foundation } from './foundation.core'; + +import { SmoothScroll } from '../../foundation.smoothScroll'; +Foundation.plugin(SmoothScroll, 'SmoothScroll'); + diff --git a/js/foundation.magellan.js b/js/foundation.magellan.js index cb828911e..b46d2f586 100644 --- a/js/foundation.magellan.js +++ b/js/foundation.magellan.js @@ -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(); }) diff --git a/js/foundation.smoothScroll.js b/js/foundation.smoothScroll.js index f81a8a14c..b81e3d301 100644 --- a/js/foundation.smoothScroll.js +++ b/js/foundation.smoothScroll.js @@ -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}