From c109276ef6f6e2d1e55a99c00e5538925c45ba18 Mon Sep 17 00:00:00 2001 From: Luis Date: Fri, 14 Jul 2017 23:32:15 +0200 Subject: [PATCH] Scrolling to current slide when index is shown --- src/js/plugins/zoom.js | 10 +- src/js/utils/scroll-to.js | 8 +- static/css/webslides.css | 2 +- static/js/webslides.js | 193 +++++++++++++++++++------------------ static/js/webslides.min.js | 4 +- 5 files changed, 117 insertions(+), 100 deletions(-) diff --git a/src/js/plugins/zoom.js b/src/js/plugins/zoom.js index 86d896e..5323a71 100644 --- a/src/js/plugins/zoom.js +++ b/src/js/plugins/zoom.js @@ -1,5 +1,6 @@ import DOM from '../utils/dom'; import Keys from '../utils/keys'; +import scrollTo from '../utils/scroll-to'; import Slide from '../modules/slide'; const CLASSES = { @@ -139,9 +140,9 @@ export default class Zoom { if (zoomedCurrent) { zoomedCurrent.classList.remove(CLASSES.CURRENT); } - this.zws_.el - .querySelector(`#zoomed-${currentId}`) - .classList.add(CLASSES.CURRENT); + const actualCurrent = this.zws_.el + .querySelector(`#zoomed-${currentId}`); + actualCurrent.classList.add(CLASSES.CURRENT); this.isZoomed_ = true; document.body.style.overflow = 'auto'; @@ -149,6 +150,9 @@ export default class Zoom { setTimeout(() => { this.ws_.disable(); this.zws_.el.classList.add('in'); + const wrapCSS = window.getComputedStyle(this.zws_.grid); + scrollTo(actualCurrent.parentNode.offsetTop + + DOM.parseSize(wrapCSS.paddingTop), 50, () => {}, document.body); }, 50); } diff --git a/src/js/utils/scroll-to.js b/src/js/utils/scroll-to.js index 844fe0c..53e6b9f 100644 --- a/src/js/utils/scroll-to.js +++ b/src/js/utils/scroll-to.js @@ -8,9 +8,13 @@ let SCROLLABLE_CONTAINER = null; * @param {number} y Offset of the page to scroll to. * @param {number} duration Duration of the animation. 500ms by default. * @param {function} cb Callback function to call upon completion. + * @param {HTMLElement} container The HTML element where to scroll */ -export default function scrollTo(y, duration = 500, cb = () => {}) { - if (!SCROLLABLE_CONTAINER) { +export default function scrollTo(y, duration = 500, cb = () => {}, + container = null) { + if (container) { + SCROLLABLE_CONTAINER = container; + } else if (!SCROLLABLE_CONTAINER) { SCROLLABLE_CONTAINER = document.getElementById('webslides'); } diff --git a/static/css/webslides.css b/static/css/webslides.css index 8d932a2..5d7e841 100644 --- a/static/css/webslides.css +++ b/static/css/webslides.css @@ -1,7 +1,7 @@ /*! * Name: WebSlides * Version: 1.3.1 - * Date: 2017-07-13 + * Date: 2017-07-14 * Description: Making HTML presentations easy * URL: https://github.com/webslides/webslides#readme * Credits: @jlantunez, @LuisSacristan, @Belelros diff --git a/static/js/webslides.js b/static/js/webslides.js index f56f5eb..6495386 100644 --- a/static/js/webslides.js +++ b/static/js/webslides.js @@ -1,7 +1,7 @@ /*! * Name: WebSlides * Version: 1.3.1 - * Date: 2017-07-13 + * Date: 2017-07-14 * Description: Making HTML presentations easy * URL: https://github.com/webslides/webslides#readme * Credits: @jlantunez, @LuisSacristan, @Belelros @@ -71,7 +71,7 @@ /******/ __webpack_require__.p = "/static/js/"; /******/ /******/ // Load entry module and return exports -/******/ return __webpack_require__(__webpack_require__.s = 6); +/******/ return __webpack_require__(__webpack_require__.s = 7); /******/ }) /************************************************************************/ /******/ ([ @@ -79,7 +79,7 @@ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__custom_event__ = __webpack_require__(19); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__custom_event__ = __webpack_require__(20); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } @@ -687,10 +687,69 @@ var MobileDetector = function () { /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__plugins_plugins__ = __webpack_require__(13); +/* harmony export (immutable) */ __webpack_exports__["a"] = scrollTo; +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__easing__ = __webpack_require__(21); + + +var SCROLLABLE_CONTAINER = null; + +/** + * Smoothly scrolls to a given Y position using Easing.Swing. It'll run a + * callback upon finishing. + * @param {number} y Offset of the page to scroll to. + * @param {number} duration Duration of the animation. 500ms by default. + * @param {function} cb Callback function to call upon completion. + * @param {HTMLElement} container The HTML element where to scroll + */ +function scrollTo(y) { + var duration = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 500; + var cb = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : function () {}; + var container = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null; + + if (container) { + SCROLLABLE_CONTAINER = container; + } else if (!SCROLLABLE_CONTAINER) { + SCROLLABLE_CONTAINER = document.getElementById('webslides'); + } + + var delta = y - SCROLLABLE_CONTAINER.scrollTop; + var startLocation = SCROLLABLE_CONTAINER.scrollTop; + var increment = 16; + + if (!duration) { + SCROLLABLE_CONTAINER.scrollTop = y; + cb(); + return; + } + + var animateScroll = function animateScroll(elapsedTime) { + elapsedTime += increment; + var percent = Math.min(1, elapsedTime / duration); + var easingP = __WEBPACK_IMPORTED_MODULE_0__easing__["a" /* default */].swing(percent, elapsedTime * percent, y, delta, duration); + + SCROLLABLE_CONTAINER.scrollTop = Math.floor(startLocation + easingP * delta); + + if (elapsedTime < duration) { + setTimeout(function () { + return animateScroll(elapsedTime); + }, increment); + } else { + cb(); + } + }; + + animateScroll(0); +} + +/***/ }), +/* 5 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__plugins_plugins__ = __webpack_require__(14); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__slide__ = __webpack_require__(1); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__utils_dom__ = __webpack_require__(0); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__utils_scroll_to__ = __webpack_require__(21); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__utils_scroll_to__ = __webpack_require__(4); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } @@ -1226,25 +1285,25 @@ var WebSlides = function () { /* harmony default export */ __webpack_exports__["a"] = (WebSlides); /***/ }), -/* 5 */ +/* 6 */ /***/ (function(module, exports) { // removed by extract-text-webpack-plugin /***/ }), -/* 6 */ +/* 7 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__modules_webslides__ = __webpack_require__(4); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__modules_webslides__ = __webpack_require__(5); -__webpack_require__(5); +__webpack_require__(6); window.WebSlides = __WEBPACK_IMPORTED_MODULE_0__modules_webslides__["a" /* default */]; /***/ }), -/* 7 */ +/* 8 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -1347,7 +1406,7 @@ var AutoSlide = function () { /* harmony default export */ __webpack_exports__["a"] = (AutoSlide); /***/ }), -/* 8 */ +/* 9 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -1403,7 +1462,7 @@ var ClickNav = function () { /* harmony default export */ __webpack_exports__["a"] = (ClickNav); /***/ }), -/* 9 */ +/* 10 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -1473,7 +1532,7 @@ var Grid = function () { /* harmony default export */ __webpack_exports__["a"] = (Grid); /***/ }), -/* 10 */ +/* 11 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -1580,7 +1639,7 @@ var Hash = function () { /* harmony default export */ __webpack_exports__["a"] = (Hash); /***/ }), -/* 11 */ +/* 12 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -1677,7 +1736,7 @@ var Keyboard = function () { /* harmony default export */ __webpack_exports__["a"] = (Keyboard); /***/ }), -/* 12 */ +/* 13 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -1853,21 +1912,21 @@ var Navigation = function () { /* harmony default export */ __webpack_exports__["a"] = (Navigation); /***/ }), -/* 13 */ +/* 14 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__autoslide__ = __webpack_require__(7); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__click_nav__ = __webpack_require__(8); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__grid__ = __webpack_require__(9); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__hash__ = __webpack_require__(10); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__keyboard__ = __webpack_require__(11); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__navigation__ = __webpack_require__(12); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__scroll__ = __webpack_require__(14); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__touch__ = __webpack_require__(15); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__video__ = __webpack_require__(16); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__youtube__ = __webpack_require__(17); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__zoom__ = __webpack_require__(18); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__autoslide__ = __webpack_require__(8); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__click_nav__ = __webpack_require__(9); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__grid__ = __webpack_require__(10); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__hash__ = __webpack_require__(11); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__keyboard__ = __webpack_require__(12); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__navigation__ = __webpack_require__(13); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__scroll__ = __webpack_require__(15); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__touch__ = __webpack_require__(16); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__video__ = __webpack_require__(17); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__youtube__ = __webpack_require__(18); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__zoom__ = __webpack_require__(19); @@ -1895,7 +1954,7 @@ var Navigation = function () { }); /***/ }), -/* 14 */ +/* 15 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -2037,7 +2096,7 @@ var Scroll = function () { /* harmony default export */ __webpack_exports__["a"] = (Scroll); /***/ }), -/* 15 */ +/* 16 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -2287,7 +2346,7 @@ var Touch = function () { /* harmony default export */ __webpack_exports__["a"] = (Touch); /***/ }), -/* 16 */ +/* 17 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -2374,7 +2433,7 @@ var Video = function () { /* harmony default export */ __webpack_exports__["a"] = (Video); /***/ }), -/* 17 */ +/* 18 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -2710,13 +2769,14 @@ var YouTube = function () { /* harmony default export */ __webpack_exports__["a"] = (YouTube); /***/ }), -/* 18 */ +/* 19 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__utils_dom__ = __webpack_require__(0); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__utils_keys__ = __webpack_require__(2); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__modules_slide__ = __webpack_require__(1); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__utils_scroll_to__ = __webpack_require__(4); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__modules_slide__ = __webpack_require__(1); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } @@ -2725,6 +2785,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons + var CLASSES = { ZOOM: 'grid', DIV: 'column', @@ -2818,7 +2879,7 @@ var Zoom = function () { this.zws_.slides = [].map.call(this.ws_.slides, function (slide, i) { var s_ = slide.el.cloneNode(true); _this.zws_.grid.appendChild(s_); - return new __WEBPACK_IMPORTED_MODULE_2__modules_slide__["a" /* default */](s_, i); + return new __WEBPACK_IMPORTED_MODULE_3__modules_slide__["a" /* default */](s_, i); }); __WEBPACK_IMPORTED_MODULE_0__utils_dom__["a" /* default */].hide(this.zws_.el); @@ -2891,7 +2952,8 @@ var Zoom = function () { if (zoomedCurrent) { zoomedCurrent.classList.remove(CLASSES.CURRENT); } - this.zws_.el.querySelector('#zoomed-' + currentId).classList.add(CLASSES.CURRENT); + var actualCurrent = this.zws_.el.querySelector('#zoomed-' + currentId); + actualCurrent.classList.add(CLASSES.CURRENT); this.isZoomed_ = true; document.body.style.overflow = 'auto'; @@ -2899,6 +2961,8 @@ var Zoom = function () { setTimeout(function () { _this3.ws_.disable(); _this3.zws_.el.classList.add('in'); + var wrapCSS = window.getComputedStyle(_this3.zws_.grid); + __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_2__utils_scroll_to__["a" /* default */])(actualCurrent.parentNode.offsetTop + __WEBPACK_IMPORTED_MODULE_0__utils_dom__["a" /* default */].parseSize(wrapCSS.paddingTop), 50, function () {}, document.body); }, 50); } @@ -2928,7 +2992,7 @@ var Zoom = function () { /* harmony default export */ __webpack_exports__["a"] = (Zoom); /***/ }), -/* 19 */ +/* 20 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -2979,7 +3043,7 @@ var WSCustomEvent = canIuseNativeCustom() ? NativeCustomEvent : IECustomEvent; /* harmony default export */ __webpack_exports__["a"] = (WSCustomEvent); /***/ }), -/* 20 */ +/* 21 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -2994,60 +3058,5 @@ function swing(p) { /* harmony default export */ __webpack_exports__["a"] = ({ swing: swing }); -/***/ }), -/* 21 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -/* harmony export (immutable) */ __webpack_exports__["a"] = scrollTo; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__easing__ = __webpack_require__(20); - - -var SCROLLABLE_CONTAINER = null; - -/** - * Smoothly scrolls to a given Y position using Easing.Swing. It'll run a - * callback upon finishing. - * @param {number} y Offset of the page to scroll to. - * @param {number} duration Duration of the animation. 500ms by default. - * @param {function} cb Callback function to call upon completion. - */ -function scrollTo(y) { - var duration = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 500; - var cb = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : function () {}; - - if (!SCROLLABLE_CONTAINER) { - SCROLLABLE_CONTAINER = document.getElementById('webslides'); - } - - var delta = y - SCROLLABLE_CONTAINER.scrollTop; - var startLocation = SCROLLABLE_CONTAINER.scrollTop; - var increment = 16; - - if (!duration) { - SCROLLABLE_CONTAINER.scrollTop = y; - cb(); - return; - } - - var animateScroll = function animateScroll(elapsedTime) { - elapsedTime += increment; - var percent = Math.min(1, elapsedTime / duration); - var easingP = __WEBPACK_IMPORTED_MODULE_0__easing__["a" /* default */].swing(percent, elapsedTime * percent, y, delta, duration); - - SCROLLABLE_CONTAINER.scrollTop = Math.floor(startLocation + easingP * delta); - - if (elapsedTime < duration) { - setTimeout(function () { - return animateScroll(elapsedTime); - }, increment); - } else { - cb(); - } - }; - - animateScroll(0); -} - /***/ }) /******/ ]); \ No newline at end of file diff --git a/static/js/webslides.min.js b/static/js/webslides.min.js index 72c861f..9bd11b7 100644 --- a/static/js/webslides.min.js +++ b/static/js/webslides.min.js @@ -1,9 +1,9 @@ /*! * Name: WebSlides * Version: 1.3.1 - * Date: 2017-07-13 + * Date: 2017-07-14 * Description: Making HTML presentations easy * URL: https://github.com/webslides/webslides#readme * Credits: @jlantunez, @LuisSacristan, @Belelros */ -!function(e){function t(n){if(i[n])return i[n].exports;var s=i[n]={i:n,l:!1,exports:{}};return e[n].call(s.exports,s,s.exports,t),s.l=!0,s.exports}var i={};t.m=e,t.c=i,t.i=function(e){return e},t.d=function(e,i,n){t.o(e,i)||Object.defineProperty(e,i,{configurable:!1,enumerable:!0,get:n})},t.n=function(e){var i=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(i,"a",i),i},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="/static/js/",t(t.s=6)}([function(e,t,i){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var s=i(19),o=function(){function e(e,t){for(var i=0;i1&&void 0!==arguments[1]?arguments[1]:"",i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",n=document.createElement(e);return t&&(n.id=t),i&&(n.textContent=i),n}},{key:"once",value:function(e,t,i){var n=function n(s){s.target===e&&(e.removeEventListener(t,n),i(s))};e.addEventListener(t,n,!1)}},{key:"getTransitionEvent",value:function(e){if(a&&!e)return a;a="";for(var t=e||document.createElement("ws"),i={transition:"transitionend",OTransition:"oTransitionEnd",MozTransition:"transitionend",WebkitTransition:"webkitTransitionEnd"},n=Object.keys(i),s=0,o=n.length;s2&&void 0!==arguments[2]?arguments[2]:{},n=new s.a(t,{detail:i});e.dispatchEvent(n)}},{key:"toArray",value:function(e){return[].slice.call(e)}},{key:"isFocusableElement",value:function(){var e=!1;if(document.activeElement){var t="inherit"!==document.activeElement.contentEditable&&void 0!==document.activeElement.contentEditable;e=["INPUT","SELECT","OPTION","TEXTAREA"].indexOf(document.activeElement.tagName)>-1||t}return e}},{key:"parseSize",value:function(e){return Number(e.replace(/[^\d\.]/g,""))}},{key:"wrap",value:function(e,t){var i=document.createElement(t);return e.parentElement.insertBefore(i,e),i.appendChild(e),i}},{key:"after",value:function(e,t){var i=t.parentNode;i.lastChild===t?i.appendChild(e):i.insertBefore(e,t.nextSibling)}}]),e}();t.a=l},function(e,t,i){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}i.d(t,"a",function(){return l}),i.d(t,"b",function(){return r});var s=i(0),o=function(){function e(e,t){for(var i=0;i0&&void 0!==arguments[0]?arguments[0]:{},i=t.autoslide,s=void 0!==i&&i,o=t.changeOnClick,a=void 0!==o&&o,r=t.loop,l=void 0===r||r,c=t.minWheelDelta,h=void 0===c?40:c,d=t.navigateOnScroll,f=void 0===d||d,v=t.scrollWait,y=void 0===v?450:v,p=t.slideOffset,m=void 0===p?50:p;if(n(this,e),this.el=document.getElementById("webslides"),!this.el)throw new Error("Couldn't find the webslides container!");this.isMoving=!1,this.slides=null,this.currentSlideI_=-1,this.currentSlide_=null,this.maxSlide_=0,this.isVertical=this.el.classList.contains(u.VERTICAL),this.plugins={},this.options={autoslide:s,changeOnClick:a,loop:l,minWheelDelta:h,navigateOnScroll:f,scrollWait:y,slideOffset:m},this.initialised=!1,this.removeChildren_(),this.grabSlides_(),this.createPlugins_(),this.initSlides_(),this.onInit_()}return l(e,[{key:"removeChildren_",value:function(){for(var e=this.el.childNodes,t=e.length;t--;){var i=e[t];o.a.isCandidate(i)||this.el.removeChild(i)}}},{key:"createPlugins_",value:function(){var e=this;Object.keys(c).forEach(function(t){var i=c[t];e.plugins[t]=new i(e)})}},{key:"onInit_",value:function(){this.initialised=!0,a.a.fireEvent(this.el,"ws:init"),document.documentElement.classList.add(u.READY)}},{key:"grabSlides_",value:function(){this.slides=a.a.toArray(this.el.childNodes).map(function(e,t){return new o.a(e,t)}),this.maxSlide_=this.slides.length}},{key:"goToSlide",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(this.isValidIndexSlide_(e)&&!this.isMoving&&this.currentSlideI_!==e){this.isMoving=!0;var i=!1;null!==t?i=t:this.currentSlideI_>=0&&(i=e>this.currentSlideI_);var n=this.slides[e];null===this.currentSlide_||!this.isVertical||this.plugins.touch&&this.plugins.touch.isEnabled?this.transitionToSlide_(i,n,this.onSlideChange_):this.scrollTransitionToSlide_(i,n,this.onSlideChange_)}}},{key:"scrollTransitionToSlide_",value:function(e,t,n){var s=this;this.el.style.overflow="hidden",e?t.show():(t.moveBeforeFirst(),t.show(),i.i(r.a)(this.currentSlide_.el.offsetTop,0)),i.i(r.a)(t.el.offsetTop,500,function(){s.currentSlide_.hide(),e&&s.currentSlide_.moveAfterLast(),s.el.style.overflow="auto",setTimeout(function(){n.call(s,t)},150)})}},{key:"transitionToSlide_",value:function(e,t,n){var s=this;i.i(r.a)(0,0);var o="slideInRight";e||(t.moveBeforeFirst(),o="slideInLeft"),this.currentSlide_&&(e&&this.currentSlide_.moveAfterLast(),this.currentSlide_.hide()),t.show(),this.initialised&&this.plugins.touch&&this.plugins.touch.isEnabled?(a.a.once(t.el,a.a.getAnimationEvent(),function(){t.el.classList.remove(o),n.call(s,t)}),t.el.classList.add(o)):n.call(this,t)}},{key:"onSlideChange_",value:function(e){this.currentSlide_&&this.currentSlide_.disable(),this.currentSlide_=e,this.currentSlideI_=e.i,this.currentSlide_.enable(),this.isMoving=!1,a.a.fireEvent(this.el,"ws:slide-change",{slides:this.maxSlide_,currentSlide0:this.currentSlideI_,currentSlide:this.currentSlideI_+1})}},{key:"goNext",value:function(){var e=this.currentSlideI_+1;if(e>=this.maxSlide_){if(!this.options.loop)return;e=0}this.goToSlide(e,!0)}},{key:"goPrev",value:function(){var e=this.currentSlideI_-1;if(e<0){if(!this.options.loop)return;e=this.maxSlide_-1}this.goToSlide(e,!1)}},{key:"isValidIndexSlide_",value:function(e){return"number"==typeof e&&e>=0&&e=this.maxSlide_)&&(e=0),0!==e)for(var t=0;t0&&(this.interval_=setInterval(this.ws_.goNext.bind(this.ws_),e))}},{key:"stop",value:function(){this.interval_&&(clearInterval(this.interval_),this.interval_=null)}}]),e}();t.a=a},function(e,t,i){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var s=function(){function e(e,t){for(var i=0;iMath.abs(i);if(this.isGoingUp_=i<0,this.isGoingLeft_=n<0,o){if(s)return;e.preventDefault()}(Math.abs(i+t)>=this.ws_.options.minWheelDelta||Math.abs(n+t)>=this.ws_.options.minWheelDelta)&&(o&&this.isGoingLeft_||!o&&this.isGoingUp_?this.ws_.goPrev():this.ws_.goNext(),e.preventDefault())}}}]),e}();t.a=a},function(e,t,i){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var s=i(3),o=function(){function e(e,t){for(var i=0;i1&&(this.startTouches=e.getTouchCoordinates(t),this.endTouches=this.startTouches,this.isGesture=!0)}}},{key:"onMove_",value:function(t){if(!this.ws_.isDisabled()){var i=e.normalizeEventInfo(t);this.isGesture?this.endTouches=e.getTouchCoordinates(t):(this.endX_=i.x,this.endY_=i.y)}}},{key:"onStop_",value:function(){if(!this.ws_.isDisabled())if(this.isGesture){var e=Math.sqrt(Math.pow(this.startTouches[0].x-this.startTouches[1].x,2)+Math.pow(this.startTouches[0].y-this.startTouches[1].y,2)),t=Math.sqrt(Math.pow(this.endTouches[0].x-this.endTouches[1].x,2)+Math.pow(this.endTouches[0].y-this.endTouches[1].y,2));e>t&&this.ws_.toggleZoom(),this.isGesture=!1}else{var i=this.startX_-this.endX_,n=this.startY_-this.endY_;Math.abs(i)>Math.abs(n)&&(i<-this.ws_.options.slideOffset?this.ws_.goPrev():i>this.ws_.options.slideOffset&&this.ws_.goNext())}}}],[{key:"getTouchCoordinates",value:function(e){return[{x:e.touches[0].clientX,y:e.touches[0].clientY},{x:e.touches[1].clientX,y:e.touches[1].clientY}]}},{key:"normalizeEventInfo",value:function(e){var t={pageX:0,pageY:0};return void 0!==e.changedTouches?t=e.changedTouches[0]:void 0!==e.originalEvent&&void 0!==e.originalEvent.changedTouches&&(t=e.originalEvent.changedTouches[0]),{x:e.offsetX||e.layerX||t.pageX,y:e.offsetY||e.layerY||t.pageY}}}]),e}();t.a=r},function(e,t,i){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var s=i(0),o=i(1),a=function(){function e(e,t){for(var i=0;i1&&void 0!==arguments[1]?arguments[1]:500,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:function(){};o||(o=document.getElementById("webslides"));var n=e-o.scrollTop,a=o.scrollTop;if(!t)return o.scrollTop=e,void i();!function r(l){l+=16;var u=Math.min(1,l/t),c=s.a.swing(u,l*u,e,n,t);o.scrollTop=Math.floor(a+c*n),l1&&void 0!==arguments[1]?arguments[1]:"",i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",n=document.createElement(e);return t&&(n.id=t),i&&(n.textContent=i),n}},{key:"once",value:function(e,t,i){var n=function n(s){s.target===e&&(e.removeEventListener(t,n),i(s))};e.addEventListener(t,n,!1)}},{key:"getTransitionEvent",value:function(e){if(a&&!e)return a;a="";for(var t=e||document.createElement("ws"),i={transition:"transitionend",OTransition:"oTransitionEnd",MozTransition:"transitionend",WebkitTransition:"webkitTransitionEnd"},n=Object.keys(i),s=0,o=n.length;s2&&void 0!==arguments[2]?arguments[2]:{},n=new s.a(t,{detail:i});e.dispatchEvent(n)}},{key:"toArray",value:function(e){return[].slice.call(e)}},{key:"isFocusableElement",value:function(){var e=!1;if(document.activeElement){var t="inherit"!==document.activeElement.contentEditable&&void 0!==document.activeElement.contentEditable;e=["INPUT","SELECT","OPTION","TEXTAREA"].indexOf(document.activeElement.tagName)>-1||t}return e}},{key:"parseSize",value:function(e){return Number(e.replace(/[^\d\.]/g,""))}},{key:"wrap",value:function(e,t){var i=document.createElement(t);return e.parentElement.insertBefore(i,e),i.appendChild(e),i}},{key:"after",value:function(e,t){var i=t.parentNode;i.lastChild===t?i.appendChild(e):i.insertBefore(e,t.nextSibling)}}]),e}();t.a=l},function(e,t,i){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}i.d(t,"a",function(){return l}),i.d(t,"b",function(){return r});var s=i(0),o=function(){function e(e,t){for(var i=0;i1&&void 0!==arguments[1]?arguments[1]:500,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:function(){},n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;n?o=n:o||(o=document.getElementById("webslides"));var a=e-o.scrollTop,r=o.scrollTop;if(!t)return o.scrollTop=e,void i();!function n(l){l+=16;var u=Math.min(1,l/t),c=s.a.swing(u,l*u,e,a,t);o.scrollTop=Math.floor(r+c*a),l0&&void 0!==arguments[0]?arguments[0]:{},i=t.autoslide,s=void 0!==i&&i,o=t.changeOnClick,a=void 0!==o&&o,r=t.loop,l=void 0===r||r,c=t.minWheelDelta,d=void 0===c?40:c,h=t.navigateOnScroll,f=void 0===h||h,v=t.scrollWait,y=void 0===v?450:v,p=t.slideOffset,m=void 0===p?50:p;if(n(this,e),this.el=document.getElementById("webslides"),!this.el)throw new Error("Couldn't find the webslides container!");this.isMoving=!1,this.slides=null,this.currentSlideI_=-1,this.currentSlide_=null,this.maxSlide_=0,this.isVertical=this.el.classList.contains(u.VERTICAL),this.plugins={},this.options={autoslide:s,changeOnClick:a,loop:l,minWheelDelta:d,navigateOnScroll:f,scrollWait:y,slideOffset:m},this.initialised=!1,this.removeChildren_(),this.grabSlides_(),this.createPlugins_(),this.initSlides_(),this.onInit_()}return l(e,[{key:"removeChildren_",value:function(){for(var e=this.el.childNodes,t=e.length;t--;){var i=e[t];o.a.isCandidate(i)||this.el.removeChild(i)}}},{key:"createPlugins_",value:function(){var e=this;Object.keys(c).forEach(function(t){var i=c[t];e.plugins[t]=new i(e)})}},{key:"onInit_",value:function(){this.initialised=!0,a.a.fireEvent(this.el,"ws:init"),document.documentElement.classList.add(u.READY)}},{key:"grabSlides_",value:function(){this.slides=a.a.toArray(this.el.childNodes).map(function(e,t){return new o.a(e,t)}),this.maxSlide_=this.slides.length}},{key:"goToSlide",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(this.isValidIndexSlide_(e)&&!this.isMoving&&this.currentSlideI_!==e){this.isMoving=!0;var i=!1;null!==t?i=t:this.currentSlideI_>=0&&(i=e>this.currentSlideI_);var n=this.slides[e];null===this.currentSlide_||!this.isVertical||this.plugins.touch&&this.plugins.touch.isEnabled?this.transitionToSlide_(i,n,this.onSlideChange_):this.scrollTransitionToSlide_(i,n,this.onSlideChange_)}}},{key:"scrollTransitionToSlide_",value:function(e,t,n){var s=this;this.el.style.overflow="hidden",e?t.show():(t.moveBeforeFirst(),t.show(),i.i(r.a)(this.currentSlide_.el.offsetTop,0)),i.i(r.a)(t.el.offsetTop,500,function(){s.currentSlide_.hide(),e&&s.currentSlide_.moveAfterLast(),s.el.style.overflow="auto",setTimeout(function(){n.call(s,t)},150)})}},{key:"transitionToSlide_",value:function(e,t,n){var s=this;i.i(r.a)(0,0);var o="slideInRight";e||(t.moveBeforeFirst(),o="slideInLeft"),this.currentSlide_&&(e&&this.currentSlide_.moveAfterLast(),this.currentSlide_.hide()),t.show(),this.initialised&&this.plugins.touch&&this.plugins.touch.isEnabled?(a.a.once(t.el,a.a.getAnimationEvent(),function(){t.el.classList.remove(o),n.call(s,t)}),t.el.classList.add(o)):n.call(this,t)}},{key:"onSlideChange_",value:function(e){this.currentSlide_&&this.currentSlide_.disable(),this.currentSlide_=e,this.currentSlideI_=e.i,this.currentSlide_.enable(),this.isMoving=!1,a.a.fireEvent(this.el,"ws:slide-change",{slides:this.maxSlide_,currentSlide0:this.currentSlideI_,currentSlide:this.currentSlideI_+1})}},{key:"goNext",value:function(){var e=this.currentSlideI_+1;if(e>=this.maxSlide_){if(!this.options.loop)return;e=0}this.goToSlide(e,!0)}},{key:"goPrev",value:function(){var e=this.currentSlideI_-1;if(e<0){if(!this.options.loop)return;e=this.maxSlide_-1}this.goToSlide(e,!1)}},{key:"isValidIndexSlide_",value:function(e){return"number"==typeof e&&e>=0&&e=this.maxSlide_)&&(e=0),0!==e)for(var t=0;t0&&(this.interval_=setInterval(this.ws_.goNext.bind(this.ws_),e))}},{key:"stop",value:function(){this.interval_&&(clearInterval(this.interval_),this.interval_=null)}}]),e}();t.a=a},function(e,t,i){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var s=function(){function e(e,t){for(var i=0;iMath.abs(i);if(this.isGoingUp_=i<0,this.isGoingLeft_=n<0,o){if(s)return;e.preventDefault()}(Math.abs(i+t)>=this.ws_.options.minWheelDelta||Math.abs(n+t)>=this.ws_.options.minWheelDelta)&&(o&&this.isGoingLeft_||!o&&this.isGoingUp_?this.ws_.goPrev():this.ws_.goNext(),e.preventDefault())}}}]),e}();t.a=a},function(e,t,i){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var s=i(3),o=function(){function e(e,t){for(var i=0;i1&&(this.startTouches=e.getTouchCoordinates(t),this.endTouches=this.startTouches,this.isGesture=!0)}}},{key:"onMove_",value:function(t){if(!this.ws_.isDisabled()){var i=e.normalizeEventInfo(t);this.isGesture?this.endTouches=e.getTouchCoordinates(t):(this.endX_=i.x,this.endY_=i.y)}}},{key:"onStop_",value:function(){if(!this.ws_.isDisabled())if(this.isGesture){var e=Math.sqrt(Math.pow(this.startTouches[0].x-this.startTouches[1].x,2)+Math.pow(this.startTouches[0].y-this.startTouches[1].y,2)),t=Math.sqrt(Math.pow(this.endTouches[0].x-this.endTouches[1].x,2)+Math.pow(this.endTouches[0].y-this.endTouches[1].y,2));e>t&&this.ws_.toggleZoom(),this.isGesture=!1}else{var i=this.startX_-this.endX_,n=this.startY_-this.endY_;Math.abs(i)>Math.abs(n)&&(i<-this.ws_.options.slideOffset?this.ws_.goPrev():i>this.ws_.options.slideOffset&&this.ws_.goNext())}}}],[{key:"getTouchCoordinates",value:function(e){return[{x:e.touches[0].clientX,y:e.touches[0].clientY},{x:e.touches[1].clientX,y:e.touches[1].clientY}]}},{key:"normalizeEventInfo",value:function(e){var t={pageX:0,pageY:0};return void 0!==e.changedTouches?t=e.changedTouches[0]:void 0!==e.originalEvent&&void 0!==e.originalEvent.changedTouches&&(t=e.originalEvent.changedTouches[0]),{x:e.offsetX||e.layerX||t.pageX,y:e.offsetY||e.layerY||t.pageY}}}]),e}();t.a=r},function(e,t,i){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var s=i(0),o=i(1),a=function(){function e(e,t){for(var i=0;i