fullpage-pagination
Advanced tools
Comparing version 1.1.2 to 1.1.3
@@ -1,1 +0,1 @@ | ||
"use strict";function _classCallCheck(t,n){if(!(t instanceof n))throw new TypeError("Cannot call a class as a function")}function _defineProperties(t,n){for(var e=0;e<n.length;e++){var s=n[e];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(t,s.key,s)}}function _createClass(t,n,e){return n&&_defineProperties(t.prototype,n),e&&_defineProperties(t,e),t}function _defineProperty(t,n,e){return n in t?Object.defineProperty(t,n,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[n]=e,t}function ownKeys(n,t){var e=Object.keys(n);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(n);t&&(s=s.filter(function(t){return Object.getOwnPropertyDescriptor(n,t).enumerable})),e.push.apply(e,s)}return e}function _objectSpread2(n){for(var t=1;t<arguments.length;t++){var e=null!=arguments[t]?arguments[t]:{};t%2?ownKeys(e,!0).forEach(function(t){_defineProperty(n,t,e[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(e)):ownKeys(e).forEach(function(t){Object.defineProperty(n,t,Object.getOwnPropertyDescriptor(e,t))})}return n}function checkPropertiesSupport(){Element.prototype.closest||console.warn("This browser does not support `closest` method. You should use polyfill."),"undefined"!=typeof Promise&&-1!==Promise.toString().indexOf("[native code]")||console.warn("This browser does not support `Promise`. You should use polyfill.")}function createTouchEvents(t){function o(t,n){var e=document.createEvent("CustomEvent");return e.initCustomEvent(n,!0,!0,t.target),t.target.dispatchEvent(e),e=null,!1}var a=!0,c={x:0,y:0},r={x:0,y:0},n={touchstart:function(t){c={x:t.touches[0].pageX,y:t.touches[0].pageY}},touchmove:function(t){a=!1,r={x:t.touches[0].pageX,y:t.touches[0].pageY}},touchend:function(t){if(a)o(t,"fc");else{var n=r.x-c.x,e=Math.abs(n),s=r.y-c.y,i=Math.abs(s);20<Math.max(e,i)&&o(t,i<e?n<0?"swl":"swr":s<0?"swu":"swd")}a=!0},touchcancel:function(t){a=!1}};for(var e in n)t.addEventListener(e,n[e],!1)}Object.defineProperty(exports,"__esModule",{value:!0});var Animator=function(){function d(t){var n=t.direction,e=t.sections,s=t.from,i=t.to,o=t.transition,a=t.easing,c=t.onExit,r=t.onEnter,l=t.fadeIn,h=t.fadeInDuration,u=t.customTransition,p=t.toggleClassesFirst;_classCallCheck(this,d),this.direction=n,this.sections=e,this.from=s,this.to=i,this.current=e[s],this.next=e[i],this.container=this.sections[0].parentNode,this.translate=0,this.transition=o,this.easing=a,this.onExit=c,this.onEnter=r,this.fadeIn=l,this.fadeInDuration=h,this.customTransition=u,this.toggleClassesFirst=p}return _createClass(d,[{key:"animate",value:function(){this._onExit().then(this._changeSection.bind(this)).then(this._onEnter.bind(this)).then(this._onComplete.bind(this))}},{key:"getSectionTop",value:function(t){return t.getBoundingClientRect().top}},{key:"fadeToggle",value:function(){var t=this;this.current.style.transition="opacity ".concat(this.fadeInDuration,"ms"),this.current.style.opacity=0,setTimeout(function(){t.current.style.display="none",t.current.style.transition="",t.current.classList.remove(d.classNames.IS_ACTIVE)},this.fadeInDuration),this.next.classList.add(d.classNames.IS_ACTIVE),this.next.style.display="",this.next.style.transition="opacity ".concat(this.fadeInDuration,"ms"),setTimeout(function(){t.next.style.opacity=1},66)}},{key:"scrollToSection",value:function(){var t=this,n=this.getSectionTop(this.container),e=this.getSectionTop(this.next)-n;this.translate=e,this.container.style.transform="translate(0px, -".concat(this.translate,"px)"),this.container.style.transition="transform ".concat(this.transition,"ms ").concat(this.easing),setTimeout(function(){t.container.style.transition="",t.toggleActiveClasses()},this.transition)}},{key:"toggleActiveClasses",value:function(){this.current.classList.remove(d.classNames.IS_ACTIVE),this.next.classList.add(d.classNames.IS_ACTIVE)}},{key:"_onExit",value:function(){var n=this;return new Promise(function(t){n.onExit?n.onExit(n.current,t):t()})}},{key:"_onEnter",value:function(){var n=this;return new Promise(function(t){n.onEnter?n.onEnter(n.next,t):t()})}},{key:"_onComplete",value:function(){this.finishTime=(new Date).getTime(),this.onComplete&&this.onComplete.call(this)}},{key:"_changeSection",value:function(){this.fadeIn?this.fadeToggle():this.customTransition?this.toggleActiveClasses():this.scrollToSection()}}]),d}();function addTouchEvents(){createTouchEvents(document)}Animator.classNames={IS_ACTIVE:"is-active"},checkPropertiesSupport();var Fullpage=function(){function c(t,n){_classCallCheck(this,c),this.container=t,this.sections=[].slice.call(this.container.children),this.defaultParams={delay:1e3,transition:500,easing:"ease",navigation:!1,renderNavButton:!1,prevButton:!1,nextButton:!1,fadeIn:!1,fadeInDuration:500,touchevents:!1,customTransition:!1,loop:!1,toggleClassesFirst:!1},this.options=_objectSpread2({},this.defaultParams,{},n),this.allowPagination=!0,this.current=0}return _createClass(c,[{key:"init",value:function(){this._addElementsAttributes(),this._crateNavigation(),this.paginateBinded=this.paginate.bind(this),this._paginate(),this.getIdFromUrl()&&1<this.getIdFromUrl().length&&this._paginateOnLoad(),this.afterLoad&&this.afterLoad()}},{key:"getIdFromUrl",value:function(){var t,n=window.location.href;if(-1!==n.indexOf("#")&&(t=n.substring(n.lastIndexOf("#"))),t)return t.slice(1)}},{key:"paginateToNext",value:function(t){this.direction=t?1:-1,this.next=this.current+this.direction}},{key:"paginateOnNavButtonClick",value:function(t,n){t.preventDefault();var e=+n.getAttribute(c.constants.index);"number"==typeof e&&(this.next=e,this.direction=this.next>this.current?1:-1)}},{key:"paginateOnAnchorClick",value:function(t,n){var e,s=n.getAttribute(c.constants.anchor);this.sections.forEach(function(t){(t.hasAttribute(c.constants.anchorId)?t.getAttribute(c.constants.anchorId):null)===s&&(e=t)}),this.next=+e.getAttribute(c.constants.index),this.direction=this.next>this.current?1:-1}},{key:"paginateOnPrevNextClick",value:function(t,n,e){t.preventDefault(),this.paginateToNext(e)}},{key:"toggleDisableButtonsClasses",value:function(){this.next===this.sections.length-1?this.options.nextButton.classList.add(c.constants.IS_DISABLED):this.options.nextButton.classList.remove(c.constants.IS_DISABLED),0===this.next?this.options.prevButton.classList.add(c.constants.IS_DISABLED):this.options.prevButton.classList.remove(c.constants.IS_DISABLED)}},{key:"paginate",value:function(t){var e=this;if(this.allowPagination){if("wheel"===t.type&&this.paginateToNext(0<t.deltaY),"click"===t.type){var n=t.target.closest(".".concat(c.constants.navButton)),s=t.target.closest("[".concat(c.constants.anchor,"]")),i=t.target.closest(".".concat(c.constants.prev)),o=t.target.closest(".".concat(c.constants.next));if(n&&this.paginateOnNavButtonClick(t,n),s&&this.paginateOnAnchorClick(t,s),(i||o)&&this.paginateOnPrevNextClick(t,i,o),null===n&&null===s&&null===i&&null===o)return}if(this.options.touchevents&&("swu"===t.type&&this.paginateToNext(!0),"swd"===t.type&&this.paginateToNext(!1)),!t.type){var a=t;this.sections.forEach(function(t,n){t.hasAttribute(c.constants.anchorId,a)&&(e.next=n)})}if(this.options.loop){if(this.next>this.sections.length-1?(this.next=0,this.loopTo="first"):this.next<0?(this.next=this.sections.length-1,this.loopTo="last"):this.loopTo=!1,this.next===this.current)return}else if(this.next>=this.sections.length||this.next<0||this.next===this.current)return;this.options.loop||this.toggleDisableButtonsClasses(),this.next>=this.sections.length||this.next<0||this.next===this.current||(this.allowPagination=!1,this.navigation.forEach(function(t){t.classList.remove(c.constants.IS_ACTIVE)}),this.navigation[this.next].classList.add(c.constants.IS_ACTIVE),this.options.toggleClassesFirst&&(this.sections[this.current].classList.remove(c.constants.IS_ACTIVE),this.sections[this.next].classList.add(c.constants.IS_ACTIVE)),this.startTime=(new Date).getTime(),this.animator=new Animator({direction:this.direction,sections:this.sections,from:this.current,to:this.next,transition:this.options.transition,easing:this.options.easing,onExit:this.onExit,onEnter:this.onEnter,fadeIn:this.options.fadeIn,fadeInDuration:this.options.fadeInDuration,customTransition:this.options.customTransition,toggleClassesFirst:this.options.toggleClassesFirst}),this.animator.onComplete=function(){e.onComplete&&e.onComplete(),e.current=e.next,e.animator.finishTime-e.startTime<e.options.delay?setTimeout(function(){e.allowPagination=!0},e.options.delay):e.allowPagination=!0},this.animator.animate())}}},{key:"_addElementsAttributes",value:function(){this.options.fadeIn&&(this.sections.forEach(function(t){t.classList.add(c.constants.IS_ABSOLUTE),t.style.opacity=0}),this.sections[0].style.opacity=1),this.sections[0].classList.add(c.constants.IS_ACTIVE),this.sections.forEach(function(t,n){t.setAttribute(c.constants.index,n)}),this.options.prevButton&&this.options.prevButton.classList.add(c.constants.prev),this.options.nextButton&&this.options.nextButton.classList.add(c.constants.next),this.options.loop||0===this.current&&this.options.prevButton.classList.add(c.constants.IS_DISABLED)}},{key:"_paginate",value:function(){var n=this;(this.options.touchevents?["wheel","click","swu","swd"]:["wheel","click"]).forEach(function(t){document.addEventListener(t,n.paginateBinded)})}},{key:"_paginateOnLoad",value:function(){this.paginate(this.getIdFromUrl())}},{key:"_crateNavigation",value:function(){if(this.options.navigation){var t=this.options.navigation;t.innerHTML='<ul class="'.concat(c.constants.navList,'"></ul>');for(var n=0;n<this.sections.length;n++){var e=t.querySelector("ul"),s=document.createElement("li");s.className=c.constants.navItem,this.options.renderNavButton?s.innerHTML=0===n?'<button class="'.concat(c.constants.navButton," ").concat(c.constants.IS_ACTIVE,'" ').concat(c.constants.index,'="').concat(n,'">').concat(this.options.renderNavButton(n),"</button>"):'<button class="'.concat(c.constants.navButton,'" ').concat(c.constants.index,'="').concat(n,'">').concat(this.options.renderNavButton(n),"</button>"):s.innerHTML=0===n?'<button class="'.concat(c.constants.navButton," ").concat(c.constants.IS_ACTIVE,'" ').concat(c.constants.index,'="').concat(n,'">').concat(n+1,"</button>"):'<button class="'.concat(c.constants.navButton,'" ').concat(c.constants.index,'="').concat(n,'">').concat(n+1,"</button>"),e.appendChild(s)}this.navigation=[].slice.call(t.querySelectorAll(".".concat(c.constants.navButton)))}}}]),c}();Fullpage.constants={IS_ACTIVE:"is-active",IS_ABSOLUTE:"is-absolute",IS_DISABLED:"is-disabled",navList:"fullpage-nav",navItem:"fullpage-nav__item",navButton:"fullpage-nav__button",prev:"fullpage__prev",next:"fullpage__next",anchor:"data-fullpage-anchor",anchorId:"data-fullpage-id",index:"data-fullpage-index"},exports.Fullpage=Fullpage,exports.addTouchEvents=addTouchEvents; | ||
"use strict";function _classCallCheck(t,n){if(!(t instanceof n))throw new TypeError("Cannot call a class as a function")}function _defineProperties(t,n){for(var e=0;e<n.length;e++){var s=n[e];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(t,s.key,s)}}function _createClass(t,n,e){return n&&_defineProperties(t.prototype,n),e&&_defineProperties(t,e),t}function _defineProperty(t,n,e){return n in t?Object.defineProperty(t,n,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[n]=e,t}function ownKeys(n,t){var e=Object.keys(n);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(n);t&&(s=s.filter(function(t){return Object.getOwnPropertyDescriptor(n,t).enumerable})),e.push.apply(e,s)}return e}function _objectSpread2(n){for(var t=1;t<arguments.length;t++){var e=null!=arguments[t]?arguments[t]:{};t%2?ownKeys(e,!0).forEach(function(t){_defineProperty(n,t,e[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(e)):ownKeys(e).forEach(function(t){Object.defineProperty(n,t,Object.getOwnPropertyDescriptor(e,t))})}return n}function checkPropertiesSupport(){Element.prototype.closest||console.warn("This browser does not support `closest` method. You should use polyfill."),"undefined"!=typeof Promise&&-1!==Promise.toString().indexOf("[native code]")||console.warn("This browser does not support `Promise`. You should use polyfill.")}function createTouchEvents(t){function o(t,n){var e=document.createEvent("CustomEvent");return e.initCustomEvent(n,!0,!0,t.target),t.target.dispatchEvent(e),e=null,!1}var a=!0,c={x:0,y:0},r={x:0,y:0},n={touchstart:function(t){c={x:t.touches[0].pageX,y:t.touches[0].pageY}},touchmove:function(t){a=!1,r={x:t.touches[0].pageX,y:t.touches[0].pageY}},touchend:function(t){if(a)o(t,"fc");else{var n=r.x-c.x,e=Math.abs(n),s=r.y-c.y,i=Math.abs(s);20<Math.max(e,i)&&o(t,i<e?n<0?"swl":"swr":s<0?"swu":"swd")}a=!0},touchcancel:function(t){a=!1}};for(var e in n)t.addEventListener(e,n[e],!1)}function getIdFromUrl(){var t,n=window.location.href;if(-1!==n.indexOf("#")&&(t=n.substring(n.lastIndexOf("#"))),t)return t.slice(1)}Object.defineProperty(exports,"__esModule",{value:!0});var constants={IS_ACTIVE:"is-active",IS_ABSOLUTE:"is-absolute",IS_DISABLED:"is-disabled",navList:"fullpage-nav",navItem:"fullpage-nav__item",navButton:"fullpage-nav__button",prev:"fullpage__prev",next:"fullpage__next",anchor:"data-fullpage-anchor",anchorId:"data-fullpage-id",index:"data-fullpage-index"},Animator=function(){function d(t){var n=t.direction,e=t.sections,s=t.from,i=t.to,o=t.transition,a=t.easing,c=t.onExit,r=t.onEnter,l=t.fadeIn,u=t.fadeInDuration,h=t.customTransition,p=t.toggleClassesFirst;_classCallCheck(this,d),this.direction=n,this.sections=e,this.from=s,this.to=i,this.current=e[s],this.next=e[i],this.container=this.sections[0].parentNode,this.translate=0,this.transition=o,this.easing=a,this.onExit=c,this.onEnter=r,this.fadeIn=l,this.fadeInDuration=u,this.customTransition=h,this.toggleClassesFirst=p}return _createClass(d,[{key:"animate",value:function(){this._onExit().then(this._changeSection.bind(this)).then(this._onEnter.bind(this)).then(this._onComplete.bind(this))}},{key:"destroy",value:function(){this._removeStyles()}},{key:"getSectionTop",value:function(t){return t.getBoundingClientRect().top}},{key:"fadeToggle",value:function(){var t=this;this.current.style.transition="opacity ".concat(this.fadeInDuration,"ms"),this.current.style.opacity=0,setTimeout(function(){t.current.style.display="none",t.current.style.transition="",t.current.classList.remove(constants.IS_ACTIVE)},this.fadeInDuration),this.next.classList.add(constants.IS_ACTIVE),this.next.style.display="",this.next.style.transition="opacity ".concat(this.fadeInDuration,"ms"),setTimeout(function(){t.next.style.opacity=1},66)}},{key:"scrollToSection",value:function(){var t=this,n=this.getSectionTop(this.container),e=this.getSectionTop(this.next)-n;this.translate=e,this.container.style.transform="translate(0px, -".concat(this.translate,"px)"),this.container.style.transition="transform ".concat(this.transition,"ms ").concat(this.easing),setTimeout(function(){t.container.style.transition="",t.toggleActiveClasses()},this.transition)}},{key:"toggleActiveClasses",value:function(){this.current.classList.remove(constants.IS_ACTIVE),this.next.classList.add(constants.IS_ACTIVE)}},{key:"_onExit",value:function(){var n=this;return new Promise(function(t){n.onExit?n.onExit(n.current,t):t()})}},{key:"_onEnter",value:function(){var n=this;return new Promise(function(t){n.onEnter?n.onEnter(n.next,t):t()})}},{key:"_onComplete",value:function(){this.finishTime=(new Date).getTime(),this.onComplete&&this.onComplete.call(this)}},{key:"_changeSection",value:function(){this.fadeIn?this.fadeToggle():this.customTransition?this.toggleActiveClasses():this.scrollToSection()}},{key:"_removeStyles",value:function(){this.sections.forEach(function(t){t.style.opacity="",t.style.display="",t.style.transition=""})}}]),d}(),defaultParameters={delay:1e3,transition:500,easing:"ease",navigation:!1,renderNavButton:!1,prevButton:!1,nextButton:!1,fadeIn:!1,fadeInDuration:500,touchevents:!1,customTransition:!1,loop:!1,toggleClassesFirst:!1};function addTouchEvents(){createTouchEvents(document)}checkPropertiesSupport();var Fullpage=function(){function e(t,n){_classCallCheck(this,e),this.container=t,this.sections=[].slice.call(this.container.children),this.options=_objectSpread2({},defaultParameters,{},n),this.allowPagination=!0,this.current=0}return _createClass(e,[{key:"init",value:function(){this._addElementsAttributes(),this._crateNavigation(),this.paginateBinded=this.paginate.bind(this),this._paginate(),getIdFromUrl()&&1<getIdFromUrl().length&&this._paginateOnLoad(),this.afterLoad&&this.afterLoad()}},{key:"destroy",value:function(){this._removeListeners(),this._removeElementsAttributes(),this._removeNavigation(),this.animator&&this.animator.destroy()}},{key:"paginateToNext",value:function(t){this.direction=t?1:-1,this.next=this.current+this.direction}},{key:"paginateOnNavButtonClick",value:function(t,n){t.preventDefault();var e=+n.getAttribute(constants.index);"number"==typeof e&&(this.next=e,this.direction=this.next>this.current?1:-1)}},{key:"paginateOnAnchorClick",value:function(t,n){var e,s=n.getAttribute(constants.anchor);this.sections.forEach(function(t){(t.hasAttribute(constants.anchorId)?t.getAttribute(constants.anchorId):null)===s&&(e=t)}),this.next=+e.getAttribute(constants.index),this.direction=this.next>this.current?1:-1}},{key:"paginateOnPrevNextClick",value:function(t,n,e){t.preventDefault(),this.paginateToNext(e)}},{key:"toggleDisableButtonsClasses",value:function(){this.next===this.sections.length-1?this.options.nextButton.classList.add(constants.IS_DISABLED):this.options.nextButton.classList.remove(constants.IS_DISABLED),0===this.next?this.options.prevButton.classList.add(constants.IS_DISABLED):this.options.prevButton.classList.remove(constants.IS_DISABLED)}},{key:"paginate",value:function(t){var e=this;if(this.allowPagination){if("wheel"===t.type&&this.paginateToNext(0<t.deltaY),"click"===t.type){var n=t.target.closest(".".concat(constants.navButton)),s=t.target.closest("[".concat(constants.anchor,"]")),i=t.target.closest(".".concat(constants.prev)),o=t.target.closest(".".concat(constants.next));if(n&&this.paginateOnNavButtonClick(t,n),s&&this.paginateOnAnchorClick(t,s),(i||o)&&this.paginateOnPrevNextClick(t,i,o),null===n&&null===s&&null===i&&null===o)return}if(this.options.touchevents&&("swu"===t.type&&this.paginateToNext(!0),"swd"===t.type&&this.paginateToNext(!1)),!t.type){var a=t;this.sections.forEach(function(t,n){t.hasAttribute(constants.anchorId,a)&&(e.next=n)})}if(this.options.loop){if(this.next>this.sections.length-1?(this.next=0,this.loopTo="first"):this.next<0?(this.next=this.sections.length-1,this.loopTo="last"):this.loopTo=!1,this.next===this.current)return}else if(this.next>=this.sections.length||this.next<0||this.next===this.current)return;this.options.loop||this.toggleDisableButtonsClasses(),this.next>=this.sections.length||this.next<0||this.next===this.current||(this.allowPagination=!1,this.navigation.forEach(function(t){t.classList.remove(constants.IS_ACTIVE)}),this.navigation[this.next].classList.add(constants.IS_ACTIVE),this.options.toggleClassesFirst&&(this.sections[this.current].classList.remove(constants.IS_ACTIVE),this.sections[this.next].classList.add(constants.IS_ACTIVE)),this.startTime=(new Date).getTime(),this.animator=new Animator({direction:this.direction,sections:this.sections,from:this.current,to:this.next,transition:this.options.transition,easing:this.options.easing,onExit:this.onExit,onEnter:this.onEnter,fadeIn:this.options.fadeIn,fadeInDuration:this.options.fadeInDuration,customTransition:this.options.customTransition,toggleClassesFirst:this.options.toggleClassesFirst}),this.animator.onComplete=function(){e.onComplete&&e.onComplete(),e.current=e.next,e.animator.finishTime-e.startTime<e.options.delay?setTimeout(function(){e.allowPagination=!0},e.options.delay):e.allowPagination=!0},this.animator.animate())}}},{key:"_addElementsAttributes",value:function(){this.options.fadeIn&&(this.sections.forEach(function(t){t.classList.add(constants.IS_ABSOLUTE),t.style.opacity=0}),this.sections[0].style.opacity=1),this.sections[0].classList.add(constants.IS_ACTIVE),this.sections.forEach(function(t,n){t.setAttribute(constants.index,n)}),this.options.prevButton&&this.options.prevButton.classList.add(constants.prev),this.options.nextButton&&this.options.nextButton.classList.add(constants.next),this.options.loop||0===this.current&&this.options.prevButton.classList.add(constants.IS_DISABLED)}},{key:"_paginate",value:function(){var n=this;(this.options.touchevents?["wheel","click","swu","swd"]:["wheel","click"]).forEach(function(t){document.addEventListener(t,n.paginateBinded)})}},{key:"_paginateOnLoad",value:function(){this.paginate(getIdFromUrl())}},{key:"_crateNavigation",value:function(){if(this.options.navigation){var t=this.options.navigation;t.innerHTML='<ul class="'.concat(constants.navList,'"></ul>');for(var n=0;n<this.sections.length;n++){var e=t.querySelector("ul"),s=document.createElement("li");s.className=constants.navItem,this.options.renderNavButton?s.innerHTML=0===n?'<button class="'.concat(constants.navButton," ").concat(constants.IS_ACTIVE,'" ').concat(constants.index,'="').concat(n,'">').concat(this.options.renderNavButton(n),"</button>"):'<button class="'.concat(constants.navButton,'" ').concat(constants.index,'="').concat(n,'">').concat(this.options.renderNavButton(n),"</button>"):s.innerHTML=0===n?'<button class="'.concat(constants.navButton," ").concat(constants.IS_ACTIVE,'" ').concat(constants.index,'="').concat(n,'">').concat(n+1,"</button>"):'<button class="'.concat(constants.navButton,'" ').concat(constants.index,'="').concat(n,'">').concat(n+1,"</button>"),e.appendChild(s)}this.navigation=[].slice.call(t.querySelectorAll(".".concat(constants.navButton)))}}},{key:"_removeListeners",value:function(){var n=this;(this.options.touchevents?["wheel","click","swu","swd"]:["wheel","click"]).forEach(function(t){document.removeEventListener(t,n.paginateBinded)})}},{key:"_removeElementsAttributes",value:function(){this.sections.forEach(function(t){t.classList.remove(constants.IS_ACTIVE),t.classList.remove(constants.IS_ABSOLUTE),t.style.opacity="",t.removeAttribute(constants.index)})}},{key:"_removeNavigation",value:function(){this.options.navigation&&(this.options.navigation.innerHTML="")}}]),e}();exports.Fullpage=Fullpage,exports.addTouchEvents=addTouchEvents; |
{ | ||
"name": "fullpage-pagination", | ||
"description": "JS plugin for making fullpage pagination", | ||
"version": "1.1.2", | ||
"version": "1.1.3", | ||
"scripts": { | ||
@@ -6,0 +6,0 @@ "start": "rollup -c -w", |
@@ -0,1 +1,3 @@ | ||
import constants from './components/constants'; | ||
export default class Animator { | ||
@@ -41,2 +43,6 @@ constructor({ | ||
destroy() { | ||
this._removeStyles(); | ||
} | ||
getSectionTop(section) { | ||
@@ -54,6 +60,6 @@ const rect = section.getBoundingClientRect(); | ||
this.current.style.transition = ''; | ||
this.current.classList.remove(Animator.classNames.IS_ACTIVE); | ||
this.current.classList.remove(constants.IS_ACTIVE); | ||
}, this.fadeInDuration); | ||
this.next.classList.add(Animator.classNames.IS_ACTIVE); | ||
this.next.classList.add(constants.IS_ACTIVE); | ||
this.next.style.display = ''; | ||
@@ -84,4 +90,4 @@ this.next.style.transition = `opacity ${this.fadeInDuration}ms`; | ||
toggleActiveClasses() { | ||
this.current.classList.remove(Animator.classNames.IS_ACTIVE); | ||
this.next.classList.add(Animator.classNames.IS_ACTIVE); | ||
this.current.classList.remove(constants.IS_ACTIVE); | ||
this.next.classList.add(constants.IS_ACTIVE); | ||
}; | ||
@@ -109,3 +115,4 @@ | ||
_onComplete() {this.finishTime = new Date().getTime(); | ||
_onComplete() { | ||
this.finishTime = new Date().getTime(); | ||
if (this.onComplete) { | ||
@@ -125,6 +132,10 @@ this.onComplete.call(this); | ||
}; | ||
}; | ||
Animator.classNames = { | ||
IS_ACTIVE: 'is-active' | ||
_removeStyles() { | ||
this.sections.forEach((section) => { | ||
section.style.opacity = ''; | ||
section.style.display = ''; | ||
section.style.transition = ''; | ||
}) | ||
} | ||
}; |
@@ -20,2 +20,13 @@ export function checkPropertiesSupport() { | ||
for (var i in touch) { d.addEventListener(i, touch[i], false); } | ||
}; | ||
export function getIdFromUrl() { | ||
const url = window.location.href; | ||
let id; | ||
if (url.indexOf('#') !== -1) { | ||
id = url.substring(url.lastIndexOf('#')); | ||
}; | ||
if (id) { | ||
return id.slice(1); | ||
}; | ||
}; |
178
src/main.js
// import './polyfill'; | ||
import { checkPropertiesSupport, createTouchEvents } from './helpers'; | ||
import { checkPropertiesSupport, createTouchEvents, getIdFromUrl } from './helpers'; | ||
import Animator from './Animator'; | ||
import constants from './components/constants'; | ||
import defaultParameters from './components/defaultPataneters' | ||
@@ -15,18 +17,3 @@ checkPropertiesSupport(); | ||
this.sections = [].slice.call(this.container.children); | ||
this.defaultParams = { | ||
delay: 1000, | ||
transition: 500, | ||
easing: 'ease', | ||
navigation: false, | ||
renderNavButton: false, | ||
prevButton: false, | ||
nextButton: false, | ||
fadeIn: false, | ||
fadeInDuration: 500, | ||
touchevents: false, | ||
customTransition: false, | ||
loop: false, | ||
toggleClassesFirst: false | ||
}; | ||
this.options = {...this.defaultParams, ...options}; | ||
this.options = { ...defaultParameters, ...options }; | ||
this.allowPagination = true; | ||
@@ -44,3 +31,3 @@ this.current = 0; | ||
if (this.getIdFromUrl() && this.getIdFromUrl().length > 1) { | ||
if (getIdFromUrl() && getIdFromUrl().length > 1) { | ||
this._paginateOnLoad(); | ||
@@ -54,12 +41,8 @@ }; | ||
getIdFromUrl() { | ||
const url = window.location.href; | ||
let id; | ||
if (url.indexOf('#') !== -1) { | ||
id = url.substring(url.lastIndexOf('#')); | ||
}; | ||
if (id) { | ||
return id.slice(1); | ||
}; | ||
}; | ||
destroy() { | ||
this._removeListeners(); | ||
this._removeElementsAttributes(); | ||
this._removeNavigation(); | ||
if(this.animator) this.animator.destroy(); | ||
} | ||
@@ -72,22 +55,22 @@ paginateToNext(condition) { | ||
paginateOnNavButtonClick(e, btn) { | ||
e.preventDefault(); | ||
const index = +btn.getAttribute(Fullpage.constants.index); | ||
e.preventDefault(); | ||
const index = +btn.getAttribute(constants.index); | ||
if (typeof index !== 'number') return; | ||
this.next = index; | ||
if (typeof index !== 'number') return; | ||
this.next = index; | ||
this.direction = this.next > this.current ? 1 : -1; | ||
this.direction = this.next > this.current ? 1 : -1; | ||
}; | ||
paginateOnAnchorClick(e, btn) { | ||
const id = btn.getAttribute(Fullpage.constants.anchor); | ||
let targetSection; | ||
const id = btn.getAttribute(constants.anchor); | ||
let targetSection; | ||
this.sections.forEach(section => { | ||
const currentId = section.hasAttribute(Fullpage.constants.anchorId) ? section.getAttribute(Fullpage.constants.anchorId) : null; | ||
if (currentId === id) targetSection = section; | ||
}); | ||
this.sections.forEach(section => { | ||
const currentId = section.hasAttribute(constants.anchorId) ? section.getAttribute(constants.anchorId) : null; | ||
if (currentId === id) targetSection = section; | ||
}); | ||
this.next = +targetSection.getAttribute(Fullpage.constants.index);; | ||
this.direction = this.next > this.current ? 1 : -1; | ||
this.next = +targetSection.getAttribute(constants.index);; | ||
this.direction = this.next > this.current ? 1 : -1; | ||
}; | ||
@@ -102,10 +85,10 @@ | ||
if (this.next === this.sections.length - 1) { | ||
this.options.nextButton.classList.add(Fullpage.constants.IS_DISABLED); | ||
this.options.nextButton.classList.add(constants.IS_DISABLED); | ||
} else { | ||
this.options.nextButton.classList.remove(Fullpage.constants.IS_DISABLED); | ||
this.options.nextButton.classList.remove(constants.IS_DISABLED); | ||
}; | ||
if (this.next === 0) { | ||
this.options.prevButton.classList.add(Fullpage.constants.IS_DISABLED); | ||
this.options.prevButton.classList.add(constants.IS_DISABLED); | ||
} else { | ||
this.options.prevButton.classList.remove(Fullpage.constants.IS_DISABLED); | ||
this.options.prevButton.classList.remove(constants.IS_DISABLED); | ||
}; | ||
@@ -122,6 +105,6 @@ }; | ||
if (e.type === 'click') { | ||
const navBtn = e.target.closest(`.${Fullpage.constants.navButton}`); | ||
const anchorBtn = e.target.closest(`[${Fullpage.constants.anchor}]`); | ||
const prevBtn = e.target.closest(`.${Fullpage.constants.prev}`); | ||
const nextBtn = e.target.closest(`.${Fullpage.constants.next}`); | ||
const navBtn = e.target.closest(`.${constants.navButton}`); | ||
const anchorBtn = e.target.closest(`[${constants.anchor}]`); | ||
const prevBtn = e.target.closest(`.${constants.prev}`); | ||
const nextBtn = e.target.closest(`.${constants.next}`); | ||
@@ -139,5 +122,5 @@ if (navBtn) { | ||
if (navBtn === null | ||
&& anchorBtn === null | ||
&& prevBtn === null | ||
&& nextBtn === null) return; | ||
&& anchorBtn === null | ||
&& prevBtn === null | ||
&& nextBtn === null) return; | ||
}; | ||
@@ -159,3 +142,3 @@ | ||
this.sections.forEach((section, i) => { | ||
if (section.hasAttribute(Fullpage.constants.anchorId, id)) { | ||
if (section.hasAttribute(constants.anchorId, id)) { | ||
this.next = i; | ||
@@ -182,5 +165,5 @@ }; | ||
if(!this.options.loop) { | ||
if (!this.options.loop) { | ||
this.toggleDisableButtonsClasses(); | ||
}; | ||
}; | ||
@@ -192,9 +175,9 @@ if (this.next >= this.sections.length || this.next < 0 || this.next === this.current) return; | ||
this.navigation.forEach(btn => { | ||
btn.classList.remove(Fullpage.constants.IS_ACTIVE); | ||
btn.classList.remove(constants.IS_ACTIVE); | ||
}); | ||
this.navigation[this.next].classList.add(Fullpage.constants.IS_ACTIVE); | ||
this.navigation[this.next].classList.add(constants.IS_ACTIVE); | ||
if (this.options.toggleClassesFirst) { | ||
this.sections[this.current].classList.remove(Fullpage.constants.IS_ACTIVE); | ||
this.sections[this.next].classList.add(Fullpage.constants.IS_ACTIVE); | ||
this.sections[this.current].classList.remove(constants.IS_ACTIVE); | ||
this.sections[this.next].classList.add(constants.IS_ACTIVE); | ||
}; | ||
@@ -234,6 +217,6 @@ | ||
}; | ||
}; | ||
this.animator.animate(); | ||
}; | ||
}; | ||
@@ -244,3 +227,3 @@ _addElementsAttributes() { | ||
this.sections.forEach(section => { | ||
section.classList.add(Fullpage.constants.IS_ABSOLUTE); | ||
section.classList.add(constants.IS_ABSOLUTE); | ||
section.style.opacity = 0; | ||
@@ -250,9 +233,9 @@ }); | ||
}; | ||
// add first section active class | ||
this.sections[0].classList.add(Fullpage.constants.IS_ACTIVE); | ||
this.sections[0].classList.add(constants.IS_ACTIVE); | ||
// add section indexes | ||
this.sections.forEach((section, i) => { | ||
section.setAttribute(Fullpage.constants.index, i); | ||
section.setAttribute(constants.index, i); | ||
}); | ||
@@ -262,6 +245,6 @@ | ||
if (this.options.prevButton) { | ||
this.options.prevButton.classList.add(Fullpage.constants.prev); | ||
this.options.prevButton.classList.add(constants.prev); | ||
}; | ||
if (this.options.nextButton) { | ||
this.options.nextButton.classList.add(Fullpage.constants.next); | ||
this.options.nextButton.classList.add(constants.next); | ||
}; | ||
@@ -272,5 +255,5 @@ | ||
if (this.current === 0) { | ||
this.options.prevButton.classList.add(Fullpage.constants.IS_DISABLED); | ||
this.options.prevButton.classList.add(constants.IS_DISABLED); | ||
}; | ||
}; | ||
}; | ||
}; | ||
@@ -287,10 +270,10 @@ | ||
_paginateOnLoad() { | ||
this.paginate(this.getIdFromUrl()); | ||
this.paginate(getIdFromUrl()); | ||
}; | ||
_crateNavigation() { | ||
if(!this.options.navigation) return; | ||
if (!this.options.navigation) return; | ||
const nav = this.options.navigation; | ||
nav.innerHTML = `<ul class="${Fullpage.constants.navList}"></ul>`; | ||
nav.innerHTML = `<ul class="${constants.navList}"></ul>`; | ||
@@ -300,36 +283,43 @@ for (let i = 0; i < this.sections.length; i++) { | ||
const item = document.createElement('li'); | ||
item.className = Fullpage.constants.navItem; | ||
item.className = constants.navItem; | ||
if (this.options.renderNavButton) { | ||
if (i === 0) { | ||
item.innerHTML = `<button class="${Fullpage.constants.navButton} ${Fullpage.constants.IS_ACTIVE}" ${Fullpage.constants.index}="${i}">${this.options.renderNavButton(i)}</button>`; | ||
item.innerHTML = `<button class="${constants.navButton} ${constants.IS_ACTIVE}" ${constants.index}="${i}">${this.options.renderNavButton(i)}</button>`; | ||
} else { | ||
item.innerHTML = `<button class="${Fullpage.constants.navButton}" ${Fullpage.constants.index}="${i}">${this.options.renderNavButton(i)}</button>`; | ||
item.innerHTML = `<button class="${constants.navButton}" ${constants.index}="${i}">${this.options.renderNavButton(i)}</button>`; | ||
}; | ||
} else { | ||
if (i === 0) { | ||
item.innerHTML = `<button class="${Fullpage.constants.navButton} ${Fullpage.constants.IS_ACTIVE}" ${Fullpage.constants.index}="${i}">${i + 1}</button>`; | ||
item.innerHTML = `<button class="${constants.navButton} ${constants.IS_ACTIVE}" ${constants.index}="${i}">${i + 1}</button>`; | ||
} else { | ||
item.innerHTML = `<button class="${Fullpage.constants.navButton}" ${Fullpage.constants.index}="${i}">${i + 1}</button>`; | ||
item.innerHTML = `<button class="${constants.navButton}" ${constants.index}="${i}">${i + 1}</button>`; | ||
}; | ||
}; | ||
}; | ||
list.appendChild(item); | ||
}; | ||
this.navigation = [].slice.call(nav.querySelectorAll(`.${Fullpage.constants.navButton}`)); | ||
}; | ||
}; | ||
this.navigation = [].slice.call(nav.querySelectorAll(`.${constants.navButton}`)); | ||
}; | ||
Fullpage.constants = { | ||
IS_ACTIVE: 'is-active', | ||
IS_ABSOLUTE: 'is-absolute', | ||
IS_DISABLED: 'is-disabled', | ||
navList: 'fullpage-nav', | ||
navItem: 'fullpage-nav__item', | ||
navButton: 'fullpage-nav__button', | ||
prev: 'fullpage__prev', | ||
next: 'fullpage__next', | ||
anchor: 'data-fullpage-anchor', | ||
anchorId: 'data-fullpage-id', | ||
index: 'data-fullpage-index' | ||
_removeListeners() { | ||
const events = this.options.touchevents ? ['wheel', 'click', 'swu', 'swd'] : ['wheel', 'click']; | ||
events.forEach(event => { | ||
document.removeEventListener(event, this.paginateBinded); | ||
}); | ||
} | ||
_removeElementsAttributes() { | ||
this.sections.forEach(section => { | ||
section.classList.remove(constants.IS_ACTIVE); | ||
section.classList.remove(constants.IS_ABSOLUTE); | ||
section.style.opacity = ''; | ||
section.removeAttribute(constants.index); | ||
}) | ||
} | ||
_removeNavigation() { | ||
if(!this.options.navigation) return; | ||
this.options.navigation.innerHTML = ''; | ||
} | ||
}; |
202
test.js
@@ -140,3 +140,29 @@ 'use strict'; | ||
} | ||
function getIdFromUrl() { | ||
var url = window.location.href; | ||
var id; | ||
if (url.indexOf('#') !== -1) { | ||
id = url.substring(url.lastIndexOf('#')); | ||
} | ||
if (id) { | ||
return id.slice(1); | ||
} | ||
} | ||
var constants = { | ||
IS_ACTIVE: 'is-active', | ||
IS_ABSOLUTE: 'is-absolute', | ||
IS_DISABLED: 'is-disabled', | ||
navList: 'fullpage-nav', | ||
navItem: 'fullpage-nav__item', | ||
navButton: 'fullpage-nav__button', | ||
prev: 'fullpage__prev', | ||
next: 'fullpage__next', | ||
anchor: 'data-fullpage-anchor', | ||
anchorId: 'data-fullpage-id', | ||
index: 'data-fullpage-index' | ||
}; | ||
var Animator = | ||
@@ -185,2 +211,7 @@ /*#__PURE__*/ | ||
}, { | ||
key: "destroy", | ||
value: function destroy() { | ||
this._removeStyles(); | ||
} | ||
}, { | ||
key: "getSectionTop", | ||
@@ -202,5 +233,5 @@ value: function getSectionTop(section) { | ||
_this.current.classList.remove(Animator.classNames.IS_ACTIVE); | ||
_this.current.classList.remove(constants.IS_ACTIVE); | ||
}, this.fadeInDuration); | ||
this.next.classList.add(Animator.classNames.IS_ACTIVE); | ||
this.next.classList.add(constants.IS_ACTIVE); | ||
this.next.style.display = ''; | ||
@@ -232,4 +263,4 @@ this.next.style.transition = "opacity ".concat(this.fadeInDuration, "ms"); | ||
value: function toggleActiveClasses() { | ||
this.current.classList.remove(Animator.classNames.IS_ACTIVE); | ||
this.next.classList.add(Animator.classNames.IS_ACTIVE); | ||
this.current.classList.remove(constants.IS_ACTIVE); | ||
this.next.classList.add(constants.IS_ACTIVE); | ||
} | ||
@@ -282,2 +313,11 @@ }, { | ||
} | ||
}, { | ||
key: "_removeStyles", | ||
value: function _removeStyles() { | ||
this.sections.forEach(function (section) { | ||
section.style.opacity = ''; | ||
section.style.display = ''; | ||
section.style.transition = ''; | ||
}); | ||
} | ||
}]); | ||
@@ -287,4 +327,17 @@ | ||
}(); | ||
Animator.classNames = { | ||
IS_ACTIVE: 'is-active' | ||
var defaultParameters = { | ||
delay: 1000, | ||
transition: 500, | ||
easing: 'ease', | ||
navigation: false, | ||
renderNavButton: false, | ||
prevButton: false, | ||
nextButton: false, | ||
fadeIn: false, | ||
fadeInDuration: 500, | ||
touchevents: false, | ||
customTransition: false, | ||
loop: false, | ||
toggleClassesFirst: false | ||
}; | ||
@@ -304,18 +357,3 @@ | ||
this.sections = [].slice.call(this.container.children); | ||
this.defaultParams = { | ||
delay: 1000, | ||
transition: 500, | ||
easing: 'ease', | ||
navigation: false, | ||
renderNavButton: false, | ||
prevButton: false, | ||
nextButton: false, | ||
fadeIn: false, | ||
fadeInDuration: 500, | ||
touchevents: false, | ||
customTransition: false, | ||
loop: false, | ||
toggleClassesFirst: false | ||
}; | ||
this.options = _objectSpread2({}, this.defaultParams, {}, options); | ||
this.options = _objectSpread2({}, defaultParameters, {}, options); | ||
this.allowPagination = true; | ||
@@ -336,3 +374,3 @@ this.current = 0; | ||
if (this.getIdFromUrl() && this.getIdFromUrl().length > 1) { | ||
if (getIdFromUrl() && getIdFromUrl().length > 1) { | ||
this._paginateOnLoad(); | ||
@@ -346,14 +384,11 @@ } | ||
}, { | ||
key: "getIdFromUrl", | ||
value: function getIdFromUrl() { | ||
var url = window.location.href; | ||
var id; | ||
key: "destroy", | ||
value: function destroy() { | ||
this._removeListeners(); | ||
if (url.indexOf('#') !== -1) { | ||
id = url.substring(url.lastIndexOf('#')); | ||
} | ||
this._removeElementsAttributes(); | ||
if (id) { | ||
return id.slice(1); | ||
} | ||
this._removeNavigation(); | ||
if (this.animator) this.animator.destroy(); | ||
} | ||
@@ -370,3 +405,3 @@ }, { | ||
e.preventDefault(); | ||
var index = +btn.getAttribute(Fullpage.constants.index); | ||
var index = +btn.getAttribute(constants.index); | ||
if (typeof index !== 'number') return; | ||
@@ -379,9 +414,9 @@ this.next = index; | ||
value: function paginateOnAnchorClick(e, btn) { | ||
var id = btn.getAttribute(Fullpage.constants.anchor); | ||
var id = btn.getAttribute(constants.anchor); | ||
var targetSection; | ||
this.sections.forEach(function (section) { | ||
var currentId = section.hasAttribute(Fullpage.constants.anchorId) ? section.getAttribute(Fullpage.constants.anchorId) : null; | ||
var currentId = section.hasAttribute(constants.anchorId) ? section.getAttribute(constants.anchorId) : null; | ||
if (currentId === id) targetSection = section; | ||
}); | ||
this.next = +targetSection.getAttribute(Fullpage.constants.index); | ||
this.next = +targetSection.getAttribute(constants.index); | ||
this.direction = this.next > this.current ? 1 : -1; | ||
@@ -399,11 +434,11 @@ } | ||
if (this.next === this.sections.length - 1) { | ||
this.options.nextButton.classList.add(Fullpage.constants.IS_DISABLED); | ||
this.options.nextButton.classList.add(constants.IS_DISABLED); | ||
} else { | ||
this.options.nextButton.classList.remove(Fullpage.constants.IS_DISABLED); | ||
this.options.nextButton.classList.remove(constants.IS_DISABLED); | ||
} | ||
if (this.next === 0) { | ||
this.options.prevButton.classList.add(Fullpage.constants.IS_DISABLED); | ||
this.options.prevButton.classList.add(constants.IS_DISABLED); | ||
} else { | ||
this.options.prevButton.classList.remove(Fullpage.constants.IS_DISABLED); | ||
this.options.prevButton.classList.remove(constants.IS_DISABLED); | ||
} | ||
@@ -423,6 +458,6 @@ } | ||
if (e.type === 'click') { | ||
var navBtn = e.target.closest(".".concat(Fullpage.constants.navButton)); | ||
var anchorBtn = e.target.closest("[".concat(Fullpage.constants.anchor, "]")); | ||
var prevBtn = e.target.closest(".".concat(Fullpage.constants.prev)); | ||
var nextBtn = e.target.closest(".".concat(Fullpage.constants.next)); | ||
var navBtn = e.target.closest(".".concat(constants.navButton)); | ||
var anchorBtn = e.target.closest("[".concat(constants.anchor, "]")); | ||
var prevBtn = e.target.closest(".".concat(constants.prev)); | ||
var nextBtn = e.target.closest(".".concat(constants.next)); | ||
@@ -456,3 +491,3 @@ if (navBtn) { | ||
this.sections.forEach(function (section, i) { | ||
if (section.hasAttribute(Fullpage.constants.anchorId, id)) { | ||
if (section.hasAttribute(constants.anchorId, id)) { | ||
_this.next = i; | ||
@@ -484,9 +519,9 @@ } | ||
this.navigation.forEach(function (btn) { | ||
btn.classList.remove(Fullpage.constants.IS_ACTIVE); | ||
btn.classList.remove(constants.IS_ACTIVE); | ||
}); | ||
this.navigation[this.next].classList.add(Fullpage.constants.IS_ACTIVE); | ||
this.navigation[this.next].classList.add(constants.IS_ACTIVE); | ||
if (this.options.toggleClassesFirst) { | ||
this.sections[this.current].classList.remove(Fullpage.constants.IS_ACTIVE); | ||
this.sections[this.next].classList.add(Fullpage.constants.IS_ACTIVE); | ||
this.sections[this.current].classList.remove(constants.IS_ACTIVE); | ||
this.sections[this.next].classList.add(constants.IS_ACTIVE); | ||
} | ||
@@ -534,3 +569,3 @@ this.startTime = new Date().getTime(); // animation goes here | ||
this.sections.forEach(function (section) { | ||
section.classList.add(Fullpage.constants.IS_ABSOLUTE); | ||
section.classList.add(constants.IS_ABSOLUTE); | ||
section.style.opacity = 0; | ||
@@ -541,14 +576,14 @@ }); | ||
this.sections[0].classList.add(Fullpage.constants.IS_ACTIVE); // add section indexes | ||
this.sections[0].classList.add(constants.IS_ACTIVE); // add section indexes | ||
this.sections.forEach(function (section, i) { | ||
section.setAttribute(Fullpage.constants.index, i); | ||
section.setAttribute(constants.index, i); | ||
}); // add prev next buttons class names | ||
if (this.options.prevButton) { | ||
this.options.prevButton.classList.add(Fullpage.constants.prev); | ||
this.options.prevButton.classList.add(constants.prev); | ||
} | ||
if (this.options.nextButton) { | ||
this.options.nextButton.classList.add(Fullpage.constants.next); | ||
this.options.nextButton.classList.add(constants.next); | ||
} | ||
@@ -558,3 +593,3 @@ | ||
if (this.current === 0) { | ||
this.options.prevButton.classList.add(Fullpage.constants.IS_DISABLED); | ||
this.options.prevButton.classList.add(constants.IS_DISABLED); | ||
} | ||
@@ -576,3 +611,3 @@ } | ||
value: function _paginateOnLoad() { | ||
this.paginate(this.getIdFromUrl()); | ||
this.paginate(getIdFromUrl()); | ||
} | ||
@@ -584,3 +619,3 @@ }, { | ||
var nav = this.options.navigation; | ||
nav.innerHTML = "<ul class=\"".concat(Fullpage.constants.navList, "\"></ul>"); | ||
nav.innerHTML = "<ul class=\"".concat(constants.navList, "\"></ul>"); | ||
@@ -590,15 +625,15 @@ for (var i = 0; i < this.sections.length; i++) { | ||
var item = document.createElement('li'); | ||
item.className = Fullpage.constants.navItem; | ||
item.className = constants.navItem; | ||
if (this.options.renderNavButton) { | ||
if (i === 0) { | ||
item.innerHTML = "<button class=\"".concat(Fullpage.constants.navButton, " ").concat(Fullpage.constants.IS_ACTIVE, "\" ").concat(Fullpage.constants.index, "=\"").concat(i, "\">").concat(this.options.renderNavButton(i), "</button>"); | ||
item.innerHTML = "<button class=\"".concat(constants.navButton, " ").concat(constants.IS_ACTIVE, "\" ").concat(constants.index, "=\"").concat(i, "\">").concat(this.options.renderNavButton(i), "</button>"); | ||
} else { | ||
item.innerHTML = "<button class=\"".concat(Fullpage.constants.navButton, "\" ").concat(Fullpage.constants.index, "=\"").concat(i, "\">").concat(this.options.renderNavButton(i), "</button>"); | ||
item.innerHTML = "<button class=\"".concat(constants.navButton, "\" ").concat(constants.index, "=\"").concat(i, "\">").concat(this.options.renderNavButton(i), "</button>"); | ||
} | ||
} else { | ||
if (i === 0) { | ||
item.innerHTML = "<button class=\"".concat(Fullpage.constants.navButton, " ").concat(Fullpage.constants.IS_ACTIVE, "\" ").concat(Fullpage.constants.index, "=\"").concat(i, "\">").concat(i + 1, "</button>"); | ||
item.innerHTML = "<button class=\"".concat(constants.navButton, " ").concat(constants.IS_ACTIVE, "\" ").concat(constants.index, "=\"").concat(i, "\">").concat(i + 1, "</button>"); | ||
} else { | ||
item.innerHTML = "<button class=\"".concat(Fullpage.constants.navButton, "\" ").concat(Fullpage.constants.index, "=\"").concat(i, "\">").concat(i + 1, "</button>"); | ||
item.innerHTML = "<button class=\"".concat(constants.navButton, "\" ").concat(constants.index, "=\"").concat(i, "\">").concat(i + 1, "</button>"); | ||
} | ||
@@ -608,4 +643,30 @@ } | ||
} | ||
this.navigation = [].slice.call(nav.querySelectorAll(".".concat(Fullpage.constants.navButton))); | ||
this.navigation = [].slice.call(nav.querySelectorAll(".".concat(constants.navButton))); | ||
} | ||
}, { | ||
key: "_removeListeners", | ||
value: function _removeListeners() { | ||
var _this3 = this; | ||
var events = this.options.touchevents ? ['wheel', 'click', 'swu', 'swd'] : ['wheel', 'click']; | ||
events.forEach(function (event) { | ||
document.removeEventListener(event, _this3.paginateBinded); | ||
}); | ||
} | ||
}, { | ||
key: "_removeElementsAttributes", | ||
value: function _removeElementsAttributes() { | ||
this.sections.forEach(function (section) { | ||
section.classList.remove(constants.IS_ACTIVE); | ||
section.classList.remove(constants.IS_ABSOLUTE); | ||
section.style.opacity = ''; | ||
section.removeAttribute(constants.index); | ||
}); | ||
} | ||
}, { | ||
key: "_removeNavigation", | ||
value: function _removeNavigation() { | ||
if (!this.options.navigation) return; | ||
this.options.navigation.innerHTML = ''; | ||
} | ||
}]); | ||
@@ -615,15 +676,2 @@ | ||
}(); | ||
Fullpage.constants = { | ||
IS_ACTIVE: 'is-active', | ||
IS_ABSOLUTE: 'is-absolute', | ||
IS_DISABLED: 'is-disabled', | ||
navList: 'fullpage-nav', | ||
navItem: 'fullpage-nav__item', | ||
navButton: 'fullpage-nav__button', | ||
prev: 'fullpage__prev', | ||
next: 'fullpage__next', | ||
anchor: 'data-fullpage-anchor', | ||
anchorId: 'data-fullpage-id', | ||
index: 'data-fullpage-index' | ||
}; | ||
@@ -630,0 +678,0 @@ addTouchEvents(); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
54569
16
1211