1(function (global, factory) { 2 typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : 3 typeof define === 'function' && define.amd ? define(factory) : 4 (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.fullpage = factory()); 5})(this, (function () { 'use strict';
vendor: 27,012 bytes, lines 6-944
6 7 if (!Array.prototype.find) { 8 Object.defineProperty(Array.prototype, 'find', { 9 value: function value(predicate) { 10 // 1. Let O be ? ToObject(this value). 11 if (this == null) { 12 throw new TypeError('"this" is null or not defined'); 13 } 14 15 var o = Object(this); // 2. Let len be ? ToLength(? Get(O, "length")). 16 17 var len = o.length >>> 0; // 3. If IsCallable(predicate) is false, throw a TypeError exception. 18 19 if (typeof predicate !== 'function') { 20 throw new TypeError('predicate must be a function'); 21 } // 4. If thisArg was supplied, let T be thisArg; else let T be undefined. 22 23 24 var thisArg = arguments[1]; // 5. Let k be 0. 25 26 var k = 0; // 6. Repeat, while k < len 27 28 while (k < len) { 29 // a. Let Pk be ! ToString(k). 30 // b. Let kValue be ? Get(O, Pk). 31 // c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)). 32 // d. If testResult is true, return kValue. 33 var kValue = o[k]; 34 35 if (predicate.call(thisArg, kValue, k, o)) { 36 return kValue; 37 } // e. Increase k by 1. 38 39 40 k++; 41 } // 7. Return undefined. 42 43 44 return undefined; 45 } 46 }); 47 } 48 49 // Production steps of ECMA-262, Edition 6, 22.1.2.1 50 if (!Array.from) { 51 Array.from = function () { 52 var toStr = Object.prototype.toString; 53 54 var isCallable = function isCallable(fn) { 55 return typeof fn === 'function' || toStr.call(fn) === '[object Function]'; 56 }; 57 58 var toInteger = function toInteger(value) { 59 var number = Number(value); 60 61 if (isNaN(number)) { 62 return 0; 63 } 64 65 if (number === 0 || !isFinite(number)) { 66 return number; 67 } 68 69 return (number > 0 ? 1 : -1) * Math.floor(Math.abs(number)); 70 }; 71 72 var maxSafeInteger = Math.pow(2, 53) - 1; 73 74 var toLength = function toLength(value) { 75 var len = toInteger(value); 76 return Math.min(Math.max(len, 0), maxSafeInteger); 77 }; // The length property of the from method is 1. 78 79 80 return function from(arrayLike 81 /*, mapFn, thisArg */ 82 ) { 83 // 1. Let C be the this value. 84 var C = this; // 2. Let items be ToObject(arrayLike). 85 86 var items = Object(arrayLike); // 3. ReturnIfAbrupt(items). 87 88 if (arrayLike == null) { 89 throw new TypeError('Array.from requires an array-like object - not null or undefined'); 90 } // 4. If mapfn is undefined, then let mapping be false. 91 92 93 var mapFn = arguments.length > 1 ? arguments[1] : void undefined; 94 var T; 95 96 if (typeof mapFn !== 'undefined') { 97 // 5. else 98 // 5. a If IsCallable(mapfn) is false, throw a TypeError exception. 99 if (!isCallable(mapFn)) { 100 throw new TypeError('Array.from: when provided, the second argument must be a function'); 101 } // 5. b. If thisArg was supplied, let T be thisArg; else let T be undefined. 102 103 104 if (arguments.length > 2) { 105 T = arguments[2]; 106 } 107 } // 10. Let lenValue be Get(items, "length"). 108 // 11. Let len be ToLength(lenValue). 109 110 111 var len = toLength(items.length); // 13. If IsConstructor(C) is true, then 112 // 13. a. Let A be the result of calling the [[Construct]] internal method 113 // of C with an argument list containing the single item len. 114 // 14. a. Else, Let A be ArrayCreate(len). 115 116 var A = isCallable(C) ? Object(new C(len)) : new Array(len); // 16. Let k be 0. 117 118 var k = 0; // 17. Repeat, while k < len⦠(also steps a - h) 119 120 var kValue; 121 122 while (k < len) { 123 kValue = items[k]; 124 125 if (mapFn) { 126 A[k] = typeof T === 'undefined' ? mapFn(kValue, k) : mapFn.call(T, kValue, k); 127 } else { 128 A[k] = kValue; 129 } 130 131 k += 1; 132 } // 18. Let putStatus be Put(A, "length", len, true). 133 134 135 A.length = len; // 20. Return A. 136 137 return A; 138 }; 139 }(); 140 } 141 142 var win = window; 143 var doc = document; 144 var isTouchDevice = navigator.userAgent.match(/(iPhone|iPod|iPad|Android|playbook|silk|BlackBerry|BB10|Windows Phone|Tizen|Bada|webOS|IEMobile|Opera Mini)/) || navigator.userAgent.includes("Mac") && "ontouchend" in document; // iPad on iOS 13 detection 145 146 var isMacDevice = /(Mac|iPhone|iPod|iPad)/i.test(win.navigator.userAgent); // @ts-ignore 147 148 var isTouch = 'ontouchstart' in win || navigator.msMaxTouchPoints > 0 || navigator.maxTouchPoints; 149 var isIE11 = !!window.MSInputMethodContext && !!document.documentMode; // taken from https://github.com/udacity/ud891/blob/gh-pages/lesson2-focus/07-modals-and-keyboard-traps/solution/modal.js 150 151 var focusableElementsString = 'a[href], area[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), iframe, object, embed, [tabindex="0"], summary:not([disabled]), [contenteditable]'; // cache common elements 152 153 var FP = { 154 test: {}, 155 shared: {} 156 }; 157 var extensions = ['parallax', 'scrollOverflowReset', 'dragAndMove', 'offsetSections', 'fadingEffect', 'responsiveSlides', 'continuousHorizontal', 'interlockedSlides', 'scrollHorizontally', 'resetSliders', 'cards', 'dropEffect', 'waterEffect']; 158 var isInsideIframe = function () { 159 var inIframe = window.self !== window.top; 160 return function () { 161 return inIframe; 162 }; 163 }(); 164 165 /** 166 * forEach polyfill for IE 167 * https://developer.mozilla.org/en-US/docs/Web/API/NodeList/forEach#Browser_Compatibility 168 */ 169 170 if (win.NodeList && !NodeList.prototype.forEach) { 171 NodeList.prototype.forEach = function (callback, thisArg) { 172 thisArg = thisArg || window; 173 174 for (var i = 0; i < this.length; i++) { 175 callback.call(thisArg, this[i], i, this); 176 } 177 }; 178 } 179 180 if (typeof Object.assign != 'function') { 181 // Must be writable: true, enumerable: false, configurable: true 182 Object.defineProperty(Object, 'assign', { 183 value: function assign(target, varArgs) { 184 185 if (target == null) { 186 // TypeError if undefined or null 187 throw new TypeError('Cannot convert undefined or null to object'); 188 } 189 190 var to = Object(target); 191 192 for (var index = 1; index < arguments.length; index++) { 193 var nextSource = arguments[index]; 194 195 if (nextSource != null) { 196 // Skip over if undefined or null 197 for (var nextKey in nextSource) { 198 // Avoid bugs when hasOwnProperty is shadowed 199 if (Object.prototype.hasOwnProperty.call(nextSource, nextKey)) { 200 to[nextKey] = nextSource[nextKey]; 201 } 202 } 203 } 204 } 205 206 return to; 207 }, 208 writable: true, 209 configurable: true 210 }); 211 } 212 213 // https://stackoverflow.com/questions/51719553/padstart-not-working-in-ie11 214 // https://github.com/behnammodi/polyfill/blob/master/string.polyfill.js 215 // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/padStart 216 if (!String.prototype.padStart) { 217 String.prototype.padStart = function padStart(targetLength, padString) { 218 targetLength = targetLength >> 0; //truncate if number or convert non-number to 0; 219 220 padString = String(typeof padString !== 'undefined' ? padString : ' '); 221 222 if (this.length > targetLength) { 223 return String(this); 224 } else { 225 targetLength = targetLength - this.length; 226 227 if (targetLength > padString.length) { 228 padString += Array.apply(null, Array(targetLength)).map(function () { 229 return padString; 230 }).join(""); 231 } 232 233 return padString.slice(0, targetLength) + String(this); 234 } 235 }; 236 } 237 238 //utils 239 /** 240 * Shows a message in the console of the given type. 241 */ 242 243 function showError(type, text) { 244 win.console && win.console[type] && win.console[type]('fullPage: ' + text); 245 } 246 function isVisible(el) { 247 var style = win.getComputedStyle(el); 248 return style.display !== 'none'; 249 } 250 function getVisible(elements) { 251 return Array.from(elements).filter(function (e) { 252 return isVisible(e); 253 }); 254 } 255 /** 256 * Equivalent of jQuery function $(). 257 */ 258 259 function $(selector, context) { 260 context = arguments.length > 1 ? context : document; 261 return context ? context.querySelectorAll(selector) : null; 262 } 263 /** 264 * Extends a given Object properties and its childs. 265 */ 266 267 function deepExtend(out) { 268 out = out || {}; 269 270 for (var i = 1, len = arguments.length; i < len; ++i) { 271 var obj = arguments[i]; 272 273 if (!obj) { 274 continue; 275 } 276 277 for (var key in obj) { 278 if (!obj.hasOwnProperty(key) || key == '__proto__' || key == 'constructor') { 279 continue; 280 } // based on https://javascriptweblog.wordpress.com/2011/08/08/fixing-the-javascript-typeof-operator/ 281 282 283 if (Object.prototype.toString.call(obj[key]) === '[object Object]') { 284 out[key] = deepExtend(out[key], obj[key]); 285 continue; 286 } 287 288 out[key] = obj[key]; 289 } 290 } 291 292 return out; 293 } 294 /** 295 * Checks if the passed element contains the passed class. 296 */ 297 298 function hasClass(el, className) { 299 if (el == null) { 300 return false; 301 } 302 303 return el.classList.contains(className); 304 } 305 /** 306 * Gets the window height. Crossbrowser. 307 */ 308 309 function getWindowHeight() { 310 return 'innerHeight' in win ? win.innerHeight : doc.documentElement.offsetHeight; 311 } 312 /** 313 * Gets the window width. 314 */ 315 316 function getWindowWidth() { 317 return win.innerWidth; 318 } 319 /** 320 * Set's the CSS properties for the passed item/s. 321 * @param {NodeList|HTMLElement|Object} items 322 * @param {Object} props css properties and values. 323 */ 324 325 function css(items, props) { 326 items = getList(items); 327 var key; 328 329 for (key in props) { 330 if (props.hasOwnProperty(key)) { 331 if (key !== null) { 332 for (var i = 0; i < items.length; i++) { 333 var item = items[i]; 334 item.style[key] = props[key]; 335 } 336 } 337 } 338 } 339 340 return items; 341 } 342 /** 343 * Gets the previous element to the passed element. 344 */ 345 346 function prev(item) { 347 return item.previousElementSibling; 348 } 349 /** 350 * Gets the next element to the passed element. 351 */ 352 353 function next(item) { 354 return item.nextElementSibling; 355 } 356 /** 357 * Gets the last element from the passed list of elements. 358 */ 359 360 function last(item) { 361 return item[item.length - 1]; 362 } 363 /** 364 * Gets index from the passed element. 365 * @param {String} selector is optional. 366 */ 367 368 function index(item, selector) { 369 item = isArrayOrList(item) ? item[0] : item; 370 var children = selector != null ? $(selector, item.parentNode) : item.parentNode.childNodes; 371 var num = 0; 372 373 for (var i = 0; i < children.length; i++) { 374 if (children[i] == item) return num; 375 if (children[i].nodeType == 1) num++; 376 } 377 378 return -1; 379 } 380 /** 381 * Gets an iterable element for the passed element/s 382 */ 383 384 function getList(item) { 385 return !isArrayOrList(item) ? [item] : item; 386 } 387 /** 388 * Adds the display=none property for the passed element/s 389 */ 390 391 function hide(el) { 392 el = getList(el); 393 394 for (var i = 0; i < el.length; i++) { 395 el[i].style.display = 'none'; 396 } 397 398 return el; 399 } 400 /** 401 * Adds the display=block property for the passed element/s 402 */ 403 404 function show(el) { 405 el = getList(el); 406 407 for (var i = 0; i < el.length; i++) { 408 el[i].style.display = 'block'; 409 } 410 411 return el; 412 } 413 /** 414 * Checks if the passed element is an iterable element or not 415 */ 416 417 function isArrayOrList(el) { 418 return Object.prototype.toString.call(el) === '[object Array]' || Object.prototype.toString.call(el) === '[object NodeList]'; 419 } 420 /** 421 * Adds the passed class to the passed element/s 422 */ 423 424 function addClass(el, className) { 425 el = getList(el); 426 427 for (var i = 0; i < el.length; i++) { 428 var item = el[i]; 429 item.classList.add(className); 430 } 431 432 return el; 433 } 434 /** 435 * Removes the passed class to the passed element/s 436 * @param {String} `className` can be multiple classnames separated by whitespace 437 */ 438 439 function removeClass(el, className) { 440 el = getList(el); 441 var classNames = className.split(' '); 442 443 for (var a = 0; a < classNames.length; a++) { 444 className = classNames[a]; 445 446 for (var i = 0; i < el.length; i++) { 447 var item = el[i]; 448 item.classList.remove(className); 449 } 450 } 451 452 return el; 453 } 454 /** 455 * Appends the given element ot the given parent. 456 */ 457 458 function appendTo(el, parent) { 459 parent.appendChild(el); 460 } 461 /** 462 Usage: 463 464 var wrapper = document.createElement('div'); 465 wrapper.className = 'fp-slides'; 466 wrap($('.slide'), wrapper); 467 468 https://jsfiddle.net/qwzc7oy3/15/ (vanilla) 469 https://jsfiddle.net/oya6ndka/1/ (jquery equivalent) 470 */ 471 472 function wrap(toWrap, wrapper, isWrapAll) { 473 var newParent; 474 wrapper = wrapper || doc.createElement('div'); 475 476 for (var i = 0; i < toWrap.length; i++) { 477 var item = toWrap[i]; 478 479 if (isWrapAll && !i || !isWrapAll) { 480 newParent = wrapper.cloneNode(true); 481 item.parentNode.insertBefore(newParent, item); 482 } 483 484 newParent.appendChild(item); 485 } 486 487 return toWrap; 488 } 489 /** 490 Usage: 491 var wrapper = document.createElement('div'); 492 wrapper.className = 'fp-slides'; 493 wrap($('.slide'), wrapper); 494 495 https://jsfiddle.net/qwzc7oy3/27/ (vanilla) 496 https://jsfiddle.net/oya6ndka/4/ (jquery equivalent) 497 */ 498 499 function wrapAll(toWrap, wrapper) { 500 wrap(toWrap, wrapper, true); 501 } 502 /** 503 * Usage: 504 * wrapInner(document.querySelector('#pepe'), '<div class="test">afdas</div>'); 505 * wrapInner(document.querySelector('#pepe'), element); 506 * 507 * https://jsfiddle.net/zexxz0tw/6/ 508 * 509 * https://stackoverflow.com/a/21817590/1081396 510 */ 511 512 function wrapInner(parent, wrapper) { 513 parent.appendChild(wrapper); 514 515 while (parent.firstChild !== wrapper) { 516 wrapper.appendChild(parent.firstChild); 517 } 518 } 519 /** 520 * Usage: 521 * unwrap(document.querySelector('#pepe')); 522 * unwrap(element); 523 * 524 * https://jsfiddle.net/szjt0hxq/1/ 525 * 526 */ 527 528 function unwrap(wrapper) { 529 var wrapperContent = doc.createDocumentFragment(); 530 531 while (wrapper.firstChild) { 532 wrapperContent.appendChild(wrapper.firstChild); 533 } 534 535 wrapper.parentNode.replaceChild(wrapperContent, wrapper); 536 } 537 /** 538 * http://stackoverflow.com/questions/22100853/dom-pure-javascript-solution-to-jquery-closest-implementation 539 * Returns the element or `false` if there's none 540 */ 541 542 function closest(el, selector) { 543 if (el && el.nodeType === 1) { 544 if (matches(el, selector)) { 545 return el; 546 } 547 548 return closest(el.parentNode, selector); 549 } 550 551 return null; 552 } 553 /** 554 * Places one element (rel) after another one or group of them (reference). 555 * @param {HTMLElement} reference 556 * @param {HTMLElement|NodeList|String|Array} el 557 * https://jsfiddle.net/9s97hhzv/1/ 558 */ 559 560 function after(reference, el) { 561 insertBefore(reference, reference.nextSibling, el); 562 } 563 /** 564 * Places one element (rel) before another one or group of them (reference). 565 * @param {HTMLElement} reference 566 * @param {HTMLElement|NodeList|String|Array} el 567 * https://jsfiddle.net/9s97hhzv/1/ 568 */ 569 570 function before(reference, el) { 571 insertBefore(reference, reference, el); 572 } 573 /** 574 * Based in https://stackoverflow.com/a/19316024/1081396 575 * and https://stackoverflow.com/a/4793630/1081396 576 */ 577 578 function insertBefore(reference, beforeElement, el) { 579 if (!isArrayOrList(el)) { 580 if (typeof el == 'string') { 581 el = createElementFromHTML(el); 582 } 583 584 el = [el]; 585 } 586 587 for (var i = 0; i < el.length; i++) { 588 reference.parentNode.insertBefore(el[i], beforeElement); 589 } 590 } //http://stackoverflow.com/questions/3464876/javascript-get-window-x-y-position-for-scroll 591 592 function getScrollTop() { 593 var docElement = doc.documentElement; 594 return (win.pageYOffset || docElement.scrollTop) - (docElement.clientTop || 0); 595 } 596 /** 597 * Gets the siblings of the passed element 598 */ 599 600 function siblings(el) { 601 return Array.prototype.filter.call(el.parentNode.children, function (child) { 602 return child !== el; 603 }); 604 } 605 function preventDefault(event) { 606 event.preventDefault(); 607 } 608 function getAttr(el, attr) { 609 return el.getAttribute(attr); 610 } 611 function docAddEvent(event, callback, options) { 612 doc.addEventListener(event, callback, options === 'undefined' ? null : options); 613 } 614 function windowAddEvent(event, callback, options) { 615 win.addEventListener(event, callback, options === 'undefined' ? null : options); 616 } 617 function docRemoveEvent(event, callback, options) { 618 doc.removeEventListener(event, callback, options === 'undefined' ? null : options); 619 } 620 function windowRemoveEvent(event, callback, options) { 621 win.removeEventListener(event, callback, options === 'undefined' ? null : options); 622 } 623 /** 624 * Determines whether the passed item is of function type. 625 */ 626 627 function isFunction(item) { 628 if (typeof item === 'function') { 629 return true; 630 } 631 632 var type = Object.prototype.toString.call(item); 633 return type === '[object Function]' || type === '[object GeneratorFunction]'; 634 } 635 /** 636 * Trigger custom events 637 */ 638 639 function trigger(el, eventName, data) { 640 var event; 641 data = typeof data === 'undefined' ? {} : data; // Native 642 643 if (typeof win.CustomEvent === "function") { 644 event = new CustomEvent(eventName, { 645 detail: data 646 }); 647 } else { 648 event = doc.createEvent('CustomEvent'); 649 event.initCustomEvent(eventName, true, true, data); 650 } 651 652 el.dispatchEvent(event); 653 } 654 /** 655 * Polyfill of .matches() 656 */ 657 658 function matches(el, selector) { 659 return (el.matches || el.matchesSelector || el.msMatchesSelector || el.mozMatchesSelector || el.webkitMatchesSelector || el.oMatchesSelector).call(el, selector); 660 } 661 /** 662 * Toggles the visibility of the passed element el. 663 */ 664 665 function toggle(el, value) { 666 if (typeof value === "boolean") { 667 for (var i = 0; i < el.length; i++) { 668 el[i].style.display = value ? 'block' : 'none'; 669 } 670 } //we don't use it in other way, so no else :) 671 672 673 return el; 674 } 675 /** 676 * Creates a HTMLElement from the passed HTML string. 677 * https://stackoverflow.com/a/494348/1081396 678 */ 679 680 function createElementFromHTML(htmlString) { 681 var div = doc.createElement('div'); 682 div.innerHTML = htmlString.trim(); // Change this to div.childNodes to support multiple top-level nodes 683 684 return div.firstChild; 685 } 686 /** 687 * Removes the passed item/s from the DOM. 688 */ 689 690 function remove(items) { 691 items = getList(items); 692 693 for (var i = 0; i < items.length; i++) { 694 var item = items[i]; 695 696 if (item && item.parentElement) { 697 item.parentNode.removeChild(item); 698 } 699 } 700 } //https://jsfiddle.net/w1rktecz/ 701 702 function untilAll(item, selector, fn) { 703 var sibling = item[fn]; 704 var siblings = []; 705 706 while (sibling) { 707 if (matches(sibling, selector) || selector == null) { 708 siblings.push(sibling); 709 } 710 711 sibling = sibling[fn]; 712 } 713 714 return siblings; 715 } 716 /** 717 * Gets all next elements matching the passed selector. 718 */ 719 720 function nextAll(item, selector) { 721 return untilAll(item, selector, 'nextElementSibling'); 722 } 723 /** 724 * Gets all previous elements matching the passed selector. 725 */ 726 727 function prevAll(item, selector) { 728 return untilAll(item, selector, 'previousElementSibling'); 729 } 730 /** 731 * Converts an object to an array. 732 */ 733 734 function toArray(objectData) { 735 return Object.keys(objectData).map(function (key) { 736 return objectData[key]; 737 }); 738 } 739 function getLast(items) { 740 return items[items.length - 1]; 741 } 742 /** 743 * Gets the average of the last `number` elements of the given array. 744 */ 745 746 function getAverage(elements, number) { 747 var sum = 0; //taking `number` elements from the end to make the average, if there are not enought, 1 748 749 var lastElements = elements.slice(Math.max(elements.length - number, 1)); 750 751 for (var i = 0; i < lastElements.length; i++) { 752 sum = sum + lastElements[i]; 753 } 754 755 return Math.ceil(sum / number); 756 } 757 /** 758 * Sets the value for the given attribute from the `data-` attribute with the same suffix 759 * ie: data-srcset ==> srcset | data-src ==> src 760 */ 761 762 function setSrc(element, attribute) { 763 element.setAttribute(attribute, getAttr(element, 'data-' + attribute)); 764 element.removeAttribute('data-' + attribute); 765 } 766 function getParentsUntil(item, topParentSelector) { 767 var parents = [item]; 768 769 do { 770 item = item.parentNode; 771 parents.push(item); 772 } while (!matches(item, topParentSelector)); 773 774 return parents; 775 } 776 function isInsideInput() { 777 var activeElement = doc.activeElement; 778 return matches(activeElement, 'textarea') || matches(activeElement, 'input') || matches(activeElement, 'select') || getAttr(activeElement, 'contentEditable') == "true" || getAttr(activeElement, 'contentEditable') == ''; 779 } //utils are public, so we can use it wherever we want 780 // @ts-ignore 781 782 window["fp_utils"] = { 783 "$": $, 784 "deepExtend": deepExtend, 785 "hasClass": hasClass, 786 "getWindowHeight": getWindowHeight, 787 "css": css, 788 "prev": prev, 789 "next": next, 790 "last": last, 791 "index": index, 792 "getList": getList, 793 "hide": hide, 794 "show": show, 795 "isArrayOrList": isArrayOrList, 796 "addClass": addClass, 797 "removeClass": removeClass, 798 "appendTo": appendTo, 799 "wrap": wrap, 800 "wrapAll": wrapAll, 801 "unwrap": unwrap, 802 "closest": closest, 803 "after": after, 804 "before": before, 805 "insertBefore": insertBefore, 806 "getScrollTop": getScrollTop, 807 "siblings": siblings, 808 "preventDefault": preventDefault, 809 "isFunction": isFunction, 810 "trigger": trigger, 811 "matches": matches, 812 "toggle": toggle, 813 "createElementFromHTML": createElementFromHTML, 814 "remove": remove, 815 // "filter": filter, 816 "untilAll": untilAll, 817 "nextAll": nextAll, 818 "prevAll": prevAll, 819 "showError": showError 820 }; 821 822 var utils = /*#__PURE__*/Object.freeze({ 823 __proto__: null, 824 showError: showError, 825 isVisible: isVisible, 826 getVisible: getVisible, 827 $: $, 828 deepExtend: deepExtend, 829 hasClass: hasClass, 830 getWindowHeight: getWindowHeight, 831 getWindowWidth: getWindowWidth, 832 css: css, 833 prev: prev, 834 next: next, 835 last: last, 836 index: index, 837 getList: getList, 838 hide: hide, 839 show: show, 840 isArrayOrList: isArrayOrList, 841 addClass: addClass, 842 removeClass: removeClass, 843 appendTo: appendTo, 844 wrap: wrap, 845 wrapAll: wrapAll, 846 wrapInner: wrapInner, 847 unwrap: unwrap, 848 closest: closest, 849 after: after, 850 before: before, 851 insertBefore: insertBefore, 852 getScrollTop: getScrollTop, 853 siblings: siblings, 854 preventDefault: preventDefault, 855 getAttr: getAttr, 856 docAddEvent: docAddEvent, 857 windowAddEvent: windowAddEvent, 858 docRemoveEvent: docRemoveEvent, 859 windowRemoveEvent: windowRemoveEvent, 860 isFunction: isFunction, 861 trigger: trigger, 862 matches: matches, 863 toggle: toggle, 864 createElementFromHTML: createElementFromHTML, 865 remove: remove, 866 untilAll: untilAll, 867 nextAll: nextAll, 868 prevAll: prevAll, 869 toArray: toArray, 870 getLast: getLast, 871 getAverage: getAverage, 872 setSrc: setSrc, 873 getParentsUntil: getParentsUntil, 874 isInsideInput: isInsideInput 875 }); 876 877 function _typeof(obj) { 878 "@babel/helpers - typeof"; 879 880 if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { 881 _typeof = function (obj) { 882 return typeof obj; 883 }; 884 } else { 885 _typeof = function (obj) { 886 return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; 887 }; 888 } 889 890 return _typeof(obj); 891 } 892 893 var EventEmitter = { 894 events: {}, 895 on: function on(event, listener) { 896 var _this = this; 897 898 if (_typeof(this.events[event]) !== 'object') { 899 this.events[event] = []; 900 } 901 902 this.events[event].push(listener); 903 return function () { 904 return _this.removeListener(event, listener); 905 }; 906 }, 907 removeListener: function removeListener(event, listener) { 908 if (_typeof(this.events[event]) === 'object') { 909 var idx = this.events[event].indexOf(listener); 910 911 if (idx > -1) { 912 this.events[event].splice(idx, 1); 913 } 914 } 915 }, 916 emit: function emit(event) { 917 var _this2 = this; 918 919 for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { 920 args[_key - 1] = arguments[_key]; 921 } 922 923 if (_typeof(this.events[event]) === 'object') { 924 this.events[event].forEach(function (listener) { 925 return listener.apply(_this2, args); 926 }); 927 } 928 }, 929 once: function once(event, listener) { 930 var _this3 = this; 931 932 var remove = this.on(event, function () { 933 remove(); 934 935 for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { 936 args[_key2] = arguments[_key2]; 937 } 938 939 listener.apply(_this3, args); 940 }); 941 } 942 }; 943 944 var
vendor: 8,031 bytes, lines 944-1204
944state = { 945 numSections: 0, 946 numSlides: 0, 947 slides: [], 948 sections: [], 949 activeSection: null, 950 scrollTrigger: null, 951 isBeyondFullpage: false, 952 aboutToScrollToFullPage: false, 953 slideMoving: false, 954 isResizing: false, 955 isScrolling: false, 956 lastScrolledDestiny: undefined, 957 lastScrolledSlide: undefined, 958 activeAnimation: false, 959 canScroll: true, 960 touchDirection: 'none', 961 wheelDirection: 'none', 962 isGrabbing: false, 963 isUsingWheel: false, 964 isWindowFocused: true, 965 previousDestTop: 0, 966 windowsHeight: getWindowHeight(), 967 isDoingContinousVertical: false, 968 timeouts: {}, 969 scrollY: 0, 970 scrollX: 0, 971 isFullpageInitDone: false 972 }; // @ts-ignore 973 974 win.state = state; 975 function setState(props) { 976 Object.assign(state, props); 977 } 978 function getState() { 979 return state; 980 } 981 function getActivePanel() { 982 return state.activeSection && state.activeSection.activeSlide ? state.activeSection.activeSlide : state.activeSection; 983 } 984 985 var events = { 986 onAfterRenderNoAnchor: 'onAfterRenderNoAnchor', 987 onClickOrTouch: 'onClickOrTouch', 988 moveSlideLeft: 'moveSlideLeft', 989 moveSlideRight: 'moveSlideRight', 990 onInitialise: 'onInitialise', 991 beforeInit: 'beforeInit', 992 bindEvents: 'bindEvents', 993 onDestroy: 'onDestroy', 994 contentChanged: 'contentChanged', 995 onScrollOverflowScrolled: 'onScrollOverflowScrolled', 996 onScrollPageAndSlide: 'onScrollPageAndSlide', 997 onKeyDown: 'onKeyDown', 998 onMenuClick: 'onMenuClick', 999 scrollPage: 'scrollPage', 1000 landscapeScroll: 'landscapeScroll', 1001 scrollBeyondFullpage: 'scrollBeyondFullpage', 1002 onPerformMovement: 'onPerformMovement', 1003 onSlideLeave: 'onSlideLeave', 1004 onLeave: 'onLeave', 1005 afterSectionLoads: 'afterSectionLoads', 1006 afterSlideLoads: 'afterSlideLoads' 1007 }; 1008 1009 EventEmitter.on(events.bindEvents, bindEvents$c); 1010 1011 function bindEvents$c() { 1012 //Scrolls to the section when clicking the navigation bullet 1013 //simulating the jQuery .on('click') event using delegation 1014 ['click', 'touchstart'].forEach(function (eventName) { 1015 docAddEvent(eventName, delegatedEvents); 1016 }); 1017 windowAddEvent('focus', focusHandler); 1018 internalEvents(); 1019 } 1020 1021 function internalEvents() { 1022 EventEmitter.on(events.onDestroy, onDestroy$9); 1023 } 1024 1025 function delegatedEvents(e) { 1026 EventEmitter.emit(events.onClickOrTouch, { 1027 e: e, 1028 target: e.target 1029 }); 1030 } 1031 1032 function onDestroy$9() { 1033 ['click', 'touchstart'].forEach(function (eventName) { 1034 docRemoveEvent(eventName, delegatedEvents); 1035 }); 1036 } // changing isWindowFocused to true on focus event 1037 1038 1039 function focusHandler() { 1040 setState({ 1041 isWindowFocused: true 1042 }); 1043 } 1044 1045 // keeping central set of classnames and selectors 1046 var WRAPPER = 'fullpage-wrapper'; 1047 var WRAPPER_SEL = '.' + WRAPPER; // slimscroll 1048 1049 var SCROLLABLE = 'fp-scrollable'; 1050 1051 var RESPONSIVE = 'fp-responsive'; 1052 var NO_TRANSITION = 'fp-notransition'; 1053 var DESTROYED = 'fp-destroyed'; 1054 var ENABLED = 'fp-enabled'; 1055 var VIEWING_PREFIX = 'fp-viewing'; 1056 var ACTIVE = 'active'; 1057 var ACTIVE_SEL = '.' + ACTIVE; 1058 var COMPLETELY = 'fp-completely'; 1059 var COMPLETELY_SEL = '.' + COMPLETELY; 1060 var LOADED = 'fp-loaded'; 1061 1062 var SECTION_DEFAULT_SEL = '.section'; 1063 var SECTION = 'fp-section'; 1064 var SECTION_SEL = '.' + SECTION; 1065 var SECTION_ACTIVE_SEL = SECTION_SEL + ACTIVE_SEL; 1066 var TABLE_CELL = 'fp-tableCell'; 1067 var TABLE_CELL_SEL = '.' + TABLE_CELL; 1068 var AUTO_HEIGHT = 'fp-auto-height'; 1069 var AUTO_HEIGHT_SEL = '.' + AUTO_HEIGHT; 1070 var AUTO_HEIGHT_RESPONSIVE = 'fp-auto-height-responsive'; 1071 var AUTO_HEIGHT_RESPONSIVE_SEL = '.' + AUTO_HEIGHT_RESPONSIVE; 1072 var NORMAL_SCROLL = 'fp-normal-scroll'; 1073 1074 var SECTION_NAV = 'fp-nav'; 1075 var SECTION_NAV_SEL = '#' + SECTION_NAV; 1076 var SECTION_NAV_TOOLTIP = 'fp-tooltip'; 1077 var SECTION_NAV_TOOLTIP_SEL = '.' + SECTION_NAV_TOOLTIP; 1078 var SHOW_ACTIVE_TOOLTIP = 'fp-show-active'; // slide 1079 1080 var SLIDE_DEFAULT_SEL = '.slide'; 1081 var SLIDE = 'fp-slide'; 1082 var SLIDE_SEL = '.' + SLIDE; 1083 var SLIDE_ACTIVE_SEL = SLIDE_SEL + ACTIVE_SEL; 1084 var SLIDES_WRAPPER = 'fp-slides'; 1085 var SLIDES_WRAPPER_SEL = '.' + SLIDES_WRAPPER; 1086 var SLIDES_CONTAINER = 'fp-slidesContainer'; 1087 var SLIDES_CONTAINER_SEL = '.' + SLIDES_CONTAINER; 1088 var TABLE = 'fp-table'; 1089 var OVERFLOW = 'fp-overflow'; 1090 var OVERFLOW_SEL = '.' + OVERFLOW; 1091 var IS_OVERFLOW = 'fp-is-overflow'; // slide nav 1092 1093 var SLIDES_NAV = 'fp-slidesNav'; 1094 var SLIDES_NAV_SEL = '.' + SLIDES_NAV; 1095 var SLIDES_NAV_LINK_SEL = SLIDES_NAV_SEL + ' a'; 1096 var SLIDES_STYLED_ARROW = 'fp-arrow'; 1097 var SLIDES_ARROW = 'fp-controlArrow'; 1098 var SLIDES_ARROW_SEL = '.' + SLIDES_ARROW; 1099 var SLIDES_PREV = 'fp-prev'; 1100 var SLIDES_PREV_SEL = '.' + SLIDES_PREV; 1101 var SLIDES_ARROW_PREV_SEL = SLIDES_ARROW_SEL + SLIDES_PREV_SEL; 1102 var SLIDES_NEXT = 'fp-next'; 1103 var SLIDES_NEXT_SEL = '.' + SLIDES_NEXT; 1104 // var SLIDES_ARROW_NEXT_SEL = SLIDES_ARROW_SEL + SLIDES_NEXT_SEL; // Watermark 1105 1106 // var WATERMARK = 'fp-watermark'; 1107 // var WATERMARK_SEL = '.' + WATERMARK; 1108 1109 var defaultOptions = { 1110 //navigation 1111 menu: false, 1112 anchors: [], 1113 lockAnchors: false, 1114 navigation: false, 1115 navigationPosition: 'right', 1116 navigationTooltips: [], 1117 showActiveTooltip: false, 1118 slidesNavigation: false, 1119 slidesNavPosition: 'bottom', 1120 scrollBar: false, 1121 hybrid: false, 1122 licenseKey: '', 1123 credits: { 1124 "enabled": true, 1125 "label": 'Made with fullPage.js', 1126 "position": 'right' 1127 }, 1128 //scrolling 1129 css3: true, 1130 scrollingSpeed: 700, 1131 autoScrolling: true, 1132 fitToSection: true, 1133 fitToSectionDelay: 600, 1134 easing: 'easeInOutCubic', 1135 easingcss3: 'ease', 1136 loopBottom: false, 1137 loopTop: false, 1138 loopHorizontal: true, 1139 continuousVertical: false, 1140 continuousHorizontal: false, 1141 scrollHorizontally: false, 1142 interlockedSlides: false, 1143 dragAndMove: false, 1144 offsetSections: false, 1145 resetSliders: false, 1146 fadingEffect: false, 1147 normalScrollElements: null, 1148 scrollOverflow: true, 1149 scrollOverflowReset: false, 1150 skipIntermediateItems: false, 1151 touchSensitivity: 5, 1152 touchWrapper: null, 1153 bigSectionsDestination: null, 1154 adjustOnNavChange: true, 1155 //Accessibility 1156 keyboardScrolling: true, 1157 animateAnchor: true, 1158 recordHistory: true, 1159 allowCorrectDirection: false, 1160 //design 1161 scrollOverflowMacStyle: true, 1162 controlArrows: true, 1163 controlArrowsHTML: ['<div class="' + SLIDES_STYLED_ARROW + '"></div>', '<div class="' + SLIDES_STYLED_ARROW + '"></div>'], 1164 controlArrowColor: '#fff', 1165 verticalCentered: true, 1166 sectionsColor: [], 1167 paddingTop: 0, 1168 paddingBottom: 0, 1169 fixedElements: null, 1170 responsive: 0, 1171 //backwards compabitility with responsiveWiddth 1172 responsiveWidth: 0, 1173 responsiveHeight: 0, 1174 responsiveSlides: false, 1175 parallax: false, 1176 parallaxOptions: { 1177 type: 'reveal', 1178 percentage: 62, 1179 property: 'translate' 1180 }, 1181 cards: false, 1182 cardsOptions: { 1183 perspective: 100, 1184 fadeContent: true, 1185 fadeBackground: true 1186 }, 1187 //Custom selectors 1188 sectionSelector: SECTION_DEFAULT_SEL, 1189 slideSelector: SLIDE_DEFAULT_SEL, 1190 //events 1191 afterLoad: null, 1192 beforeLeave: null, 1193 onLeave: null, 1194 afterRender: null, 1195 afterResize: null, 1196 afterReBuild: null, 1197 afterSlideLoad: null, 1198 onSlideLeave: null, 1199 afterResponsive: null, 1200 onScrollOverflow: null, 1201 lazyLoading: true, 1202 lazyLoadThreshold: 0, 1203 observer: true, 1204 scrollBeyondFullpage: tru
vendor: 19,373 bytes, lines 1204-1852
1204e 1205 }; 1206 1207 var container = null; 1208 var g_initialAnchorsInDom = false; 1209 var originals = deepExtend({}, defaultOptions); //deep copy 1210 1211 var g_options = null; 1212 function getInitialAnchorsInDom() { 1213 return g_initialAnchorsInDom; 1214 } 1215 function setContainer(value) { 1216 container = value; 1217 } 1218 function getContainer(value) { 1219 return container; 1220 } 1221 function getOptions() { 1222 return g_options || defaultOptions; 1223 } 1224 function setOptions(options) { 1225 g_options = deepExtend({}, defaultOptions, options); 1226 originals = Object.assign({}, g_options); 1227 } 1228 function getOriginals() { 1229 return originals; 1230 } 1231 function setOption(name, value) { 1232 defaultOptions[name] = value; 1233 } 1234 /* 1235 * Sets the state for a variable with multiple states (original, and temporal) 1236 * Some variables such as `autoScrolling` or `recordHistory` might change automatically its state when using `responsive` or `autoScrolling:false`. 1237 * This function is used to keep track of both states, the original and the temporal one. 1238 * If type is not 'internal', then we assume the user is globally changing the variable. 1239 */ 1240 1241 function setVariableState(variable, value, type) { 1242 g_options[variable] = value; 1243 1244 if (type !== 'internal') { 1245 originals[variable] = value; 1246 } 1247 } 1248 /** 1249 * Setting options from DOM elements if they are not provided. 1250 */ 1251 1252 function setOptionsFromDOM() { 1253 //no anchors option? Checking for them in the DOM attributes 1254 if (!getOptions().anchors.length) { 1255 var anchorsAttribute = '[data-anchor]'; 1256 var anchors = $(getOptions().sectionSelector.split(',').join(anchorsAttribute + ',') + anchorsAttribute, container); 1257 1258 if (anchors.length && anchors.length === $(getOptions().sectionSelector, container).length) { 1259 g_initialAnchorsInDom = true; 1260 anchors.forEach(function (item) { 1261 getOptions().anchors.push(getAttr(item, 'data-anchor').toString()); 1262 }); 1263 } 1264 } //no tooltips option? Checking for them in the DOM attributes 1265 1266 1267 if (!getOptions().navigationTooltips.length) { 1268 var tooltipsAttribute = '[data-tooltip]'; 1269 var tooltips = $(getOptions().sectionSelector.split(',').join(tooltipsAttribute + ',') + tooltipsAttribute, container); 1270 1271 if (tooltips.length) { 1272 tooltips.forEach(function (item) { 1273 getOptions().navigationTooltips.push(getAttr(item, 'data-tooltip').toString()); 1274 }); 1275 } 1276 } 1277 } 1278 1279 var plainItem = function plainItem(panel) { 1280 this.anchor = panel.anchor; 1281 this.item = panel.item; 1282 this.index = panel.index(); 1283 this.isLast = this.index === panel.item.parentElement.querySelectorAll(panel.selector).length - 1; 1284 this.isFirst = !this.index; 1285 this.isActive = panel.isActive; 1286 }; 1287 /** 1288 * Item. Slide or Section objects share the same properties. 1289 */ 1290 1291 var Item = function Item(el, selector) { 1292 this.parent = this.parent || null; 1293 this.selector = selector; 1294 this.anchor = getAttr(el, 'data-anchor') || getOptions().anchors[index(el, getOptions().sectionSelector)]; 1295 this.item = el; 1296 this.isVisible = isVisible(el); 1297 this.isActive = hasClass(el, ACTIVE); 1298 this.hasScroll = hasClass(el, OVERFLOW) || $(OVERFLOW_SEL, el)[0] != null; 1299 this.isSection = selector === getOptions().sectionSelector; 1300 this.container = closest(el, SLIDES_CONTAINER_SEL) || closest(el, WRAPPER_SEL); 1301 1302 this.index = function () { 1303 return this.siblings().indexOf(this); 1304 }; 1305 }; 1306 1307 Item.prototype.siblings = function () { 1308 if (this.isSection) { 1309 if (this.isVisible) { 1310 return state.sections; 1311 } else { 1312 return state.sectionsIncludingHidden; 1313 } 1314 } 1315 1316 return this.parent ? this.parent.slides : 0; 1317 }; 1318 1319 Item.prototype.prev = function () { 1320 var siblings = this.siblings(); 1321 var currentIndex = this.isSection ? siblings.indexOf(this) : this.parent.slides.indexOf(this); 1322 var prevIndex = currentIndex - 1; 1323 1324 if (prevIndex >= 0) { 1325 return siblings[prevIndex]; 1326 } 1327 1328 return null; 1329 }; 1330 1331 Item.prototype.next = function () { 1332 var siblings = this.siblings(); 1333 var currentIndex = this.isSection ? siblings.indexOf(this) : this.parent.slides.indexOf(this); 1334 var nextIndex = currentIndex + 1; 1335 1336 if (nextIndex < siblings.length) { 1337 return siblings[nextIndex]; 1338 } 1339 1340 return null; 1341 }; 1342 1343 Item.prototype["prevPanel"] = function () { 1344 return this.prev() || (this.parent ? this.parent.prev() : null); 1345 }; 1346 1347 Item.prototype["nextPanel"] = function () { 1348 return this.next() || (this.parent ? this.parent.next() : null); 1349 }; 1350 1351 Item.prototype.getSiblings = function () { 1352 if (this.isSection) { 1353 return state.sections; 1354 } 1355 1356 return state.panels; 1357 }; 1358 1359 function getNodes(panels) { 1360 return panels.map(function (panel) { 1361 return panel.item; 1362 }); 1363 } 1364 function getPanelByElement(panels, el) { 1365 return panels.find(function (panel) { 1366 return panel.item === el; 1367 }); 1368 } 1369 var Section = function Section(el) { 1370 plainItem.call(this, el); 1371 }; 1372 var Slide = function Slide(el) { 1373 plainItem.call(this, el); 1374 }; 1375 1376 /** 1377 * Gets the active slide (or section) for the given section 1378 */ 1379 1380 function getSlideOrSection(destiny) { 1381 var slide = $(SLIDE_ACTIVE_SEL, destiny); 1382 1383 if (slide.length) { 1384 destiny = slide[0]; 1385 } 1386 1387 return destiny; 1388 } 1389 function getSlideOrSectionPanel(panel) { 1390 if (!panel) { 1391 return null; 1392 } 1393 1394 return panel.activeSlide ? panel.activeSlide : panel; 1395 } 1396 function isFullPageAbove() { 1397 return getContainer().getBoundingClientRect().bottom >= 0; 1398 } 1399 /** 1400 * Gets the scrolling settings depending on the plugin autoScrolling option 1401 */ 1402 1403 function getScrollSettings(top) { 1404 var options = getOptions(); 1405 var position; 1406 var element; //top property animation 1407 1408 if (options.autoScrolling && !options.scrollBar) { 1409 position = -top; 1410 element = $(WRAPPER_SEL)[0]; 1411 } //window real scrolling 1412 else { 1413 position = top; 1414 element = window; 1415 } 1416 1417 return { 1418 options: position, 1419 element: element 1420 }; 1421 } 1422 /** 1423 * Scrolls the page / slider the given number of pixels. 1424 * It will do it one or another way dependiong on the library's config. 1425 */ 1426 1427 function setScrolling(element, val) { 1428 if (!getOptions().autoScrolling || getOptions().scrollBar || element.self != window && hasClass(element, SLIDES_WRAPPER)) { 1429 //scrolling horizontally through the slides? 1430 if (element.self != window && hasClass(element, SLIDES_WRAPPER)) { 1431 element.scrollLeft = val; 1432 } //vertical scroll 1433 else { 1434 element.scrollTo(0, val); 1435 } 1436 } else { 1437 element.style.top = val + 'px'; 1438 } 1439 } 1440 /** 1441 * Adds transition animations for the given element 1442 */ 1443 1444 function addAnimation(element) { 1445 var transition = 'transform ' + getOptions().scrollingSpeed + 'ms ' + getOptions().easingcss3; 1446 removeClass(element, NO_TRANSITION); 1447 return css(element, { 1448 '-webkit-transition': transition, 1449 'transition': transition 1450 }); 1451 } 1452 /** 1453 * Retuns `up` or `down` depending on the scrolling movement to reach its destination 1454 * from the current section. 1455 */ 1456 1457 function getYmovement(activeSection, destiny) { 1458 var fromIndex = activeSection.index(); 1459 var toIndex = index(destiny, SECTION_SEL); 1460 1461 if (fromIndex == toIndex) { 1462 return 'none'; 1463 } 1464 1465 if (fromIndex > toIndex) { 1466 return 'up'; 1467 } 1468 1469 return 'down'; 1470 } 1471 /** 1472 * Remove transition animations for the given element 1473 */ 1474 1475 function removeAnimation(element) { 1476 return addClass(element, NO_TRANSITION); 1477 } 1478 /** 1479 * Returns the cross-browser transform string. 1480 */ 1481 1482 function getTransforms(translate3d) { 1483 return { 1484 '-webkit-transform': translate3d, 1485 '-moz-transform': translate3d, 1486 '-ms-transform': translate3d, 1487 'transform': translate3d 1488 }; 1489 } 1490 1491 var silentScrollId; 1492 /** 1493 * Adds a css3 transform property to the container class with or without animation depending on the animated param. 1494 */ 1495 1496 function transformContainer(translate3d, animated) { 1497 if (animated) { 1498 addAnimation(getContainer()); 1499 } else { 1500 removeAnimation(getContainer()); 1501 } 1502 1503 clearTimeout(silentScrollId); 1504 css(getContainer(), getTransforms(translate3d)); 1505 FP.test.translate3d = translate3d; //syncronously removing the class after the animation has been applied. 1506 1507 silentScrollId = setTimeout(function () { 1508 removeClass(getContainer(), NO_TRANSITION); 1509 }, 10); 1510 } 1511 1512 /** 1513 * Scrolls silently (with no animation) the page to the given Y position. 1514 */ 1515 1516 function silentScroll(top) { 1517 // The first section can have a negative value in iOS 10. Not quite sure why: -0.0142822265625 1518 // that's why we round it to 0. 1519 var roundedTop = Math.round(top); 1520 1521 if (getOptions().css3 && getOptions().autoScrolling && !getOptions().scrollBar) { 1522 var translate3d = 'translate3d(0px, -' + roundedTop + 'px, 0px)'; 1523 transformContainer(translate3d, false); 1524 } else if (getOptions().autoScrolling && !getOptions().scrollBar) { 1525 css(getContainer(), { 1526 'top': -roundedTop + 'px' 1527 }); 1528 FP.test.top = -roundedTop + 'px'; 1529 } else { 1530 var scrollSettings = getScrollSettings(roundedTop); 1531 setScrolling(scrollSettings.element, scrollSettings.options); 1532 } 1533 } 1534 1535 FP.setScrollingSpeed = setScrollingSpeed; 1536 /** 1537 * Defines the scrolling speed 1538 */ 1539 1540 function setScrollingSpeed(value, type) { 1541 setVariableState('scrollingSpeed', value, type); 1542 } 1543 1544 var $body = null; 1545 var $html = null; 1546 var $htmlBody = null; // caching common elements 1547 1548 function setCache() { 1549 $body = $('body')[0]; 1550 $html = $('html')[0]; 1551 $htmlBody = $('html, body'); 1552 } 1553 1554 //@ts-check 1555 1556 var _g_animateScroll; 1557 /** 1558 * Simulates the animated scrollTop of jQuery. Used when css3:false or scrollBar:true or autoScrolling:false 1559 * http://stackoverflow.com/a/16136789/1081396 1560 */ 1561 1562 1563 function scrollTo(element, to, duration, callback) { 1564 var start = getScrolledPosition(element); 1565 var change = to - start; 1566 var isCallbackFired = false; 1567 var startTime; 1568 var wasAnimationActive = state.activeAnimation; 1569 setState({ 1570 activeAnimation: true 1571 }); // Cancelling any possible previous animations (io: clicking on nav dots very fast) 1572 1573 if (_g_animateScroll) { 1574 window.cancelAnimationFrame(_g_animateScroll); 1575 } 1576 1577 _g_animateScroll = function g_animateScroll(timestamp) { 1578 if (!startTime) { 1579 startTime = timestamp; 1580 } 1581 1582 var currentTime = Math.floor(timestamp - startTime); 1583 1584 if (state.activeAnimation) { 1585 //in order to stope it from other function whenever we want 1586 var val = to; 1587 1588 if (duration) { 1589 // @ts-ignore 1590 val = win.fp_easings[getOptions().easing](currentTime, start, change, duration); 1591 } 1592 1593 if (currentTime <= duration) { 1594 setScrolling(element, val); 1595 } 1596 1597 if (currentTime < duration) { 1598 window.requestAnimationFrame(_g_animateScroll); 1599 } else if (typeof callback !== 'undefined' && !isCallbackFired) { 1600 setScrolling(element, to); 1601 callback(); 1602 setState({ 1603 activeAnimation: false 1604 }); 1605 isCallbackFired = true; 1606 } 1607 } else if (!isCallbackFired && !wasAnimationActive) { 1608 callback(); 1609 setState({ 1610 activeAnimation: false 1611 }); 1612 isCallbackFired = true; 1613 } 1614 }; 1615 1616 window.requestAnimationFrame(_g_animateScroll); 1617 } 1618 /** 1619 * Getting the position of the element to scroll when using jQuery animations 1620 */ 1621 1622 function getScrolledPosition(element) { 1623 var position; //is not the window element and is a slide? 1624 1625 if (element.self != win && hasClass(element, SLIDES_WRAPPER)) { 1626 position = element.scrollLeft; 1627 } else if (!getOptions().autoScrolling || getOptions().scrollBar) { 1628 position = getScrollTop(); 1629 } else { 1630 position = element.offsetTop; 1631 } //gets the top property of the wrapper 1632 1633 1634 return position; 1635 } 1636 1637 /** 1638 * Makes sure to only create a Panel object if the element exist 1639 */ 1640 1641 function nullOrSection(el) { 1642 if (el && !el.item) { 1643 return new Section(new SectionPanel(el)); 1644 } 1645 1646 return el ? new Section(el) : null; 1647 } 1648 1649 function nullOrSlide(el) { 1650 return el ? new Slide(el) : null; 1651 } 1652 1653 /** 1654 * Dispatch events & callbacks 1655 */ 1656 1657 function fireCallback(eventName, v) { 1658 var eventData = getEventData(eventName, v); 1659 trigger(getContainer(), eventName, eventData); 1660 1661 if (getOptions()[eventName].apply(eventData[Object.keys(eventData)[0]], toArray(eventData)) === false) { 1662 return false; 1663 } 1664 1665 return true; 1666 } 1667 /** 1668 * Gets the event's data for the given event on the right format. 1669 */ 1670 1671 function getEventData(eventName, v) { 1672 //using functions to run only the necessary bits within the object 1673 var paramsPerEvent = { 1674 afterRender: function afterRender() { 1675 return { 1676 section: nullOrSection(getState().activeSection), 1677 slide: nullOrSlide(getState().activeSection.activeSlide) 1678 }; 1679 }, 1680 onLeave: function onLeave() { 1681 return { 1682 origin: nullOrSection(v.items.origin), 1683 destination: nullOrSection(v.items.destination), 1684 direction: v.direction, 1685 trigger: getState().scrollTrigger 1686 }; 1687 }, 1688 afterLoad: function afterLoad() { 1689 return paramsPerEvent.onLeave(); 1690 }, 1691 afterSlideLoad: function afterSlideLoad() { 1692 return { 1693 section: nullOrSection(v.items.section), 1694 origin: nullOrSection(v.items.origin), 1695 destination: nullOrSection(v.items.destination), 1696 direction: v.direction, 1697 trigger: getState().scrollTrigger 1698 }; 1699 }, 1700 onSlideLeave: function onSlideLeave() { 1701 return paramsPerEvent.afterSlideLoad(); 1702 }, 1703 beforeLeave: function beforeLeave() { 1704 return paramsPerEvent.onLeave(); 1705 }, 1706 onScrollOverflow: function onScrollOverflow() { 1707 return { 1708 section: nullOrSection(getState().activeSection), 1709 slide: nullOrSlide(getState().activeSection.activeSlide), 1710 position: v.position, 1711 direction: v.direction 1712 }; 1713 } 1714 }; 1715 return paramsPerEvent[eventName](); 1716 } 1717 1718 function hasAutoPlay(item) { 1719 return item.hasAttribute('data-autoplay') || item.hasAttribute('autoplay'); 1720 } 1721 /** 1722 * Plays video and audio elements. 1723 */ 1724 1725 1726 function playMedia(destiny) { 1727 var panel = getSlideOrSection(destiny); //playing HTML5 media elements 1728 1729 $('video, audio', panel).forEach(function (element) { 1730 if (hasAutoPlay(element) && typeof element.play === 'function') { 1731 element.play(); 1732 } 1733 }); //youtube videos 1734 1735 $('iframe[src*="youtube.com/embed/"]', panel).forEach(function (element) { 1736 if (hasAutoPlay(element)) { 1737 playYoutube(element); 1738 } //in case the URL was not loaded yet. On page load we need time for the new URL (with the API string) to load. 1739 1740 1741 element.onload = function () { 1742 if (hasAutoPlay(element)) { 1743 playYoutube(element); 1744 } 1745 }; 1746 }); 1747 } 1748 /** 1749 * Plays a youtube video 1750 */ 1751 1752 function playYoutube(element) { 1753 element.contentWindow.postMessage('{"event":"command","func":"playVideo","args":""}', '*'); 1754 } 1755 /** 1756 * Stops video and audio elements. 1757 */ 1758 1759 1760 function stopMedia(destiny) { 1761 var panel = getSlideOrSection(destiny); //stopping HTML5 media elements 1762 1763 $('video, audio', panel).forEach(function (element) { 1764 if (!element.hasAttribute('data-keepplaying') && typeof element.pause === 'function') { 1765 element.pause(); 1766 } 1767 }); //youtube videos 1768 1769 $('iframe[src*="youtube.com/embed/"]', panel).forEach(function (element) { 1770 if (/youtube\.com\/embed\//.test(getAttr(element, 'src')) && !element.hasAttribute('data-keepplaying')) { 1771 element.contentWindow.postMessage('{"event":"command","func":"pauseVideo","args":""}', '*'); 1772 } 1773 }); 1774 } 1775 /* 1776 * Enables the Youtube videos API so we can control their flow if necessary. 1777 */ 1778 1779 function enableYoutubeAPI() { 1780 $('iframe[src*="youtube.com/embed/"]', getContainer()).forEach(function (item) { 1781 addURLParam(item, 'enablejsapi=1'); 1782 }); 1783 } 1784 /** 1785 * Adds a new parameter and its value to the `src` of a given element 1786 */ 1787 1788 function addURLParam(element, newParam) { 1789 var originalSrc = getAttr(element, 'src'); 1790 element.setAttribute('src', originalSrc + getUrlParamSign(originalSrc) + newParam); 1791 } 1792 /* 1793 * Returns the prefix sign to use for a new parameter in an existen URL. 1794 * 1795 * @return {String} ? | & 1796 */ 1797 1798 1799 function getUrlParamSign(url) { 1800 return !/\?/.test(url) ? '?' : '&'; 1801 } 1802 1803 /** 1804 * Lazy loads image, video and audio elements. 1805 */ 1806 1807 function lazyLoad(destiny) { 1808 if (!getOptions().lazyLoading) { 1809 return; 1810 } 1811 1812 var panel = getSlideOrSection(destiny); 1813 $('img[data-src], img[data-srcset], source[data-src], source[data-srcset], video[data-src], audio[data-src], iframe[data-src]', panel).forEach(function (element) { 1814 ['src', 'srcset'].forEach(function (type) { 1815 var attribute = getAttr(element, 'data-' + type); 1816 1817 if (attribute != null && attribute) { 1818 setSrc(element, type); 1819 element.addEventListener('load', function () { 1820 }); 1821 } 1822 }); 1823 1824 if (matches(element, 'source')) { 1825 var elementToPlay = closest(element, 'video, audio'); 1826 1827 if (elementToPlay) { 1828 elementToPlay.load(); 1829 1830 elementToPlay.onloadeddata = function () { 1831 }; 1832 } 1833 } 1834 }); // Add fp-loaded class to the panel after lazy loading 1835 1836 addClass(panel, LOADED); 1837 } 1838 function lazyLoadPanels(panel) { 1839 var lazyLoadThresold = getOptions().lazyLoadThreshold; 1840 lazyLoad(panel.item); 1841 1842 if (lazyLoadThresold) { 1843 lazyLoadDirection(panel, 'prev', lazyLoadThresold); 1844 lazyLoadDirection(panel, 'next', lazyLoadThresold); 1845 } 1846 } // Lazy load "count" number of panels in a specific direction 1847 1848 function lazyLoadDirection(startPanel, direction, count) { 1849 var currentPanel = startPanel; 1850 1851 for (var i = 0; i < count && (currentPanel = currentPanel[direction]()); i++) { 1852
1852console.log(currentPanel.item); 1853 lazyLoad(currentPanel.item); 1854 } 1855 } 1856 1857 /** 1858 * Sets a class for the body of the page depending on the active section / slide 1859 */ 1860 1861 function setBodyClass() { 1862 var section = getState().activeSection.item; 1863 var slide = getState().activeSection.activeSlide; 1864 var sectionAnchor = getAnchor(section); 1865 var text = String(sectionAnchor); 1866 1867 if (slide) { 1868 var slideAnchor = getAnchor(slide.item); 1869 text = text + '-' + slideAnchor; 1870 } //changing slash for dash to make it a valid CSS style 1871 1872 1873 text = text.replace('/', '-').replace('#', '').replace(/\s/g, ''); //removing previous anchor classes 1874 1875 var classRe = new RegExp('\\b\\s?' + VIEWING_PREFIX + '-[^\\s]+\\b', "g"); 1876 $body.className = $body.className.replace(classRe, ''); //adding the current anchor 1877 1878 addClass($body, VIEWING_PREFIX + '-' + text); 1879 } 1880 /** 1881 * Gets the anchor for the given slide / section. Its index will be used if there's none. 1882 */ 1883 1884 function getAnchor(element) { 1885 if (!element) { 1886 return null; 1887 } 1888 1889 var anchor = getAttr(element, 'data-anchor'); 1890 var elementIndex = index(element); //Slide without anchor link? We take the index instead. 1891 1892 if (anchor == null) { 1893 anchor = elementIndex; 1894 } 1895 1896 return anchor; 1897 } 1898 1899 /** 1900 * Sets the state of the website depending on the active section/slide. 1901 * It changes the URL hash when needed and updates the body class. 1902 */ 1903 1904 function setPageStatus(slideIndex, slideAnchor, anchorLink) { 1905 var sectionHash = ''; 1906 1907 if (getOptions().anchors.length && !getOptions().lockAnchors) { 1908 //isn't it the first slide? 1909 if (slideIndex) { 1910 if (anchorLink != null) { 1911 sectionHash = anchorLink; 1912 } //slide without anchor link? We take the index instead. 1913 1914 1915 if (slideAnchor == null) { 1916 slideAnchor = slideIndex; 1917 } 1918 1919 setState({ 1920 lastScrolledSlide: slideAnchor 1921 }); 1922 setUrlHash(sectionHash + '/' + slideAnchor); //first slide won't have slide anchor, just the section one 1923 } else if (slideIndex != null) { 1924 setState({ 1925 lastScrolledSlide: slideAnchor 1926 }); 1927 setUrlHash(anchorLink); 1928 } //section without slides 1929 else { 1930 setUrlHash(anchorLink); 1931 } 1932 } 1933 1934 setBodyClass(); 1935 } 1936 /** 1937 * Sets the URL hash. 1938 */ 1939 1940 function setUrlHash(url) { 1941 if (getOptions().recordHistory) { 1942 location.hash = url; 1943 } else { 1944 //Mobile Chrome doesn't work the normal way, so... lets use HTML5 for phones :) 1945 if (isTouchDevice || isTouch) { 1946 win.history.replaceState(undefined, undefined, '#' + url); 1947 } else { 1948 var baseUrl = win.location.href.split('#')[0]; 1949 win.location.replace(baseUrl + '#' + url); 1950 } 1951 } 1952 } 1953 1954 /**
vendor: 6,690 bytes, lines 1955-2152
1955 * Gets the name for screen readers for a section/slide navigation bullet. 1956 */ 1957 1958 function getBulletLinkName(i, defaultName, item) { 1959 var anchor = defaultName === 'Section' ? getOptions().anchors[i] : getAttr(item, 'data-anchor'); 1960 return encodeURI(getOptions().navigationTooltips[i] || anchor || defaultName + ' ' + (i + 1)); 1961 } 1962 1963 function slideBulletHandler(e) { 1964 // not all events are cancellable 1965 // https://www.uriports.com/blog/easy-fix-for-intervention-ignored-attempt-to-cancel-a-touchmove-event-with-cancelable-false/ 1966 if (e.cancelable) { 1967 preventDefault(e); 1968 } 1969 1970 setState({ 1971 scrollTrigger: 'horizontalNav' 1972 }); 1973 /*jshint validthis:true */ 1974 1975 var sectionElem = closest(this, SECTION_SEL); 1976 var slides = $(SLIDES_WRAPPER_SEL, closest(this, SECTION_SEL))[0]; 1977 var section = getPanelByElement(getState().sections, sectionElem); 1978 var destiny = section.slides[index(closest(this, 'li'))]; 1979 EventEmitter.emit(events.landscapeScroll, { 1980 slides: slides, 1981 destination: destiny.item 1982 }); 1983 } 1984 /** 1985 * Sets the state for the horizontal bullet navigations. 1986 */ 1987 1988 function activeSlidesNavigation(slidesNav, slideIndex) { 1989 if (getOptions().slidesNavigation && slidesNav != null) { 1990 removeClass($(ACTIVE_SEL, slidesNav), ACTIVE); 1991 addClass($('a', $('li', slidesNav)[slideIndex]), ACTIVE); 1992 } 1993 } 1994 /** 1995 * Creates a landscape navigation bar with dots for horizontal sliders. 1996 */ 1997 1998 function addSlidesNavigation(section) { 1999 var sectionElem = section.item; 2000 var numSlides = section.slides.length; 2001 appendTo(createElementFromHTML('<div class="' + SLIDES_NAV + '"><ul></ul></div>'), sectionElem); 2002 var nav = $(SLIDES_NAV_SEL, sectionElem)[0]; //top or bottom 2003 2004 addClass(nav, 'fp-' + getOptions().slidesNavPosition); 2005 2006 for (var i = 0; i < numSlides; i++) { 2007 var slide = $(SLIDE_SEL, sectionElem)[i]; 2008 appendTo(createElementFromHTML('<li><a href="#"><span class="fp-sr-only">' + getBulletLinkName(i, 'Slide', slide) + '</span><span></span></a></li>'), $('ul', nav)[0]); 2009 } //centering it 2010 2011 2012 css(nav, { 2013 'margin-left': '-' + nav.innerWidth / 2 + 'px' 2014 }); 2015 var activeSlideIndex = section.activeSlide ? section.activeSlide.index() : 0; 2016 addClass($('a', $('li', nav)[activeSlideIndex]), ACTIVE); 2017 } 2018 2019 var isScrollAllowed = {}; 2020 isScrollAllowed.m = { 2021 'up': true, 2022 'down': true, 2023 'left': true, 2024 'right': true 2025 }; 2026 isScrollAllowed.k = deepExtend({}, isScrollAllowed.m); 2027 /** 2028 * Allowing or disallowing the mouse/swipe scroll in a given direction. (not for keyboard) 2029 * @param type m (mouse) or k (keyboard) 2030 */ 2031 2032 function setIsScrollAllowed(value, direction, type) { 2033 //up, down, left, right 2034 if (direction !== 'all') { 2035 isScrollAllowed[type][direction] = value; 2036 } //all directions? 2037 else { 2038 Object.keys(isScrollAllowed[type]).forEach(function (key) { 2039 isScrollAllowed[type][key] = value; 2040 }); 2041 } 2042 } 2043 function getIsScrollAllowed() { 2044 return isScrollAllowed; 2045 } 2046 2047 EventEmitter.on(events.onClickOrTouch, onClickOrTouch$2); 2048 2049 function onClickOrTouch$2(params) { 2050 var target = params.target; 2051 2052 if (matches(target, SLIDES_ARROW_SEL) || closest(target, SLIDES_ARROW_SEL)) { 2053 slideArrowHandler.call(target, params); 2054 } 2055 } //Scrolling horizontally when clicking on the slider controls. 2056 2057 2058 function slideArrowHandler() { 2059 /*jshint validthis:true */ 2060 var section = closest(this, SECTION_SEL); 2061 var isPrevArrow = hasClass(this, SLIDES_PREV) || closest(this, SLIDES_PREV); 2062 /*jshint validthis:true */ 2063 2064 if (isPrevArrow) { 2065 if (getIsScrollAllowed().m.left) { 2066 setState({ 2067 scrollTrigger: 'slideArrow' 2068 }); 2069 EventEmitter.emit(events.moveSlideLeft, { 2070 section: section 2071 }); 2072 } 2073 } else { 2074 if (getIsScrollAllowed().m.right) { 2075 setState({ 2076 scrollTrigger: 'slideArrow' 2077 }); 2078 EventEmitter.emit(events.moveSlideRight, { 2079 section: section 2080 }); 2081 } 2082 } 2083 } 2084 /** 2085 * Creates the control arrows for the given section 2086 */ 2087 2088 2089 function createSlideArrows(section) { 2090 var sectionElem = section.item; 2091 var arrows = [createElementFromHTML(getOptions().controlArrowsHTML[0]), createElementFromHTML(getOptions().controlArrowsHTML[1])]; 2092 after($(SLIDES_WRAPPER_SEL, sectionElem)[0], arrows); 2093 addClass(arrows, SLIDES_ARROW); 2094 addClass(arrows[0], SLIDES_PREV); 2095 addClass(arrows[1], SLIDES_NEXT); 2096 2097 if (getOptions().controlArrowColor !== '#fff') { 2098 css($(SLIDES_ARROW_NEXT_SEL, sectionElem), { 2099 'border-color': 'transparent transparent transparent ' + getOptions().controlArrowColor 2100 }); 2101 css($(SLIDES_ARROW_PREV_SEL, sectionElem), { 2102 'border-color': 'transparent ' + getOptions().controlArrowColor + ' transparent transparent' 2103 }); 2104 } 2105 2106 if (!getOptions().loopHorizontal) { 2107 hide($(SLIDES_ARROW_PREV_SEL, sectionElem)); 2108 } 2109 } 2110 function toggleControlArrows(v) { 2111 if (!getOptions().loopHorizontal && getOptions().controlArrows) { 2112 //hidding it for the fist slide, showing for the rest 2113 toggle($(SLIDES_ARROW_PREV_SEL, v.section), v.slideIndex !== 0); //hidding it for the last slide, showing for the rest 2114 2115 toggle($(SLIDES_ARROW_NEXT_SEL, v.section), next(v.destiny) != null); 2116 } 2117 } 2118 2119 FP.setRecordHistory = setRecordHistory; 2120 /** 2121 * Defines wheter to record the history for each hash change in the URL. 2122 */ 2123 2124 function setRecordHistory(value, type) { 2125 setVariableState('recordHistory', value, type); 2126 } 2127 2128 FP.setAutoScrolling = setAutoScrolling; 2129 FP.test.setAutoScrolling = setAutoScrolling; 2130 /** 2131 * Sets the autoScroll option. 2132 * It changes the scroll bar visibility and the history of the site as a result. 2133 */ 2134 2135 function setAutoScrolling(value, type) { 2136 //removing the transformation 2137 if (!value) { 2138 silentScroll(0); 2139 } 2140 2141 setVariableState('autoScrolling', value, type); 2142 var element = getState().activeSection.item; 2143 2144 if (getOptions().autoScrolling && !getOptions().scrollBar) { 2145 css($htmlBody, { 2146 'overflow': 'hidden', 2147 'height': '100%' 2148 }); 2149 removeClass($body, SCROLLABLE); 2150 setRecordHistory(getOriginals().recordHistory, 'internal'); //for IE touch devices 2151 2152 css(getContainer(), {
2153 '-ms-touch-action': 'none', 2154 'touch-action': 'none' 2155 }); 2156 2157 if (element != null) { 2158 //moving the container up 2159 silentScroll(element.offsetTop); 2160 } 2161 } else { 2162 css($htmlBody, { 2163 'overflow': 'visible', 2164 'height': 'initial' 2165 }); 2166 addClass($body, SCROLLABLE); 2167 var recordHistory = !getOptions().autoScrolling ? false : getOriginals().recordHistory; 2168 setRecordHistory(recordHistory, 'internal'); //for IE touch devices 2169 2170 css(getContainer(), { 2171 '-ms-touch-action': '', 2172 'touch-action': '' 2173 }); //scrolling the page to the section with no animation 2174 2175 if (element != null) { 2176 var scrollSettings = getScrollSettings(element.offsetTop); 2177 scrollSettings.element.scrollTo(0, scrollSettings.options); 2178 } 2179 } 2180 } 2181 2182 //@ts-check 2183 /** 2184 * Adds sections before or after the current one to create the infinite effect. 2185 */ 2186 2187 function createInfiniteSections(v) { 2188 setState({ 2189 isDoingContinousVertical: true 2190 }); 2191 var activeSectionItem = getState().activeSection.item; // Scrolling down 2192 2193 if (!v.isMovementUp) { 2194 // Move all previous sections to after the active section 2195 after(activeSectionItem, prevAll(activeSectionItem, SECTION_SEL).reverse()); 2196 } else { 2197 // Scrolling up 2198 // Move all next sections to before the active section 2199 before(activeSectionItem, nextAll(activeSectionItem, SECTION_SEL)); 2200 } // Maintain the displayed position (now that we changed the element order) 2201 2202 2203 silentScroll(getState().activeSection.item.offsetTop); // Maintain the active slides visible in the viewport 2204 2205 keepSlidesPosition$1(); // save for later the elements that still need to be reordered 2206 2207 v.wrapAroundElements = activeSectionItem; // Recalculate animation variables 2208 2209 v.dtop = v.element.offsetTop; 2210 v.yMovement = getYmovement(getState().activeSection, v.element); 2211 return v; 2212 } 2213 /** 2214 * Maintains the active slides in the viewport 2215 * (Because the `scroll` animation might get lost with some actions, such as when using continuousVertical) 2216 */ 2217 2218 function keepSlidesPosition$1() { 2219 var activeSlides = $(SLIDE_ACTIVE_SEL); 2220 2221 for (var i = 0; i < activeSlides.length; i++) { 2222 silentLandscapeScroll(activeSlides[i], 'internal'); 2223 } 2224 } 2225 2226 //@ts-check 2227 /** 2228 * Maintains the active slides in the viewport 2229 * (Because the `scroll` animation might get lost with some actions, such as when using continuousVertical) 2230 */ 2231 2232 function keepSlidesPosition() { 2233 var activeSlides = $(SLIDE_ACTIVE_SEL); 2234 2235 for (var i = 0; i < activeSlides.length; i++) { 2236 silentLandscapeScroll(activeSlides[i], 'internal'); 2237 } 2238 } 2239 /** 2240 * Fix section order after continuousVertical changes have been animated 2241 */ 2242 2243 2244 function continuousVerticalFixSectionOrder(v) { 2245 // If continuousVertical is in effect (and autoScrolling would also be in effect then), 2246 // finish moving the elements around so the direct navigation will function more simply 2247 if (v.wrapAroundElements == null) { 2248 return; 2249 } 2250 2251 if (v.isMovementUp) { 2252 before($(SECTION_SEL)[0], v.wrapAroundElements); 2253 } else { 2254 after($(SECTION_SEL)[getState().sections.length - 1], v.wrapAroundElements); 2255 } 2256 2257 silentScroll(getState().activeSection.item.offsetTop); // Maintain the active slides visible in the viewport 2258 2259 keepSlidesPosition(); 2260 setState({ 2261 isDoingContinousVertical: false 2262 }); 2263 } 2264 2265 /** 2266 * Makes sure lazyload is done for other sections in the viewport that are not the 2267 * active one. 2268 */ 2269 2270 function lazyLoadOthers() { 2271 var hasAutoHeightSections = $(AUTO_HEIGHT_SEL)[0] || isResponsiveMode() && $(AUTO_HEIGHT_RESPONSIVE_SEL)[0]; //quitting when it doesn't apply 2272 2273 if (!getOptions().lazyLoading || !hasAutoHeightSections) { 2274 return; 2275 } //making sure to lazy load auto-height sections that are in the viewport 2276 2277 2278 $(SECTION_SEL + ':not(' + ACTIVE_SEL + ')').forEach(function (section) { 2279 if (isSectionInViewport(section)) { 2280 lazyLoadPanels(getPanelByElement(getState().sections, section)); 2281 } 2282 }); 2283 } 2284 /** 2285 * Determines whether a section is in the viewport or not. 2286 */ 2287 2288 function isSectionInViewport(el) { 2289 var rect = el.getBoundingClientRect(); 2290 var top = rect.top; 2291 var bottom = rect.bottom; //sometimes there's a 1px offset on the bottom of the screen even when the 2292 //section's height is the window.innerHeight one. I guess because pixels won't allow decimals. 2293 //using this prevents from lazyLoading the section that is not yet visible 2294 //(only 1 pixel offset is) 2295 2296 var pixelOffset = 2; 2297 var isTopInView = top + pixelOffset < state.windowsHeight && top > 0; 2298 var isBottomInView = bottom > pixelOffset && bottom < state.windowsHeight; 2299 return isTopInView || isBottomInView; 2300 } 2301 2302 function tooltipTextHandler() { 2303 /*jshint validthis:true */ 2304 trigger(prev(this), 'click'); 2305 } 2306 /** 2307 * Activating the vertical navigation bullets according to the given slide name. 2308 */ 2309 2310 function activateNavDots(name, sectionIndex) { 2311 var nav = $(SECTION_NAV_SEL)[0]; 2312 2313 if (getOptions().navigation && nav != null && nav.style.display !== 'none') { 2314 removeClass($(ACTIVE_SEL, nav), ACTIVE); 2315 2316 if (name) {
vendor: 9,581 bytes, lines 2317-2603
2317 addClass($('a[href="#' + name + '"]', nav), ACTIVE); 2318 } else { 2319 addClass($('a', $('li', nav)[sectionIndex]), ACTIVE); 2320 } 2321 } 2322 } 2323 /** 2324 * Creates a vertical navigation bar. 2325 */ 2326 2327 function addVerticalNavigation() { 2328 remove($(SECTION_NAV_SEL)); 2329 var navigation = doc.createElement('div'); 2330 navigation.setAttribute('id', SECTION_NAV); 2331 var divUl = doc.createElement('ul'); 2332 navigation.appendChild(divUl); 2333 appendTo(navigation, $body); 2334 var nav = $(SECTION_NAV_SEL)[0]; 2335 addClass(nav, 'fp-' + getOptions().navigationPosition); 2336 2337 if (getOptions().showActiveTooltip) { 2338 addClass(nav, SHOW_ACTIVE_TOOLTIP); 2339 } 2340 2341 var li = ''; 2342 2343 for (var i = 0; i < getState().sections.length; i++) { 2344 var section = getState().sections[i]; 2345 var link = ''; 2346 2347 if (getOptions().anchors.length) { 2348 link = section.anchor; 2349 } 2350 2351 li += '<li><a href="#' + encodeURI(link) + '"><span class="fp-sr-only">' + getBulletLinkName(section.index(), 'Section') + '</span><span></span></a>'; // Only add tooltip if needed (defined by user) 2352 2353 var tooltip = getOptions().navigationTooltips[section.index()]; 2354 2355 if (typeof tooltip !== 'undefined' && tooltip !== '') { 2356 li += '<div class="' + SECTION_NAV_TOOLTIP + ' fp-' + getOptions().navigationPosition + '">' + tooltip + '</div>'; 2357 } 2358 2359 li += '</li>'; 2360 } 2361 2362 $('ul', nav)[0].innerHTML = li; //activating the current active section 2363 2364 var bullet = $('li', $(SECTION_NAV_SEL)[0])[getState().activeSection.index()]; 2365 addClass($('a', bullet), ACTIVE); 2366 } //Scrolls to the section when clicking the navigation bullet 2367 2368 function sectionBulletHandler(e) { 2369 if (e.preventDefault) { 2370 preventDefault(e); 2371 } 2372 2373 setState({ 2374 scrollTrigger: 'verticalNav' 2375 }); 2376 /*jshint validthis:true */ 2377 // @ts-ignore 2378 2379 var indexBullet = index(closest(this, SECTION_NAV_SEL + ' li')); 2380 EventEmitter.emit(events.scrollPage, { 2381 destination: getState().sections[indexBullet] 2382 }); 2383 } 2384 2385 /** 2386 * Sets to active the current menu and vertical nav items. 2387 */ 2388 2389 function activateMenuAndNav(anchor, index) { 2390 activateMenuElement(anchor); 2391 activateNavDots(anchor, index); 2392 } 2393 /** 2394 * Activating the website main menu elements according to the given slide name. 2395 */ 2396 2397 function activateMenuElement(name) { 2398 if (getOptions().menu && getOptions().menu.length) { 2399 $(getOptions().menu).forEach(function (menu) { 2400 if (menu != null) { 2401 removeClass($(ACTIVE_SEL, menu), ACTIVE); 2402 addClass($('[data-menuanchor="' + name + '"]', menu), ACTIVE); 2403 } 2404 }); 2405 } 2406 } 2407 2408 new Date().getTime(); 2409 /** 2410 * Triggers the callback once per scroll wheel action. 2411 * Based on scrolling speed delay. 2412 */ 2413 2414 var oncePerScroll = function () { 2415 var canTriggerEvent = true; 2416 var prevWheelTime = new Date().getTime(); 2417 var result; 2418 var isScrollingOnInit = !win.fullpage_api; 2419 return function (scrollTrigger, callback) { 2420 var currentTime = new Date().getTime(); 2421 var timeThreshold = scrollTrigger === 'wheel' ? getOptions().scrollingSpeed : 100; 2422 canTriggerEvent = isScrollingOnInit || currentTime - prevWheelTime >= timeThreshold; 2423 isScrollingOnInit = !win.fullpage_api; 2424 2425 if (canTriggerEvent) { 2426 result = callback(); 2427 prevWheelTime = currentTime; 2428 } 2429 2430 return typeof result !== 'undefined' ? result : true; 2431 }; 2432 }(); 2433 2434 /** 2435 * Fires the wheel event once per mouse wheel trigger. 2436 */ 2437 2438 function fireCallbackOncePerScroll(callbackName, params) { 2439 if (!isFunction(getOptions().beforeLeave)) { 2440 return; 2441 } 2442 2443 var result = oncePerScroll(getState().scrollTrigger, function () { 2444 return fireCallback(callbackName, params); 2445 }); 2446 return result; 2447 } 2448 2449 FP.moveTo = moveTo; 2450 2451 FP.getScrollY = function () { 2452 return state.scrollY; 2453 }; 2454 2455 var g_afterSectionLoadsId; 2456 var g_transitionLapseId; 2457 EventEmitter.on(events.onDestroy, onDestroy$8); 2458 /** 2459 * Scrolls the site to the given element and scrolls to the slide if a callback is given. 2460 */ 2461 2462 function scrollPage(section, callback, isMovementUp) { 2463 var element = section.item; 2464 2465 if (element == null) { 2466 return; 2467 } //there's no element to scroll, leaving the function 2468 2469 2470 var dtop = getDestinationPosition(element); 2471 var slideAnchorLink; 2472 var slideIndex; //local variables 2473 2474 var v = { 2475 "element": element, 2476 "callback": callback, 2477 "isMovementUp": isMovementUp, 2478 "dtop": dtop, 2479 "yMovement": getYmovement(getState().activeSection, element), 2480 "anchorLink": section.anchor, 2481 "sectionIndex": section.index(), 2482 "activeSlide": section.activeSlide ? section.activeSlide.item : null, 2483 "leavingSection": getState().activeSection.index() + 1, 2484 //caching the value of isResizing at the momment the function is called 2485 //because it will be checked later inside a setTimeout and the value might change 2486 "localIsResizing": state.isResizing, 2487 "items": { 2488 "origin": getState().activeSection, 2489 "destination": section 2490 }, 2491 "direction": null 2492 }; //quiting when destination scroll is the same as the current one 2493 2494 if (getState().activeSection.item == element && !state.isResizing || getOptions().scrollBar && getScrollTop() === v.dtop && !hasClass(element, AUTO_HEIGHT)) { 2495 return; 2496 } 2497 2498 if (v.activeSlide != null) { 2499 slideAnchorLink = getAttr(v.activeSlide, 'data-anchor'); 2500 slideIndex = index(v.activeSlide, null); 2501 } //callback (onLeave) if the site is not just resizing and readjusting the slides 2502 2503 2504 if (!v.localIsResizing) { 2505 var direction = v.yMovement; //required for continousVertical 2506 2507 if (typeof isMovementUp !== 'undefined') { 2508 direction = isMovementUp ? 'up' : 'down'; 2509 } //for the callback 2510 2511 2512 v.direction = direction; 2513 2514 if (isFunction(getOptions().beforeLeave)) { 2515 if (fireCallbackOncePerScroll('beforeLeave', v) === false) { 2516 return; 2517 } 2518 } 2519 2520 if (isFunction(getOptions().onLeave)) { 2521 if (!fireCallback('onLeave', v)) { 2522 return; 2523 } 2524 } 2525 } // If continuousVertical && we need to wrap around 2526 2527 2528 if (getOptions().autoScrolling && getOptions().continuousVertical && typeof v.isMovementUp !== "undefined" && (!v.isMovementUp && v.yMovement == 'up' || // Intending to scroll down but about to go up or 2529 v.isMovementUp && v.yMovement == 'down')) { 2530 // intending to scroll up but about to go down 2531 v = createInfiniteSections(v); 2532 } //pausing media of the leaving section (if we are not just resizing, as destinatino will be the same one) 2533 2534 2535 if (!v.localIsResizing) { 2536 stopMedia(getState().activeSection.item); 2537 } 2538 2539 addClass(element, ACTIVE); 2540 removeClass(siblings(element), ACTIVE); 2541 updateState(); 2542 lazyLoadPanels(section); //preventing from activating the MouseWheelHandler event 2543 //more than once if the page is scrolling 2544 2545 setState({ 2546 canScroll: FP.test.isTesting 2547 }); 2548 setPageStatus(slideIndex, slideAnchorLink, v.anchorLink); 2549 EventEmitter.emit(events.onLeave, v); 2550 performMovement(v); //flag to avoid callingn `scrollPage()` twice in case of using anchor links 2551 2552 setState({ 2553 lastScrolledDestiny: v.anchorLink 2554 }); //avoid firing it twice (as it does also on scroll) 2555 2556 activateMenuAndNav(v.anchorLink, v.sectionIndex); 2557 } 2558 2559 function onDestroy$8() { 2560 clearTimeout(g_afterSectionLoadsId); 2561 clearTimeout(g_transitionLapseId); 2562 } 2563 /** 2564 * Returns the destination Y position based on the scrolling direction and 2565 * the height of the section. 2566 */ 2567 2568 2569 function getDestinationPosition(element) { 2570 var elementHeight = element.offsetHeight; 2571 var elementTop = element.offsetTop; //top of the desination will be at the top of the viewport 2572 2573 var position = elementTop; 2574 var isScrollingDown = elementTop > state.previousDestTop; 2575 var sectionBottom = position - getWindowHeight() + elementHeight; 2576 var bigSectionsDestination = getOptions().bigSectionsDestination; //is the destination element bigger than the viewport? 2577 2578 if (elementHeight > getWindowHeight()) { 2579 //scrolling up? 2580 if (!isScrollingDown && !bigSectionsDestination || bigSectionsDestination === 'bottom') { 2581 position = sectionBottom; 2582 } 2583 } //sections equal or smaller than the viewport height && scrolling down? || is resizing and its in the last section 2584 else if (isScrollingDown || state.isResizing && next(element) == null) { 2585 //The bottom of the destination will be at the bottom of the viewport 2586 position = sectionBottom; 2587 } 2588 /* 2589 Keeping record of the last scrolled position to determine the scrolling direction. 2590 No conventional methods can be used as the scroll bar might not be present 2591 AND the section might not be active if it is auto-height and didnt reach the middle 2592 of the viewport. 2593 */ 2594 2595 2596 setState({ 2597 previousDestTop: position 2598 }); 2599 return position; 2600 } 2601 /** 2602 * Performs the vertical movement (by CSS3 or by jQuery) 2603 */
vendor: 13,974 bytes, lines 2604-3009
2604 2605 2606 function performMovement(v) { 2607 setState({ 2608 touchDirection: 'none', 2609 scrollY: Math.round(v.dtop) 2610 }); 2611 EventEmitter.emit(events.onPerformMovement, v); 2612 var isFastSpeed = getOptions().scrollingSpeed < 700; 2613 var transitionLapse = isFastSpeed ? 700 : getOptions().scrollingSpeed; // using CSS3 translate functionality 2614 2615 if (getOptions().css3 && getOptions().autoScrolling && !getOptions().scrollBar) { 2616 // The first section can have a negative value in iOS 10. Not quite sure why: -0.0142822265625 2617 // that's why we round it to 0. 2618 var translate3d = 'translate3d(0px, -' + Math.round(v.dtop) + 'px, 0px)'; 2619 transformContainer(translate3d, true); //even when the scrollingSpeed is 0 there's a little delay, which might cause the 2620 //scrollingSpeed to change in case of using silentMoveTo();ç 2621 2622 if (getOptions().scrollingSpeed) { 2623 clearTimeout(g_afterSectionLoadsId); 2624 g_afterSectionLoadsId = setTimeout(function () { 2625 afterSectionLoads$1(v); //disabling canScroll when using fastSpeed 2626 2627 setState({ 2628 canScroll: !isFastSpeed || FP.test.isTesting 2629 }); 2630 }, getOptions().scrollingSpeed); 2631 } else { 2632 afterSectionLoads$1(v); 2633 } 2634 } // using JS to animate 2635 else { 2636 var scrollSettings = getScrollSettings(v.dtop); 2637 FP.test.top = -v.dtop + 'px'; 2638 clearTimeout(g_afterSectionLoadsId); 2639 scrollTo(scrollSettings.element, scrollSettings.options, getOptions().scrollingSpeed, function () { 2640 if (getOptions().scrollBar) { 2641 /* Hack! 2642 The timeout prevents setting the most dominant section in the viewport as "active" when the user 2643 scrolled to a smaller section by using the mousewheel (auto scrolling) rather than draging the scroll bar. 2644 When using scrollBar:true It seems like the scroll events still getting propagated even after the scrolling animation has finished. 2645 */ 2646 g_afterSectionLoadsId = setTimeout(function () { 2647 afterSectionLoads$1(v); 2648 }, 30); 2649 } else { 2650 afterSectionLoads$1(v); //disabling canScroll when using fastSpeed 2651 2652 setState({ 2653 canScroll: !isFastSpeed || FP.test.isTesting 2654 }); 2655 } 2656 }); 2657 } // enabling canScroll after the minimum transition laps 2658 2659 2660 if (isFastSpeed) { 2661 clearTimeout(g_transitionLapseId); 2662 g_transitionLapseId = setTimeout(function () { 2663 setState({ 2664 canScroll: true 2665 }); 2666 }, transitionLapse); 2667 } 2668 } 2669 /** 2670 * Actions to do once the section is loaded. 2671 */ 2672 2673 2674 function afterSectionLoads$1(v) { 2675 setState({ 2676 isBeyondFullpage: false 2677 }); 2678 continuousVerticalFixSectionOrder(v); //callback (afterLoad) if the site is not just resizing and readjusting the slides 2679 2680 if (isFunction(getOptions().afterLoad) && !v.localIsResizing) { 2681 fireCallback('afterLoad', v); 2682 } 2683 2684 updateState(); 2685 2686 if (!v.localIsResizing) { 2687 playMedia(v.element); 2688 } 2689 2690 addClass(v.element, COMPLETELY); 2691 removeClass(siblings(v.element), COMPLETELY); 2692 lazyLoadOthers(); 2693 setState({ 2694 canScroll: true 2695 }); 2696 EventEmitter.emit(events.afterSectionLoads, v); 2697 2698 if (isFunction(v.callback)) { 2699 v.callback(); 2700 } 2701 } 2702 2703 FP.setFitToSection = setFitToSection; 2704 FP.fitToSection = fitToSection; 2705 /** 2706 * Sets fitToSection 2707 */ 2708 2709 function setFitToSection(value, type) { 2710 setVariableState('fitToSection', value, type); 2711 } 2712 /** 2713 * Fits the site to the nearest active section 2714 */ 2715 2716 function fitToSection() { 2717 //checking fitToSection again in case it was set to false before the timeout delay 2718 if (state.canScroll && getOptions().fitToSection) { 2719 //allows to scroll to an active section and 2720 //if the section is already active, we prevent firing callbacks 2721 setState({ 2722 isResizing: true 2723 }); 2724 scrollPage(state.activeSection); 2725 setState({ 2726 isResizing: false 2727 }); 2728 } 2729 } 2730 2731 FP.setResponsive = setResponsive; 2732 /** 2733 * Checks if the site needs to get responsive and disables autoScrolling if so. 2734 * A class `fp-responsive` is added to the plugin's container in case the user wants to use it for his own responsive CSS. 2735 */ 2736 2737 function responsive() { 2738 var widthLimit = getOptions().responsive || getOptions().responsiveWidth; //backwards compatiblity 2739 2740 var heightLimit = getOptions().responsiveHeight; //only calculating what we need. Remember its called on the resize event. 2741 2742 var isBreakingPointWidth = widthLimit && win.innerWidth < widthLimit; 2743 var isBreakingPointHeight = heightLimit && win.innerHeight < heightLimit; 2744 2745 if (widthLimit && heightLimit) { 2746 setResponsive(isBreakingPointWidth || isBreakingPointHeight); 2747 } else if (widthLimit) { 2748 setResponsive(isBreakingPointWidth); 2749 } else if (heightLimit) { 2750 setResponsive(isBreakingPointHeight); 2751 } 2752 } 2753 /** 2754 * Turns fullPage.js to normal scrolling mode when the viewport `width` or `height` 2755 * are smaller than the set limit values. 2756 */ 2757 2758 function setResponsive(active) { 2759 var isResponsive = isResponsiveMode(); 2760 2761 if (active) { 2762 if (!isResponsive) { 2763 setAutoScrolling(false, 'internal'); 2764 setFitToSection(false, 'internal'); 2765 hide($(SECTION_NAV_SEL)); 2766 addClass($body, RESPONSIVE); 2767 2768 if (isFunction(getOptions().afterResponsive)) { 2769 getOptions().afterResponsive.call(getContainer(), active); 2770 } 2771 } 2772 } else if (isResponsive) { 2773 setAutoScrolling(getOriginals().autoScrolling, 'internal'); 2774 setFitToSection(getOriginals().autoScrolling, 'internal'); 2775 show($(SECTION_NAV_SEL)); 2776 removeClass($body, RESPONSIVE); 2777 2778 if (isFunction(getOptions().afterResponsive)) { 2779 getOptions().afterResponsive.call(getContainer(), active); 2780 } 2781 } 2782 } 2783 /** 2784 * Determines whether fullpage.js is in responsive mode or not. 2785 */ 2786 2787 2788 function isResponsiveMode() { 2789 return hasClass($body, RESPONSIVE); 2790 } 2791 2792 function addTableClass(element) { 2793 if (!getOptions().verticalCentered) { 2794 return; 2795 } // Overflowing sections when scrollOverflow is disabled will be autoHeight 2796 // and won't require vertical aligment 2797 2798 2799 if (!getOptions().scrollOverflow && scrollOverflowHandler.shouldBeScrollable(element.item)) { 2800 return; 2801 } 2802 2803 if (!scrollOverflowHandler.isScrollable(element)) { 2804 //In case we are styling for the 2nd time as in with reponsiveSlides 2805 if (!hasClass(element.item, TABLE)) { 2806 addClass(element.item, TABLE); 2807 } 2808 } 2809 } 2810 2811 var startingSection = null; 2812 FP.getActiveSection = getActiveSection; 2813 function getStartingSection() { 2814 return startingSection; 2815 } 2816 /** 2817 * Styling vertical sections 2818 */ 2819 2820 function styleSection(section) { 2821 var sectionElem = section.item; 2822 var hasSlides = section.allSlidesItems.length; 2823 var index = section.index(); //if no active section is defined, the 1st one will be the default one 2824 2825 if (!getState().activeSection && section.isVisible) { 2826 addClass(sectionElem, ACTIVE); 2827 updateState(); 2828 } 2829 2830 if (!startingSection && section.isVisible) { 2831 startingSection = getState().activeSection.item; 2832 } 2833 2834 if (getOptions().paddingTop) { 2835 css(sectionElem, { 2836 'padding-top': getOptions().paddingTop 2837 }); 2838 } 2839 2840 if (getOptions().paddingBottom) { 2841 css(sectionElem, { 2842 'padding-bottom': getOptions().paddingBottom 2843 }); 2844 } 2845 2846 if (typeof getOptions().sectionsColor[index] !== 'undefined') { 2847 css(sectionElem, { 2848 'background-color': getOptions().sectionsColor[index] 2849 }); 2850 } 2851 2852 if (typeof getOptions().anchors[index] !== 'undefined') { 2853 sectionElem.setAttribute('data-anchor', section.anchor); 2854 } 2855 2856 if (!hasSlides) { 2857 addTableClass(section); 2858 } 2859 } 2860 /** 2861 * Gets the active section. 2862 */ 2863 2864 function getActiveSection() { 2865 return getState().activeSection; 2866 } 2867 2868 function getSectionFromPanel(panel) { 2869 return panel.isSection ? panel : panel.parent; 2870 } 2871 2872 var g_focusScrollableId; 2873 EventEmitter.on(events.bindEvents, bindEvents$b); 2874 2875 function bindEvents$b() { 2876 // We can't focus scrollOverflow before scrolling 2877 // to the anchor (if we need to) 2878 EventEmitter.on(events.onAfterRenderNoAnchor, afterRender); 2879 EventEmitter.on(events.onLeave, scrollOverflowHandler.onLeave); 2880 EventEmitter.on(events.onSlideLeave, scrollOverflowHandler.onLeave); 2881 EventEmitter.on(events.afterSlideLoads, scrollOverflowHandler.afterLoad); 2882 EventEmitter.on(events.afterSectionLoads, scrollOverflowHandler.afterLoad); 2883 EventEmitter.on(events.onDestroy, onDestroy$7); 2884 docAddEvent('keyup', scrollOverflowHandler.keyUpHandler); 2885 } 2886 2887 function afterRender() { 2888 if (getOptions().scrollOverflow && !getOptions().scrollBar) { 2889 scrollOverflowHandler.makeScrollable(); 2890 scrollOverflowHandler.focusScrollable(); 2891 } 2892 } 2893 2894 function onDestroy$7() { 2895 EventEmitter.removeListener(events.onAfterRenderNoAnchor, afterRender); 2896 docRemoveEvent('keyup', scrollOverflowHandler.keyUpHandler); 2897 } 2898 2899 var scrollOverflowHandler = { 2900 focusedElem: null, 2901 shouldFocusScrollable: true, 2902 isInnerScrollAllowed: true, 2903 timeBeforeReachingLimit: null, 2904 timeLastScroll: null, 2905 preventScrollWithMouseWheel: function preventScrollWithMouseWheel(e) { 2906 var activeSection = getState().activeSection; 2907 2908 if (!state.canScroll || isInsideIframe() && getOptions().scrollOverflow && scrollOverflowHandler.isScrollable(activeSection) && scrollOverflowHandler.isScrolled(getState().wheelDirection, activeSection.item)) { 2909 preventDefault(e); 2910 return false; 2911 } 2912 }, 2913 preventScrollWithKeyboard: function preventScrollWithKeyboard(e) { 2914 if (!isInsideInput() && getOptions().keyboardScrolling) { 2915 var directionKeys = [38, 33, 32, 40, 34, 36, 35]; 2916 2917 if (directionKeys.indexOf(e.keyCode) > -1 && !scrollOverflowHandler.isInnerScrollAllowed) { 2918 preventDefault(e); 2919 return false; 2920 } 2921 } 2922 }, 2923 keyUpHandler: function keyUpHandler() { 2924 scrollOverflowHandler.shouldFocusScrollable = state.canScroll; 2925 }, 2926 // Leaving sections or slides 2927 onLeave: function onLeave() { 2928 clearTimeout(g_focusScrollableId); 2929 scrollOverflowHandler.isInnerScrollAllowed = false; 2930 }, 2931 // Loading sections or slides 2932 afterLoad: function afterLoad() { 2933 scrollOverflowHandler.isInnerScrollAllowed = false; // Delaying it to avoid issues on Safari when focusing elements #4484 & #4493 2934 2935 clearTimeout(g_focusScrollableId); 2936 g_focusScrollableId = setTimeout(function () { 2937 scrollOverflowHandler.shouldFocusScrollable = state.canScroll; 2938 }, 200); 2939 }, 2940 // Unfocusing the scrollable element from the orgin section/slide 2941 unfocusScrollable: function unfocusScrollable() { 2942 if (doc.activeElement === this.focusedElem) { 2943 // @ts-ignore 2944 this.focusedElem.blur(); 2945 scrollOverflowHandler.isInnerScrollAllowed = false; 2946 } 2947 }, 2948 focusScrollable: function focusScrollable() { 2949 if (!getOptions().scrollOverflow || !scrollOverflowHandler.shouldFocusScrollable) { 2950 return; 2951 } 2952 2953 scrollOverflowHandler.unfocusScrollable(); 2954 var scrollableItem = scrollOverflowHandler.getScrollableItem(getState().activeSection.item); // On desktop we focus the scrollable to be able to use the mouse wheel 2955 // We avoid it on mobile due to a bug in iOS Safari 2956 2957 if (scrollableItem && !isTouchDevice && !isTouch) { 2958 this.focusedElem = scrollableItem; // Forcing the focus on the next paint 2959 // to avoid issue #4484 & #4493 on Safari 2960 2961 requestAnimationFrame(function () { 2962 scrollableItem.focus({ 2963 preventScroll: true 2964 }); 2965 scrollOverflowHandler.isInnerScrollAllowed = true; 2966 }); 2967 } 2968 2969 scrollOverflowHandler.shouldFocusScrollable = false; 2970 }, 2971 makeScrollable: function makeScrollable() { 2972 if (getOptions().scrollOverflowMacStyle && !isMacDevice) { 2973 addClass($body, 'fp-scroll-mac'); 2974 } 2975 2976 getState().panels.forEach(function (el) { 2977 if (el.slides && el.slides.length) { 2978 return; 2979 } 2980 2981 if (hasClass(el.item, AUTO_HEIGHT_RESPONSIVE) && isResponsiveMode()) { 2982 return; 2983 } else { 2984 var item = getSlideOrSection(el.item); 2985 var shouldBeScrollable = scrollOverflowHandler.shouldBeScrollable(el.item); 2986 var section = getSectionFromPanel(el); 2987 2988 if (isIE11) { 2989 var toggleAction = shouldBeScrollable ? 'addClass' : 'removeClass'; 2990 utils[toggleAction](section.item, IS_OVERFLOW); 2991 utils[toggleAction](el.item, IS_OVERFLOW); 2992 } else { 2993 addClass(section.item, IS_OVERFLOW); 2994 addClass(el.item, IS_OVERFLOW); 2995 } 2996 2997 if (!el.hasScroll) { 2998 scrollOverflowHandler.createWrapper(item); 2999 scrollOverflowHandler.bindEvents(item); 3000 } // updating the state now in case 3001 // this is executed on page load (after images load) 3002 3003 3004 el.hasScroll = true; 3005 } 3006 }); 3007 }, 3008 bindEvents: function bindEvents(item) { 3009
vendor: 20,357 bytes, lines 3009-3606
3009scrollOverflowHandler.getScrollableItem(item).addEventListener('scroll', scrollOverflowHandler.onPanelScroll); 3010 item.addEventListener('wheel', scrollOverflowHandler.preventScrollWithMouseWheel, { 3011 passive: false 3012 }); 3013 item.addEventListener('keydown', scrollOverflowHandler.preventScrollWithKeyboard, { 3014 passive: false 3015 }); 3016 }, 3017 createWrapper: function createWrapper(item) { 3018 var overflowWrapper = document.createElement('div'); 3019 overflowWrapper.className = OVERFLOW; 3020 wrapInner(item, overflowWrapper); 3021 overflowWrapper.setAttribute('tabindex', '-1'); 3022 }, 3023 destroyWrapper: function destroyWrapper(item) { 3024 var overflowWrapper = $(OVERFLOW_SEL, item)[0]; 3025 3026 if (overflowWrapper) { 3027 unwrap(overflowWrapper); 3028 item.removeAttribute('tabindex'); 3029 } 3030 }, 3031 getScrollableItem: function getScrollableItem(sectionItem) { 3032 var panel = getSlideOrSection(sectionItem); 3033 return $(OVERFLOW_SEL, panel)[0] || panel; 3034 }, 3035 hasScroll: function hasScroll(panelItem) { 3036 return hasClass(panelItem, OVERFLOW) || $(OVERFLOW_SEL, panelItem)[0] != null; 3037 }, 3038 isScrollable: function isScrollable(panel) { 3039 return panel.isSection && panel.activeSlide ? panel.activeSlide.hasScroll : panel.hasScroll; 3040 }, 3041 shouldBeScrollable: function shouldBeScrollable(item) { 3042 var scrollable = scrollOverflowHandler.getScrollableItem(item); 3043 return scrollable.scrollHeight > win.innerHeight; 3044 }, 3045 isScrolled: function isScrolled(direction, el) { 3046 if (!state.canScroll) { 3047 return false; 3048 } // we won't allow scrolloverflow on scrollBar:true 3049 3050 3051 if (getOptions().scrollBar) { 3052 return true; 3053 } 3054 3055 var scrollableItem = scrollOverflowHandler.getScrollableItem(el); 3056 3057 if (!getOptions().scrollOverflow || !hasClass(scrollableItem, OVERFLOW) || // Checking the section first 3058 // In case they apply to both section + slide #4505 3059 hasClass(el, 'fp-noscroll') || // Checking the slide (in case it has) 3060 hasClass(getSlideOrSection(el), 'fp-noscroll')) { 3061 return true; 3062 } // ie11 wrongly calculates scrollHeight when using the CSS style 3063 // overflow: auto It adds 1 more pixel compared to offsetHeight 3064 3065 3066 var ie11offset = isIE11 ? 1 : 0; 3067 var positionY = scrollableItem.scrollTop; 3068 var isTopReached = direction === 'up' && positionY <= 0; 3069 var isBottomReached = direction === 'down' && scrollableItem.scrollHeight <= Math.ceil(scrollableItem.offsetHeight + positionY) + ie11offset; 3070 var isScrolled = isTopReached || isBottomReached; 3071 3072 if (!isScrolled && direction !== 'none') { 3073 this.timeBeforeReachingLimit = new Date().getTime(); 3074 } 3075 3076 return isScrolled; 3077 }, 3078 shouldMovePage: function shouldMovePage() { 3079 this.timeLastScroll = new Date().getTime(); 3080 var timeDiff = this.timeLastScroll - scrollOverflowHandler.timeBeforeReachingLimit; 3081 var isUsingTouch = isTouchDevice || isTouch; 3082 var isGrabbing = isUsingTouch && state.isGrabbing; 3083 var isNotFirstTimeReachingLimit = state.isUsingWheel && timeDiff > 600; 3084 return isGrabbing && timeDiff > 400 || isNotFirstTimeReachingLimit; 3085 }, 3086 onPanelScroll: function () { 3087 var prevPosition = 0; 3088 return function (e) { 3089 var currentPosition = e.target.scrollTop; 3090 var direction = state.touchDirection !== 'none' ? state.touchDirection : prevPosition < currentPosition ? 'down' : 'up'; 3091 prevPosition = currentPosition; 3092 3093 if (isFunction(getOptions().onScrollOverflow)) { 3094 fireCallback('onScrollOverflow', { 3095 position: currentPosition, 3096 direction: direction 3097 }); 3098 } 3099 3100 if (hasClass(e.target, OVERFLOW) && state.canScroll) { 3101 if (scrollOverflowHandler.isScrolled(direction, e.target) && scrollOverflowHandler.shouldMovePage()) { 3102 // Checking again if we have a scrollable content 3103 // To avoid issues like #4479 where the scroll event gets 3104 // triggered after removing/hidding content if this was scrolled 3105 if (scrollOverflowHandler.shouldBeScrollable(getState().activeSection.item)) { 3106 EventEmitter.emit(events.onScrollOverflowScrolled, { 3107 direction: direction 3108 }); 3109 } 3110 } 3111 } 3112 }; 3113 }() 3114 }; 3115 3116 var g_afterSlideLoadsId; 3117 FP.landscapeScroll = landscapeScroll; 3118 EventEmitter.on(events.bindEvents, bindEvents$a); 3119 3120 function bindEvents$a() { 3121 EventEmitter.on(events.onPerformMovement, onPerformMovement); 3122 } 3123 3124 function onPerformMovement() { 3125 clearTimeout(g_afterSlideLoadsId); 3126 setState({ 3127 slideMoving: false 3128 }); 3129 } 3130 /** 3131 * Scrolls horizontal sliders. 3132 */ 3133 3134 3135 function landscapeScroll(slides, destiny, direction) { 3136 var sectionElem = closest(slides, SECTION_SEL); 3137 var section = getState().sections.filter(function (section) { 3138 return section.item == sectionElem; 3139 })[0]; 3140 var slide = section.slides.filter(function (slide) { 3141 return slide.item == destiny; 3142 })[0]; 3143 var v = { 3144 "slides": slides, 3145 "destiny": destiny, 3146 "direction": direction, 3147 "destinyPos": { 3148 "left": destiny.offsetLeft 3149 }, 3150 "slideIndex": slide.index(), 3151 "section": sectionElem, 3152 "sectionIndex": section.index(), 3153 "anchorLink": section.anchor, 3154 "slidesNav": $(SLIDES_NAV_SEL, sectionElem)[0], 3155 "slideAnchor": slide.anchor, 3156 "prevSlide": section.activeSlide.item, 3157 "prevSlideIndex": section.activeSlide.index(), 3158 "items": { 3159 "section": section, 3160 "origin": section.activeSlide, 3161 "destination": slide 3162 }, 3163 //caching the value of isResizing at the momment the function is called 3164 //because it will be checked later inside a setTimeout and the value might change 3165 "localIsResizing": state.isResizing 3166 }; 3167 v.xMovement = getXmovement(v.prevSlideIndex, v.slideIndex); 3168 v.direction = v.direction ? v.direction : v.xMovement; //important!! Only do it when not resizing 3169 3170 if (!v.localIsResizing) { 3171 //preventing from scrolling to the next/prev section when using scrollHorizontally 3172 setState({ 3173 canScroll: false 3174 }); 3175 } 3176 3177 if (getOptions().onSlideLeave) { 3178 //if the site is not just resizing and readjusting the slides 3179 if (!v.localIsResizing && v.xMovement !== 'none') { 3180 if (isFunction(getOptions().onSlideLeave)) { 3181 if (fireCallback('onSlideLeave', v) === false) { 3182 setState({ 3183 slideMoving: false 3184 }); 3185 return; 3186 } 3187 } 3188 } 3189 } 3190 3191 addClass(destiny, ACTIVE); 3192 removeClass(siblings(destiny), ACTIVE); 3193 updateState(); 3194 3195 if (!v.localIsResizing) { 3196 stopMedia(v.prevSlide); 3197 lazyLoadPanels(slide); 3198 } 3199 3200 toggleControlArrows(v); //only changing the URL if the slides are in the current section (not for resize re-adjusting) 3201 3202 if (section.isActive && !v.localIsResizing) { 3203 setPageStatus(v.slideIndex, v.slideAnchor, v.anchorLink); 3204 } 3205 3206 EventEmitter.emit(events.onSlideLeave, v); 3207 performHorizontalMove(slides, v, true); 3208 } 3209 /** 3210 * Performs the horizontal movement. (CSS3 or jQuery) 3211 * 3212 * @param fireCallback {Boolean} - determines whether or not to fire the callback 3213 */ 3214 3215 function performHorizontalMove(slides, v, fireCallback) { 3216 var destinyPos = v.destinyPos; 3217 activeSlidesNavigation(v.slidesNav, v.slideIndex); 3218 setState({ 3219 scrollX: Math.round(destinyPos.left) 3220 }); 3221 3222 if (getOptions().css3) { 3223 var translate3d = 'translate3d(-' + Math.round(destinyPos.left) + 'px, 0px, 0px)'; 3224 FP.test.translate3dH[v.sectionIndex] = translate3d; 3225 css(addAnimation($(SLIDES_CONTAINER_SEL, slides)), getTransforms(translate3d)); 3226 clearTimeout(g_afterSlideLoadsId); 3227 g_afterSlideLoadsId = setTimeout(function () { 3228 if (fireCallback) { 3229 afterSlideLoads(v); 3230 } 3231 }, getOptions().scrollingSpeed); 3232 } else { 3233 FP.test.left[v.sectionIndex] = Math.round(destinyPos.left); 3234 scrollTo(slides, Math.round(destinyPos.left), getOptions().scrollingSpeed, function () { 3235 if (fireCallback) { 3236 afterSlideLoads(v); 3237 } 3238 }); 3239 } 3240 } 3241 /** 3242 * Retuns `right` or `left` depending on the scrolling movement to reach its destination 3243 * from the current slide. 3244 */ 3245 3246 3247 function getXmovement(fromIndex, toIndex) { 3248 if (fromIndex == toIndex) { 3249 return 'none'; 3250 } 3251 3252 if (fromIndex > toIndex) { 3253 return 'left'; 3254 } 3255 3256 return 'right'; 3257 } 3258 3259 function onDestroy$6() { 3260 clearTimeout(g_afterSlideLoadsId); 3261 } 3262 3263 function afterSlideLoads(v) { 3264 //if the site is not just resizing and readjusting the slides 3265 if (!v.localIsResizing) { 3266 if (isFunction(getOptions().afterSlideLoad)) { 3267 fireCallback('afterSlideLoad', v); 3268 } //needs to be inside the condition to prevent problems with continuousVertical and scrollHorizontally 3269 //and to prevent double scroll right after a windows resize 3270 3271 3272 setState({ 3273 canScroll: true 3274 }); 3275 playMedia(v.destiny); 3276 EventEmitter.emit(events.afterSlideLoads, v); 3277 } //letting them slide again 3278 3279 3280 setState({ 3281 slideMoving: false 3282 }); 3283 } 3284 3285 /** 3286 * Slides silently (with no animation) the active slider to the given slide. 3287 * @param noCallback {bool} true or defined -> no callbacks 3288 */ 3289 3290 function silentLandscapeScroll(activeSlide, noCallbacks) { 3291 setScrollingSpeed(0, 'internal'); 3292 3293 if (typeof noCallbacks !== 'undefined') { 3294 //preventing firing callbacks afterSlideLoad etc. 3295 setState({ 3296 isResizing: true 3297 }); 3298 } 3299 3300 landscapeScroll(closest(activeSlide, SLIDES_WRAPPER_SEL), activeSlide); 3301 3302 if (typeof noCallbacks !== 'undefined') { 3303 setState({ 3304 isResizing: false 3305 }); 3306 } 3307 3308 setScrollingSpeed(getOriginals().scrollingSpeed, 'internal'); 3309 } 3310 3311 var g_prevActiveSectionIndex = null; 3312 var g_prevActiveSlideIndex = null; 3313 /** 3314 * Updates the state of the app. 3315 */ 3316 3317 function updateState() { 3318 state.activeSection = null; 3319 state.sections.map(function (section) { 3320 var isActive = hasClass(section.item, ACTIVE); 3321 section.isActive = isActive; 3322 section.hasScroll = scrollOverflowHandler.hasScroll(section.item); 3323 3324 if (isActive) { 3325 state.activeSection = section; 3326 } 3327 3328 if (section.slides.length) { 3329 section.activeSlide = null; 3330 section.slides.map(function (slide) { 3331 var isActiveSlide = hasClass(slide.item, ACTIVE); 3332 slide.hasScroll = scrollOverflowHandler.hasScroll(section.item); 3333 slide.isActive = isActiveSlide; 3334 3335 if (isActiveSlide) { 3336 section.activeSlide = slide; 3337 } 3338 }); 3339 } 3340 }); 3341 scrollToNewActivePanel(); 3342 } 3343 function updateStructuralState() { 3344 var allSectionItems = $(getOptions().sectionSelector, getContainer()); 3345 var sectionsItems = getVisible(allSectionItems); 3346 var allSections = Array.from(allSectionItems).map(function (item) { 3347 return new SectionPanel(item); 3348 }); 3349 var sections = allSections.filter(function (item) { 3350 return item.isVisible; 3351 }); 3352 var slides = sections.reduce(function (acc, section) { 3353 return acc.concat(section.slides); 3354 }, []); // keeping track of the previously active section 3355 3356 g_prevActiveSectionIndex = getPrevActivePanelIndex(state.activeSection); 3357 g_prevActiveSlideIndex = getPrevActivePanelIndex(state.activeSection ? state.activeSection.activeSlide : null); 3358 state.numSections = sectionsItems.length; 3359 state.numSlides = sections.reduce(function (acc, section) { 3360 return acc + section.slides.length; 3361 }, 0); 3362 state.sections = sections; 3363 state.sectionsIncludingHidden = allSections; 3364 state.slides = slides; 3365 state.panels = state.sections.concat(state.slides); 3366 } 3367 3368 function getPrevActivePanelIndex(activePanel) { 3369 if (!activePanel) { 3370 return null; 3371 } 3372 3373 var prevActivePanelItem = activePanel ? activePanel.item : null; 3374 var hiddenPanels = activePanel.isSection ? state.sectionsIncludingHidden : state.activeSection.slidesIncludingHidden; 3375 3376 if (prevActivePanelItem) { 3377 var panel = getPanelByElement(hiddenPanels, prevActivePanelItem); 3378 return panel ? panel.index() : null; 3379 } 3380 3381 return null; 3382 } 3383 /** 3384 * When changes in the DOM take place there's a change 3385 * the active section is now hidden or removed. 3386 * fullPage.js will scroll to the closest section nearby. 3387 */ 3388 3389 3390 function scrollToNewActivePanel() { 3391 var activeSection = state.activeSection; 3392 var activeSectionHasSlides = state.activeSection ? state.activeSection.slides.length : false; 3393 var activeSlide = state.activeSection ? state.activeSection.activeSlide : null; // Hidding / removing the active section ? 3394 3395 if (!activeSection && state.sections.length && !getState().isBeyondFullpage && g_prevActiveSectionIndex) { 3396 var newActiveSection = getNewActivePanel(g_prevActiveSectionIndex, state.sections); 3397 3398 if (newActiveSection) { 3399 state.activeSection = newActiveSection; 3400 state.activeSection.isActive = true; 3401 addClass(state.activeSection.item, ACTIVE); 3402 } 3403 3404 if (state.activeSection) { 3405 silentScroll(state.activeSection.item.offsetTop); 3406 } 3407 } 3408 3409 if (activeSectionHasSlides && !activeSlide && g_prevActiveSlideIndex) { 3410 var newActiveSlide = getNewActivePanel(g_prevActiveSlideIndex, state.activeSection.slides); 3411 3412 if (newActiveSlide) { 3413 state.activeSection.activeSlide = newActiveSlide; 3414 state.activeSection.activeSlide.isActive = true; 3415 addClass(state.activeSection.activeSlide.item, ACTIVE); 3416 } 3417 3418 if (state.activeSection.activeSlide) { 3419 silentLandscapeScroll(state.activeSection.activeSlide.item, 'internal'); 3420 } 3421 } 3422 } 3423 3424 function getNewActivePanel(prevActivePanelIndex, siblings) { 3425 var newActiveSection; 3426 var prevIndex = prevActivePanelIndex - 1; 3427 var nextIndex = prevActivePanelIndex; 3428 3429 do { 3430 newActiveSection = siblings[prevIndex] || siblings[nextIndex]; 3431 3432 if (newActiveSection) { 3433 break; 3434 } 3435 3436 prevIndex = prevIndex - 1; 3437 nextIndex = nextIndex + 1; 3438 } while (prevIndex >= 0 || nextIndex < siblings.length); 3439 3440 return newActiveSection; 3441 } 3442 /** 3443 * Section object 3444 */ 3445 3446 3447 var SectionPanel = function SectionPanel(el) { 3448 var _this = this; 3449 3450 [].push.call(arguments, getOptions().sectionSelector); 3451 Item.apply(this, arguments); 3452 this.allSlidesItems = $(getOptions().slideSelector, el); 3453 this.slidesIncludingHidden = Array.from(this.allSlidesItems).map(function (item) { 3454 return new SlidePanel(item, _this); 3455 }); 3456 this.slides = this.slidesIncludingHidden.filter(function (slidePanel) { 3457 return slidePanel.isVisible; 3458 }); 3459 this.activeSlide = this.slides.length ? this.slides.filter(function (slide) { 3460 return slide.isActive; 3461 })[0] || this.slides[0] : null; 3462 }; 3463 SectionPanel.prototype = Item.prototype; 3464 SectionPanel.prototype.constructor = SectionPanel; 3465 /** 3466 * Slide object 3467 */ 3468 3469 var SlidePanel = function SlidePanel(el, section) { 3470 this.parent = section; 3471 Item.call(this, el, getOptions().slideSelector); 3472 }; 3473 3474 SlidePanel.prototype = Item.prototype; 3475 SlidePanel.prototype.constructor = SectionPanel; 3476 3477 /** 3478 * Adds internal classes to be able to provide customizable selectors 3479 * keeping the link with the style sheet. 3480 */ 3481 3482 function addInternalSelectors() { 3483 addClass($(getOptions().sectionSelector, getContainer()), SECTION); 3484 addClass($(getOptions().slideSelector, getContainer()), SLIDE); 3485 } 3486 3487 /** 3488 * Styles the horizontal slides for a section. 3489 */ 3490 3491 function styleSlides(section) { 3492 var numSlides = section.slides.length; 3493 var slidesElems = section.allSlidesItems; 3494 var slides = section.slides; 3495 var sliderWidth = numSlides * 100; 3496 var slideWidth = 100 / numSlides; 3497 3498 if (!$(SLIDES_WRAPPER_SEL, section.item)[0]) { 3499 var slidesWrapper = doc.createElement('div'); 3500 slidesWrapper.className = SLIDES_WRAPPER; //fp-slides 3501 3502 wrapAll(slidesElems, slidesWrapper); 3503 var slidesContainer = doc.createElement('div'); 3504 slidesContainer.className = SLIDES_CONTAINER; //fp-slidesContainer 3505 3506 wrapAll(slidesElems, slidesContainer); 3507 } 3508 3509 css($(SLIDES_CONTAINER_SEL, section.item), { 3510 'width': sliderWidth + '%' 3511 }); 3512 3513 if (numSlides > 1) { 3514 if (getOptions().controlArrows) { 3515 createSlideArrows(section); 3516 } 3517 3518 if (getOptions().slidesNavigation) { 3519 addSlidesNavigation(section); 3520 } 3521 } 3522 3523 slides.forEach(function (slide) { 3524 css(slide.item, { 3525 'width': slideWidth + '%' 3526 }); 3527 3528 if (getOptions().verticalCentered) { 3529 addTableClass(slide); 3530 } 3531 }); 3532 var startingSlide = section.activeSlide || null; //if the slide won't be an starting point, the default will be the first one 3533 //the active section isn't the first one? Is not the first slide of the first section? Then we load that section/slide by default. 3534 3535 if (startingSlide != null && state.activeSection && (state.activeSection.index() !== 0 || state.activeSection.index() === 0 && startingSlide.index() !== 0)) { 3536 silentLandscapeScroll(startingSlide.item, 'internal'); 3537 } else { 3538 addClass(slidesElems[0], ACTIVE); 3539 } 3540 } 3541 3542 var g_wrapperObserver; 3543 var g_wrapperObserveConfig = { 3544 attributes: false, 3545 subtree: true, 3546 childList: true, 3547 characterData: true 3548 }; 3549 EventEmitter.on(events.bindEvents, bindEvents$9); 3550 FP["render"] = onContentChange; 3551 3552 function bindEvents$9() { 3553 if (getOptions().observer && "MutationObserver" in window && $(WRAPPER_SEL)[0]) { 3554 g_wrapperObserver = createObserver($(WRAPPER_SEL)[0], onContentChange, g_wrapperObserveConfig); 3555 } 3556 3557 EventEmitter.on(events.contentChanged, onContentChange); 3558 } 3559 /** 3560 * Creates a Mutation observer. 3561 */ 3562 3563 3564 function createObserver(target, callback, config) { 3565 var observer = new MutationObserver(callback); 3566 observer.observe(target, config); 3567 return observer; 3568 } 3569 3570 function didSlidesChange() { 3571 return getVisible($(getOptions().slideSelector, getContainer())).length !== getState().numSlides; 3572 } 3573 3574 function didSectionsChange() { 3575 return getVisible($(getOptions().sectionSelector, getContainer())).length !== getState().numSections; 3576 } 3577 3578 function didSectionsOrSlidesChange() { 3579 return didSlidesChange() || didSectionsChange(); 3580 } 3581 /** 3582 * Listen to changes on sections and fires reBuild 3583 * when those changes affect the section height. 3584 */ 3585 3586 3587 function onContentChange(mutations) { 3588 var _didSlidesChange = didSlidesChange(); 3589 3590 if (didSectionsOrSlidesChange() && !state.isDoingContinousVertical) { 3591 if (getOptions().observer && g_wrapperObserver) { 3592 // Temporally disabling the observer while 3593 // we modidy the DOM again 3594 g_wrapperObserver.disconnect(); 3595 } 3596 3597 updateStructuralState(); 3598 updateState(); // Removing navs and anchors options 3599 3600 getOptions().anchors = []; 3601 remove($(SECTION_NAV_SEL)); 3602 addInternalSelectors(); 3603 setOptionsFromDOM(); 3604 3605 if (getOptions().navigation) { 3606 addVerticalNavigation
vendor: 24,074 bytes, lines 3606-4384
3606(); 3607 } 3608 3609 if (_didSlidesChange) { 3610 remove($(SLIDES_NAV_SEL)); 3611 remove($(SLIDES_ARROW_SEL)); 3612 } 3613 3614 getState().sections.forEach(function (section) { 3615 if (section.slides.length) { 3616 if (_didSlidesChange) { 3617 styleSlides(section); 3618 } 3619 } else { 3620 styleSection(section); 3621 } 3622 }); 3623 } 3624 3625 if (getOptions().observer && g_wrapperObserver && $(WRAPPER_SEL)[0]) { 3626 g_wrapperObserver.observe($(WRAPPER_SEL)[0], g_wrapperObserveConfig); 3627 } 3628 } 3629 3630 var supportsPassiveEvents = function () { 3631 //cheks for passive event support 3632 var g_supportsPassive = false; 3633 3634 try { 3635 var opts = Object.defineProperty({}, 'passive', { 3636 get: function get() { 3637 g_supportsPassive = true; 3638 } 3639 }); 3640 windowAddEvent("testPassive", null, opts); 3641 windowRemoveEvent("testPassive", null, opts); 3642 } catch (e) {} 3643 3644 return function () { 3645 return g_supportsPassive; 3646 }; 3647 }(); 3648 3649 function getPassiveOptionsIfPossible() { 3650 return supportsPassiveEvents() ? { 3651 passive: false 3652 } : false; 3653 } 3654 3655 var wheelDataHandler = function () { 3656 var _prevTime = new Date().getTime(); 3657 3658 var _scrollings = []; 3659 var isScrollingVertically; 3660 var direction; 3661 return { 3662 registerEvent: function registerEvent(e) { 3663 e = e || win.event; 3664 var value = e.wheelDelta || -e.deltaY || -e.detail; 3665 var delta = Math.max(-1, Math.min(1, value)); 3666 var horizontalDetection = typeof e.wheelDeltaX !== 'undefined' || typeof e.deltaX !== 'undefined'; 3667 isScrollingVertically = Math.abs(e.wheelDeltaX) < Math.abs(e.wheelDelta) || Math.abs(e.deltaX) < Math.abs(e.deltaY) || !horizontalDetection; 3668 var curTime = new Date().getTime(); 3669 direction = delta < 0 ? 'down' : 'up'; //Limiting the array to 150 (lets not waste memory!) 3670 3671 if (_scrollings.length > 149) { 3672 _scrollings.shift(); 3673 } //keeping record of the previous scrollings 3674 3675 3676 _scrollings.push(Math.abs(value)); //time difference between the last scroll and the current one 3677 3678 3679 var timeDiff = curTime - _prevTime; 3680 _prevTime = curTime; //haven't they scrolled in a while? 3681 //(enough to be consider a different scrolling action to scroll another section) 3682 3683 if (timeDiff > 200) { 3684 //emptying the array, we dont care about old scrollings for our averages 3685 _scrollings = []; 3686 } 3687 }, 3688 isAccelerating: function isAccelerating() { 3689 var averageEnd = getAverage(_scrollings, 10); 3690 var averageMiddle = getAverage(_scrollings, 70); 3691 var isAccelerating = averageEnd >= averageMiddle; 3692 return _scrollings.length ? isAccelerating && isScrollingVertically : false; 3693 }, 3694 getDirection: function getDirection() { 3695 return direction; 3696 } 3697 }; 3698 }(); 3699 3700 function scrollBeyondFullPage() { 3701 var dtop = getDestinationOffset(); 3702 var scrollSettings = getScrollSettings(dtop); 3703 FP.test.top = -dtop + 'px'; 3704 setState({ 3705 canScroll: false 3706 }); 3707 scrollTo(scrollSettings.element, scrollSettings.options, getOptions().scrollingSpeed, function () { 3708 setTimeout(function () { 3709 setState({ 3710 isBeyondFullpage: true 3711 }); 3712 setState({ 3713 canScroll: true 3714 }); 3715 }, 30); 3716 }); 3717 } 3718 function onKeyDown() { 3719 if (!isFullPageAbove()) { 3720 return; 3721 } else { 3722 scrollUpToFullpage(); 3723 } 3724 } 3725 function scrollUpToFullpage() { 3726 var scrollSettings = getScrollSettings(getLast(getState().sections).item.offsetTop); 3727 setState({ 3728 canScroll: false 3729 }); 3730 scrollTo(scrollSettings.element, scrollSettings.options, getOptions().scrollingSpeed, function () { 3731 setState({ 3732 canScroll: true 3733 }); 3734 setState({ 3735 isBeyondFullpage: false 3736 }); 3737 setState({ 3738 isAboutToScrollToFullPage: false 3739 }); 3740 }); 3741 } 3742 3743 function getDestinationOffset() { 3744 if (!getOptions().css3) { 3745 return getLast(getState().sections).item.offsetTop + getLast(getState().sections).item.offsetHeight; 3746 } 3747 3748 return getScrollTop() + getWindowHeight(); 3749 } 3750 3751 function beyondFullPageHandler(container, e) { 3752 new Date().getTime(); 3753 var pauseScroll = getState().isBeyondFullpage && container.getBoundingClientRect().bottom >= 0 && wheelDataHandler.getDirection() === 'up'; 3754 var g_isAboutToScrollToFullPage = getState().isAboutToScrollToFullPage; 3755 3756 if (g_isAboutToScrollToFullPage) { 3757 preventDefault(e); 3758 return false; 3759 } 3760 3761 if (getState().isBeyondFullpage) { 3762 if (!pauseScroll) { 3763 keyframeTime('set', 'beyondFullpage', 1000); 3764 } else { 3765 var shouldSetFixedPosition = !g_isAboutToScrollToFullPage && (!keyframeTime('isNewKeyframe', 'beyondFullpage') || !wheelDataHandler.isAccelerating()); 3766 var scrollSettings; 3767 3768 if (shouldSetFixedPosition) { 3769 scrollSettings = getScrollSettings(getLast(getState().sections).item.offsetTop + getLast(getState().sections).item.offsetHeight); 3770 scrollSettings.element.scrollTo(0, scrollSettings.options); 3771 setState({ 3772 isAboutToScrollToFullPage: false 3773 }); 3774 preventDefault(e); 3775 return false; 3776 } else if (wheelDataHandler.isAccelerating()) { 3777 pauseScroll = false; 3778 setState({ 3779 isAboutToScrollToFullPage: true 3780 }); 3781 setState({ 3782 scrollTrigger: 'wheel' 3783 }); 3784 scrollUpToFullpage(); 3785 preventDefault(e); 3786 return false; 3787 } 3788 } 3789 3790 if (!g_isAboutToScrollToFullPage) { 3791 // allow normal scrolling, but quitting 3792 if (!pauseScroll) { 3793 return true; 3794 } 3795 } 3796 } 3797 } 3798 3799 var keyframeTime = function () { 3800 var isNew = false; 3801 var frames = {}; 3802 var timeframes = {}; 3803 return function (action, name, timeframe) { 3804 switch (action) { 3805 case 'set': 3806 frames[name] = new Date().getTime(); 3807 timeframes[name] = timeframe; 3808 break; 3809 3810 case 'isNewKeyframe': 3811 var current = new Date().getTime(); 3812 isNew = current - frames[name] > timeframes[name]; 3813 break; 3814 } 3815 3816 return isNew; 3817 }; 3818 }(); 3819 3820 FP.moveSectionDown = moveSectionDown; 3821 /** 3822 * Moves the page down one section. 3823 */ 3824 3825 function moveSectionDown() { 3826 var next = getState().activeSection.next(); //looping to the top if there's no more sections below 3827 3828 if (!next && (getOptions().loopBottom || getOptions().continuousVertical)) { 3829 next = getState().sections[0]; 3830 } 3831 3832 if (next != null) { 3833 scrollPage(next, null, false); 3834 } else if (hasContentBeyondFullPage()) { 3835 EventEmitter.emit(events.scrollBeyondFullpage); 3836 } 3837 } 3838 3839 function hasContentBeyondFullPage() { 3840 return getContainer().scrollHeight < $body.scrollHeight && getOptions().scrollBar && getOptions().scrollBeyondFullpage; 3841 } 3842 3843 FP.moveSectionUp = moveSectionUp; 3844 /** 3845 * Moves the page up one section. 3846 */ 3847 3848 function moveSectionUp() { 3849 var prev = getState().activeSection.prev(); //looping to the bottom if there's no more sections above 3850 3851 if (!prev && (getOptions().loopTop || getOptions().continuousVertical)) { 3852 prev = getLast(getState().sections); 3853 } 3854 3855 if (prev != null) { 3856 scrollPage(prev, null, true); 3857 } 3858 } 3859 3860 var oldPageY = 0; 3861 /** 3862 * Detecting the direction of the mouse movement. 3863 * Used only for the middle button of the mouse. 3864 */ 3865 3866 function mouseMoveHandler(e) { 3867 if (!getOptions().autoScrolling) { 3868 return; 3869 } 3870 3871 if (state.canScroll) { 3872 // moving up 3873 if (e.pageY < oldPageY && getIsScrollAllowed().m.up) { 3874 moveSectionUp(); 3875 } // moving down 3876 else if (e.pageY > oldPageY && getIsScrollAllowed().m.down) { 3877 moveSectionDown(); 3878 } 3879 } 3880 3881 oldPageY = e.pageY; 3882 } 3883 function setOldPageY(value) { 3884 oldPageY = value; 3885 } 3886 3887 /** 3888 * Determines the way of scrolling up or down: 3889 * by 'automatically' scrolling a section or by using the default and normal scrolling. 3890 */ 3891 3892 function scrolling(type) { 3893 if (!getIsScrollAllowed().m[type]) { 3894 return; 3895 } 3896 3897 var scrollSection = type === 'down' ? moveSectionDown : moveSectionUp; 3898 3899 if (getOptions().scrollOverflow && scrollOverflowHandler.isScrollable(getState().activeSection)) { 3900 //is the scrollbar at the start/end of the scroll? 3901 if (scrollOverflowHandler.isScrolled(type, getState().activeSection.item) && scrollOverflowHandler.shouldMovePage()) { 3902 scrollSection(); 3903 } 3904 } else { 3905 scrollSection(); 3906 } 3907 } 3908 3909 var touchStartY = 0; 3910 var touchStartX = 0; 3911 var touchEndY = 0; 3912 var touchEndX = 0; 3913 var MSPointer = getMSPointer(); 3914 var pointers = { 3915 touchmove: 'ontouchmove' in window ? 'touchmove' : MSPointer ? MSPointer.move : null, 3916 touchstart: 'ontouchstart' in window ? 'touchstart' : MSPointer ? MSPointer.down : null 3917 }; 3918 /** 3919 * Adds the possibility to auto scroll through sections on touch devices. 3920 */ 3921 3922 function addTouchHandler() { 3923 if (!pointers.touchmove) { 3924 return; 3925 } 3926 3927 if (isTouchDevice || isTouch) { 3928 if (getOptions().autoScrolling) { 3929 $body.removeEventListener(pointers.touchmove, preventBouncing, { 3930 passive: false 3931 }); 3932 $body.addEventListener(pointers.touchmove, preventBouncing, { 3933 passive: false 3934 }); 3935 } 3936 3937 var touchWrapper = getOptions().touchWrapper; 3938 touchWrapper.removeEventListener(pointers.touchstart, touchStartHandler); 3939 touchWrapper.removeEventListener(pointers.touchmove, touchMoveHandler, { 3940 passive: false 3941 }); 3942 touchWrapper.addEventListener(pointers.touchstart, touchStartHandler); 3943 touchWrapper.addEventListener(pointers.touchmove, touchMoveHandler, { 3944 passive: false 3945 }); 3946 } 3947 } 3948 /** 3949 * Removes the auto scrolling for touch devices. 3950 */ 3951 3952 function removeTouchHandler() { 3953 if (!pointers.touchmove) { 3954 return; 3955 } 3956 3957 if (isTouchDevice || isTouch) { 3958 // normalScrollElements requires it off #2691 3959 if (getOptions().autoScrolling) { 3960 $body.removeEventListener(pointers.touchmove, touchMoveHandler, { 3961 passive: false 3962 }); 3963 $body.removeEventListener(pointers.touchmove, preventBouncing, { 3964 passive: false 3965 }); 3966 } 3967 3968 var touchWrapper = getOptions().touchWrapper; 3969 touchWrapper.removeEventListener(pointers.touchstart, touchStartHandler); 3970 touchWrapper.removeEventListener(pointers.touchmove, touchMoveHandler, { 3971 passive: false 3972 }); 3973 } 3974 } 3975 /* Detecting touch events 3976 3977 * As we are changing the top property of the page on scrolling, we can not use the traditional way to detect it. 3978 * This way, the touchstart and the touch moves shows an small difference between them which is the 3979 * used one to determine the direction. 3980 */ 3981 3982 function touchMoveHandler(e) { 3983 var activeSection = closest(e.target, SECTION_SEL) || getState().activeSection.item; 3984 var hasActiveSectionOverflow = scrollOverflowHandler.isScrollable(getState().activeSection); 3985 3986 if (isReallyTouch(e)) { 3987 setState({ 3988 isGrabbing: true, 3989 isUsingWheel: false 3990 }); 3991 3992 if (getOptions().autoScrolling) { 3993 if (hasActiveSectionOverflow && !state.canScroll || getOptions().scrollBar) { 3994 //preventing the easing on iOS devices 3995 preventDefault(e); 3996 } 3997 } 3998 3999 var touchEvents = getEventsPage(e); 4000 touchEndY = touchEvents.y; 4001 touchEndX = touchEvents.x; 4002 var isVerticalMovementEnough = Math.abs(touchStartY - touchEndY) > win.innerHeight / 100 * getOptions().touchSensitivity; 4003 var isHorizontalMovementEnough = Math.abs(touchStartX - touchEndX) > getWindowWidth() / 100 * getOptions().touchSensitivity; 4004 var isHorizontalPredominantMove = $(SLIDES_WRAPPER_SEL, activeSection).length && Math.abs(touchStartX - touchEndX) > Math.abs(touchStartY - touchEndY); 4005 var directionH = touchStartX > touchEndX ? 'right' : 'left'; 4006 var directionV = touchStartY > touchEndY ? 'down' : 'up'; 4007 var direction = isHorizontalPredominantMove ? directionH : directionV; 4008 setState({ 4009 touchDirection: direction 4010 }); //if movement in the X axys is greater than in the Y and the currect section has slides... 4011 4012 if (isHorizontalPredominantMove) { 4013 //is the movement greater than the minimum resistance to scroll? 4014 if (!state.slideMoving && isHorizontalMovementEnough) { 4015 if (touchStartX > touchEndX) { 4016 if (getIsScrollAllowed().m.right) { 4017 EventEmitter.emit(events.moveSlideRight, { 4018 section: activeSection 4019 }); 4020 } 4021 } else { 4022 if (getIsScrollAllowed().m.left) { 4023 EventEmitter.emit(events.moveSlideLeft, { 4024 section: activeSection 4025 }); 4026 } 4027 } 4028 } 4029 } //vertical scrolling (only when autoScrolling is enabled) 4030 else if (getOptions().autoScrolling && state.canScroll) { 4031 //is the movement greater than the minimum resistance to scroll? 4032 if (isVerticalMovementEnough) { 4033 scrolling(directionV); 4034 } 4035 } 4036 } 4037 } 4038 /** 4039 * As IE >= 10 fires both touch and mouse events when using a mouse in a touchscreen 4040 * this way we make sure that is really a touch event what IE is detecting. 4041 */ 4042 4043 4044 function isReallyTouch(e) { 4045 //if is not IE || IE is detecting `touch` or `pen` 4046 return typeof e.pointerType === 'undefined' || e.pointerType != 'mouse'; 4047 } 4048 /** 4049 * Handler for the touch start event. 4050 */ 4051 4052 4053 function touchStartHandler(e) { 4054 //stopping the auto scroll to adjust to a section 4055 if (getOptions().fitToSection) { 4056 setState({ 4057 activeAnimation: false 4058 }); 4059 } 4060 4061 if (isReallyTouch(e)) { 4062 var touchEvents = getEventsPage(e); 4063 touchStartY = touchEvents.y; 4064 touchStartX = touchEvents.x; 4065 } 4066 4067 windowAddEvent('touchend', touchEndHandler); 4068 } 4069 /** 4070 * Handler for the touch end event. 4071 */ 4072 4073 4074 function touchEndHandler() { 4075 windowRemoveEvent('touchend', touchEndHandler); 4076 setState({ 4077 isGrabbing: false 4078 }); 4079 } 4080 /** 4081 * Gets the pageX and pageY properties depending on the browser. 4082 * https://github.com/alvarotrigo/fullPage.js/issues/194#issuecomment-34069854 4083 */ 4084 4085 4086 function getEventsPage(e) { 4087 var events = {}; 4088 events.y = typeof e.pageY !== 'undefined' && (e.pageY || e.pageX) ? e.pageY : e.touches[0].pageY; 4089 events.x = typeof e.pageX !== 'undefined' && (e.pageY || e.pageX) ? e.pageX : e.touches[0].pageX; //in touch devices with scrollBar:true, e.pageY is detected, but we have to deal with touch events. #1008 4090 4091 if (isTouch && isReallyTouch(e) && getOptions().scrollBar && typeof e.touches !== 'undefined') { 4092 events.y = e.touches[0].pageY; 4093 events.x = e.touches[0].pageX; 4094 } 4095 4096 return events; 4097 } 4098 /* 4099 * Returns and object with Microsoft pointers (for IE<11 and for IE >= 11) 4100 * http://msdn.microsoft.com/en-us/library/ie/dn304886(v=vs.85).aspx 4101 */ 4102 4103 4104 function getMSPointer() { 4105 var pointer; //IE >= 11 & rest of browsers 4106 4107 if (win.PointerEvent) { 4108 pointer = { 4109 down: 'pointerdown', 4110 move: 'pointermove' 4111 }; 4112 } 4113 4114 return pointer; 4115 } 4116 /* 4117 * Preventing bouncing in iOS #2285 4118 */ 4119 4120 4121 function preventBouncing(e) { 4122 if (getOptions().autoScrolling && isReallyTouch(e) && getIsScrollAllowed().m.up) { 4123 //preventing the easing on iOS devices 4124 if (!state.canScroll) { 4125 preventDefault(e); 4126 } 4127 } 4128 } 4129 4130 FP.moveSlideLeft = moveSlideLeft; 4131 FP.moveSlideRight = moveSlideRight; 4132 /** 4133 * Slides a slider to the given direction. 4134 * Optional `section` param. 4135 */ 4136 4137 function moveSlide(direction, section) { 4138 var activeSectionItem = section == null ? getState().activeSection.item : section; 4139 var activeSection = getPanelByElement(state.sections, activeSectionItem); 4140 var slides = $(SLIDES_WRAPPER_SEL, activeSectionItem)[0]; // more than one slide needed and nothing should be sliding 4141 4142 if (slides == null || state.slideMoving || activeSection.slides.length < 2) { 4143 return; 4144 } 4145 4146 var currentSlide = activeSection.activeSlide; 4147 var destiny = direction === 'left' ? currentSlide.prev() : currentSlide.next(); //isn't there a next slide in the secuence? 4148 4149 if (!destiny) { 4150 //respect loopHorizontal setting 4151 if (!getOptions().loopHorizontal) return; 4152 destiny = direction === 'left' ? getLast(activeSection.slides) : activeSection.slides[0]; 4153 } 4154 4155 setState({ 4156 slideMoving: !FP.test.isTesting 4157 }); 4158 landscapeScroll(slides, destiny.item, direction); 4159 } 4160 /** 4161 * Slides left the slider of the active section. 4162 * Optional `section` param. 4163 */ 4164 4165 function moveSlideLeft(section) { 4166 moveSlide('left', section); 4167 } 4168 /** 4169 * Slides right the slider of the active section. 4170 * Optional `section` param. 4171 */ 4172 4173 function moveSlideRight(section) { 4174 moveSlide('right', section); 4175 } 4176 4177 /** 4178 * Gets a section by its anchor / index 4179 */ 4180 4181 function getSectionByAnchor(sectionAnchor) { 4182 var section = getState().sections.filter(function (section) { 4183 return section.anchor === sectionAnchor; 4184 })[0]; 4185 4186 if (!section) { 4187 var sectionIndex = typeof sectionAnchor !== 'undefined' ? sectionAnchor - 1 : 0; 4188 section = getState().sections[sectionIndex]; 4189 } 4190 4191 return section; 4192 } 4193 4194 /** 4195 * Scrolls the slider to the given slide destination for the given section 4196 */ 4197 4198 function scrollSlider(slideElem) { 4199 if (slideElem != null) { 4200 landscapeScroll(closest(slideElem, SLIDES_WRAPPER_SEL), slideElem); 4201 } 4202 } 4203 4204 /** 4205 * Scrolls to the given section and slide anchors 4206 */ 4207 4208 function scrollPageAndSlide(sectionAnchor, slideAnchor) { 4209 var section = getSectionByAnchor(sectionAnchor); //do nothing if there's no section with the given anchor name 4210 4211 if (section == null) return; 4212 var slideElem = getSlideByAnchor(slideAnchor, section); //we need to scroll to the section and then to the slide 4213 4214 if ((!section.anchor || section.anchor !== state.lastScrolledDestiny) && !hasClass(section.item, ACTIVE)) { 4215 scrollPage(section, function () { 4216 scrollSlider(slideElem); 4217 }); 4218 } //if we were already in the section 4219 else { 4220 scrollSlider(slideElem); 4221 } 4222 } 4223 /** 4224 * Gets a slide inside a given section by its anchor / index 4225 */ 4226 4227 function getSlideByAnchor(slideAnchor, section) { 4228 var slide = section.slides.filter(function (slide) { 4229 return slide.anchor === slideAnchor; 4230 })[0]; 4231 4232 if (slide == null) { 4233 slideAnchor = typeof slideAnchor !== 'undefined' ? slideAnchor : 0; 4234 slide = section.slides[slideAnchor]; 4235 } 4236 4237 return slide ? slide.item : null; 4238 } 4239 4240 FP.moveTo = moveTo$1; 4241 /** 4242 * Moves the page to the given section and slide. 4243 * Anchors or index positions can be used as params. 4244 */ 4245 4246 function moveTo$1(sectionAnchor, slideAnchor) { 4247 var destiny = getSectionByAnchor(sectionAnchor); 4248 4249 if (typeof slideAnchor !== 'undefined') { 4250 scrollPageAndSlide(sectionAnchor, slideAnchor); 4251 } else if (destiny != null) { 4252 scrollPage(destiny); 4253 } 4254 } 4255 4256 //@ts-check 4257 var g_controlPressed; 4258 var g_keydownId; 4259 var g_elToFocus; 4260 EventEmitter.on(events.bindEvents, bindEvents$8); 4261 4262 function bindEvents$8() { 4263 //when opening a new tab (ctrl + t), `control` won't be pressed when coming back. 4264 windowAddEvent('blur', blurHandler); //Sliding with arrow keys, both, vertical and horizontal 4265 4266 docAddEvent('keydown', keydownHandler); //to prevent scrolling while zooming 4267 4268 docAddEvent('keyup', keyUpHandler); 4269 EventEmitter.on(events.onDestroy, onDestroy$5); 4270 EventEmitter.on(events.afterSlideLoads, onAfterSlideLoads); 4271 EventEmitter.on(events.afterSectionLoads, afterSectionLoads); 4272 } 4273 4274 function onDestroy$5() { 4275 clearTimeout(g_keydownId); 4276 docRemoveEvent('keydown', keydownHandler); 4277 docRemoveEvent('keyup', keyUpHandler); 4278 } //Sliding with arrow keys, both, vertical and horizontal 4279 4280 4281 function keydownHandler(e) { 4282 clearTimeout(g_keydownId); 4283 var keyCode = e.keyCode; 4284 var isPressingHorizontalArrows = [37, 39].indexOf(keyCode) > -1; 4285 var canScrollWithKeyboard = getOptions().autoScrolling || getOptions().fitToSection || isPressingHorizontalArrows; //tab? 4286 4287 if (keyCode === 9) { 4288 onTab(e); 4289 } else if (!isInsideInput() && getOptions().keyboardScrolling && canScrollWithKeyboard) { 4290 g_controlPressed = e.ctrlKey; 4291 g_keydownId = setTimeout(function () { 4292 onkeydown(e); 4293 }, 0); 4294 } 4295 } 4296 /** 4297 * Keydown event 4298 */ 4299 4300 4301 function onkeydown(e) { 4302 var shiftPressed = e.shiftKey; 4303 var activeElement = doc.activeElement; 4304 var isMediaFocused = matches(activeElement, 'video') || matches(activeElement, 'audio'); 4305 var isScrolled = { 4306 up: scrollOverflowHandler.isScrolled('up', getState().activeSection.item), 4307 down: scrollOverflowHandler.isScrolled('down', getState().activeSection.item) 4308 }; 4309 var isUsingHorizontalArrowKeys = [37, 39].indexOf(e.keyCode) > -1; 4310 cancelDirectionKeyEvents(e); //do nothing if we can not scroll or we are not using horizotnal key arrows. 4311 4312 if (!state.canScroll && !isUsingHorizontalArrowKeys) { 4313 return; 4314 } 4315 4316 setState({ 4317 scrollTrigger: 'keydown' 4318 }); 4319 4320 switch (e.keyCode) { 4321 //up 4322 case 38: 4323 case 33: 4324 if (getIsScrollAllowed().k.up && isScrolled.up) { 4325 if (state.isBeyondFullpage) { 4326 EventEmitter.emit(events.onKeyDown, { 4327 e: e 4328 }); 4329 } else { 4330 moveSectionUp(); 4331 } 4332 } else { 4333 scrollOverflowHandler.focusScrollable(); 4334 } 4335 4336 break; 4337 //down 4338 4339 case 32: 4340 //spacebar 4341 if (shiftPressed && getIsScrollAllowed().k.up && !isMediaFocused && isScrolled.up) { 4342 moveSectionUp(); 4343 break; 4344 } 4345 4346 /* falls through */ 4347 4348 case 40: 4349 case 34: 4350 if (getIsScrollAllowed().k.down && isScrolled.down) { 4351 if (state.isBeyondFullpage) { 4352 return; 4353 } // space bar? 4354 4355 4356 if (e.keyCode !== 32 || !isMediaFocused) { 4357 moveSectionDown(); 4358 } 4359 } else { 4360 scrollOverflowHandler.focusScrollable(); 4361 } 4362 4363 break; 4364 //Home 4365 4366 case 36: 4367 if (getIsScrollAllowed().k.up) { 4368 moveTo$1(1); 4369 } 4370 4371 break; 4372 //End 4373 4374 case 35: 4375 if (getIsScrollAllowed().k.down) { 4376 moveTo$1(getState().sections.length); 4377 } 4378 4379 break; 4380 //left 4381 4382 case 37: 4383 if (getIsScrollAllowed().k.left) { 4384
4384moveSlideLeft(); 4385 } 4386 4387 break; 4388 //right 4389 4390 case 39: 4391 if (getIsScrollAllowed().k.right) { 4392 moveSlideRight();
vendor: 5,760 bytes, lines 4392-4573
4392 4393 } 4394 4395 break; 4396 4397 default: 4398 return; 4399 // exit this handler for other keys 4400 } 4401 } //to prevent scrolling while zooming 4402 4403 4404 function keyUpHandler(e) { 4405 if (state.isWindowFocused) { 4406 //the keyup gets fired on new tab ctrl + t in Firefox 4407 g_controlPressed = e.ctrlKey; 4408 } 4409 } //when opening a new tab (ctrl + t), `control` won't be pressed when coming back. 4410 4411 4412 function blurHandler() { 4413 setState({ 4414 isWindowFocused: false 4415 }); 4416 g_controlPressed = false; 4417 } 4418 /** 4419 * Makes sure the tab key will only focus elements within the current section/slide 4420 * preventing this way from breaking the page. 4421 * Based on "Modals and keyboard traps" 4422 * from https://developers.google.com/web/fundamentals/accessibility/focus/using-tabindex 4423 */ 4424 4425 4426 function onTab(e) { 4427 var isShiftPressed = e.shiftKey; 4428 var activeElement = doc.activeElement; 4429 var focusableElements = getFocusables(getSlideOrSection(getState().activeSection.item)); 4430 4431 function preventAndFocusFirst(e) { 4432 preventDefault(e); 4433 return focusableElements[0] ? focusableElements[0].focus() : null; 4434 } // deactivating tab while scrolling #4550 4435 4436 4437 if (!state.canScroll) { 4438 preventDefault(e); 4439 return; 4440 } //outside any section or slide? Let's not hijack the tab! 4441 4442 4443 if (isFocusOutside(e)) { 4444 return; 4445 } //is there an element with focus? 4446 4447 4448 if (activeElement) { 4449 if (closest(activeElement, SECTION_ACTIVE_SEL + ',' + SECTION_ACTIVE_SEL + ' ' + SLIDE_ACTIVE_SEL) == null) { 4450 activeElement = preventAndFocusFirst(e); 4451 } 4452 } //no element if focused? Let's focus the first one of the section/slide 4453 else { 4454 preventAndFocusFirst(e); 4455 } //when reached the first or last focusable element of the section/slide 4456 //we prevent the tab action to keep it in the last focusable element 4457 4458 4459 var isFirstFocusableInSection = activeElement == focusableElements[0]; 4460 var isLastFocusableInSection = activeElement == focusableElements[focusableElements.length - 1]; 4461 var isNextItem = !isShiftPressed && isLastFocusableInSection; 4462 var isPrevItem = isShiftPressed && isFirstFocusableInSection; 4463 4464 if (isPrevItem || isNextItem) { 4465 preventDefault(e); 4466 var focusInfo = getPanelWithFocusable(isPrevItem); 4467 var destinationPanel = focusInfo ? focusInfo.panel : null; 4468 4469 if (destinationPanel) { 4470 var destinationSection = destinationPanel.isSection ? destinationPanel : destinationPanel.parent; 4471 EventEmitter.emit(events.onScrollPageAndSlide, { 4472 sectionAnchor: destinationSection.index() + 1, 4473 slideAnchor: destinationPanel.isSection ? 0 : destinationPanel.index() 4474 }); 4475 g_elToFocus = focusInfo.itemToFocus; 4476 preventDefault(e); 4477 } 4478 } 4479 } 4480 4481 function onAfterSlideLoads(v) { 4482 focusItem(); 4483 } 4484 4485 function afterSectionLoads(v) { 4486 if (!closest(g_elToFocus, SLIDE_SEL) || closest(g_elToFocus, SLIDE_ACTIVE_SEL)) { 4487 focusItem(); 4488 } 4489 } 4490 4491 function focusItem() { 4492 if (g_elToFocus) { 4493 g_elToFocus.focus(); 4494 g_elToFocus = null; 4495 } 4496 } 4497 /** 4498 * Get's the panel containing the element to focus. 4499 * 4500 */ 4501 4502 4503 function getPanelWithFocusable(isPrevItem) { 4504 var action = isPrevItem ? 'prevPanel' : 'nextPanel'; 4505 var focusableElements = []; 4506 var panelWithFocusables; 4507 var currentPanel = getSlideOrSectionPanel(getActivePanel()[action]()); 4508 4509 do { 4510 focusableElements = getFocusables(currentPanel.item); 4511 4512 if (focusableElements.length) { 4513 panelWithFocusables = { 4514 panel: currentPanel, 4515 itemToFocus: focusableElements[isPrevItem ? focusableElements.length - 1 : 0] 4516 }; 4517 } 4518 4519 currentPanel = getSlideOrSectionPanel(currentPanel[action]()); 4520 } while (currentPanel && focusableElements.length === 0); 4521 4522 return panelWithFocusables; 4523 } 4524 /** 4525 * Gets all the focusable elements inside the passed element. 4526 */ 4527 4528 4529 function getFocusables(el) { 4530 return [].slice.call($(focusableElementsString, el)).filter(function (item) { 4531 return getAttr(item, 'tabindex') !== '-1' && //are also not hidden elements (or with hidden parents) 4532 item.offsetParent !== null; 4533 }); 4534 } 4535 /** 4536 * Determines whether the focus is outside fullpage.js sections/slides or not. 4537 */ 4538 4539 4540 function isFocusOutside(e) { 4541 var allFocusables = getFocusables(doc); 4542 var currentFocusIndex = allFocusables.indexOf(doc.activeElement); 4543 var focusDestinationIndex = e.shiftKey ? currentFocusIndex - 1 : currentFocusIndex + 1; 4544 var focusDestination = allFocusables[focusDestinationIndex]; 4545 var destinationItemSlide = closest(focusDestination, SLIDE_SEL); 4546 var destinationItemSection = closest(focusDestination, SECTION_SEL); 4547 return !destinationItemSlide && !destinationItemSection; 4548 } 4549 4550 function shouldCancelKeyboardNavigation(e) { 4551 // https://keycode.info/for/34 4552 // 40 = arrow down 4553 // 38 = arrow up 4554 // 32 = spacebar 4555 // 33 = PageUp 4556 // 34 = PageDown 4557 var keyControls = [40, 38, 32, 33, 34]; 4558 return keyControls.indexOf(e.keyCode) > -1 && !state.isBeyondFullpage; 4559 } //preventing the scroll with arrow keys & spacebar & Page Up & Down keys 4560 4561 4562 function cancelDirectionKeyEvents(e) { 4563 if (shouldCancelKeyboardNavigation(e) && !closest(e.target, OVERFLOW_SEL)) { 4564 e.preventDefault(); 4565 } 4566 } 4567 4568 function getControlPressed() { 4569 return g_controlPressed; 4570 } 4571 4572 var prevTime = new Date().getTime(); 4573 var
4573scrollings = []; 4574 FP.setMouseWheelScrolling = setMouseWheelScrolling; 4575 /** 4576 * Adds or remove the possibility of scrolling through sections by using the mouse wheel or the trackpad. 4577 */ 4578 4579 function setMouseWheelScrolling(value) { 4580 if (value) { 4581 addMouseWheelHandler(); 4582 addMiddleWheelHandler(); 4583 } else { 4584 removeMouseWheelHandler(); 4585 removeMiddleWheelHandler(); 4586 } 4587 } 4588 /** 4589 * Adds the auto scrolling action for the mouse wheel and trackpad. 4590 * After this function is called, the mousewheel and trackpad movements will scroll through sections 4591 * https://developer.mozilla.org/en-US/docs/Web/Events/wheel 4592 */ 4593 4594 4595 function addMouseWheelHandler() { 4596 var prefix = ''; 4597 4598 var _addEventListener; 4599 4600 if (win.addEventListener) { 4601 _addEventListener = "addEventListener"; 4602 } else { 4603 _addEventListener = "attachEvent"; 4604 prefix = 'on'; 4605 } // detect available wheel event 4606 4607
4608 var support = 'onwheel' in doc.createElement('div') ? 'wheel' : // Modern browsers support "wheel" 4609 // @ts-ignore 4610 doc.onmousewheel !== undefined ? 'mousewheel' : // Webkit and IE support at least "mousewheel" 4611 'DOMMouseScroll'; // let's assume that remaining browsers are older Firefox 4612 4613 var passiveEvent = getPassiveOptionsIfPossible(); 4614 4615 if (support == 'DOMMouseScroll') { 4616 doc[_addEventListener](prefix + 'MozMousePixelScroll', MouseWheelHandler, passiveEvent); 4617 } //handle MozMousePixelScroll in older Firefox 4618 else { 4619 doc[_addEventListener](prefix + support, MouseWheelHandler, passiveEvent); 4620 } 4621 } 4622 /** 4623 * Binding the mousemove when the mouse's middle button is pressed 4624 */ 4625 4626 4627 function addMiddleWheelHandler() { 4628 getContainer().addEventListener('mousedown', mouseDownHandler); 4629 getContainer().addEventListener('mouseup', mouseUpHandler); 4630 } 4631 /** 4632 * Removes the auto scrolling action fired by the mouse wheel and trackpad. 4633 * After this function is called, the mousewheel and trackpad movements won't scroll through sections. 4634 */ 4635 4636 4637 function removeMouseWheelHandler() { 4638 if (doc.addEventListener) { 4639 docRemoveEvent('mousewheel', MouseWheelHandler, false); //IE9, Chrome, Safari, Oper 4640 4641 docRemoveEvent('wheel', MouseWheelHandler, false); //Firefox 4642 4643 docRemoveEvent('MozMousePixelScroll', MouseWheelHandler, false); //old Firefox 4644 } else { 4645 // @ts-ignore 4646 doc.detachEvent('onmousewheel', MouseWheelHandler); //IE 6/7/8 4647 } 4648 } 4649 /** 4650 * Unbinding the mousemove when the mouse's middle button is released 4651 */ 4652 4653 4654 function removeMiddleWheelHandler() { 4655 getContainer().removeEventListener('mousedown', mouseDownHandler); 4656 getContainer().removeEventListener('mouseup', mouseUpHandler); 4657 } 4658 /** 4659 * Detecting mousewheel scrolling 4660 * 4661 * http://blogs.sitepointstatic.com/examples/tech/mouse-wheel/index.html 4662 * http://www.sitepoint.com/html5-javascript-mouse-wheel/ 4663 */ 4664 4665 4666 function MouseWheelHandler(e) { 4667 var curTime = new Date().getTime(); 4668 var isNormalScroll = hasClass($(COMPLETELY_SEL)[0], NORMAL_SCROLL); 4669 var isScrollAllowedBeyondFullPage = beyondFullPageHandler(getContainer(), e); 4670 4671 if (!state.isUsingWheel) { 4672 setState({ 4673 isGrabbing: false, 4674 isUsingWheel: true, 4675 touchDirection: 'none' 4676 }); 4677 } //is scroll allowed? 4678 4679 4680 if (!getIsScrollAllowed().m.down && !getIsScrollAllowed().m.up) { 4681 return false; 4682 } 4683 4684 if (isScrollAllowedBeyondFullPage) { 4685 return true; 4686 } else if (isScrollAllowedBeyondFullPage === false) { 4687 preventDefault(e); 4688 return false; 4689 } //autoscrolling and not zooming? 4690 4691 4692 if (getOptions().autoScrolling && !getControlPressed() && !isNormalScroll) { 4693 // cross-browser wheel delta 4694 e = e || win.event; 4695 var value = e.wheelDelta || -e.deltaY || -e.detail; 4696 var delta = Math.max(-1, Math.min(1, value)); 4697 var horizontalDetection = typeof e.wheelDeltaX !== 'undefined' || typeof e.deltaX !== 'undefined'; 4698 var isScrollingVertically = Math.abs(e.wheelDeltaX) < Math.abs(e.wheelDelta) || Math.abs(e.deltaX) < Math.abs(e.deltaY) || !horizontalDetection; 4699 var direction = delta < 0 ? 'down' : delta > 0 ? 'up' : 'none'; //Limiting the array to 150 (lets not waste memory!) 4700 4701 if (scrollings.length > 149) { 4702 scrollings.shift(); 4703 } //keeping record of the previous scrollings 4704 4705 4706 scrollings.push(Math.abs(value)); //preventing to scroll the site on mouse wheel when scrollbar is present 4707 4708 if (getOptions().scrollBar) { 4709 preventDefault(e); 4710 } //time difference between the last scroll and the current one 4711 4712 4713 var timeDiff = curTime - prevTime; 4714 prevTime = curTime; //haven't they scrolled in a while? 4715 //(enough to be consider a different scrolling action to scroll another section) 4716 4717 if (timeDiff > 200) { 4718 //emptying the array, we dont care about old scrollings for our averages 4719 scrollings = []; 4720 } 4721 4722 setState({ 4723 wheelDirection: direction 4724 }); 4725 4726 if (state.canScroll) { 4727 var averageEnd = getAverage(scrollings, 10); 4728 var averageMiddle = getAverage(scrollings, 70); 4729 var isAccelerating = averageEnd >= averageMiddle; //to avoid double swipes... 4730 4731 if (isAccelerating && isScrollingVertically) { 4732 setState({ 4733 scrollTrigger: 'wheel' 4734 }); //scrolling down? 4735 4736 if (delta < 0) { 4737 scrolling('down'); 4738 } //scrolling up? 4739 else { 4740 scrolling('up'); 4741 } 4742 } 4743 } 4744 4745 return false;
vendor: 29,400 bytes, lines 4746-5607
4746 } 4747 4748 if (getOptions().fitToSection) { 4749 //stopping the auto scroll to adjust to a section 4750 setState({ 4751 activeAnimation: false 4752 }); 4753 } 4754 } //binding the mousemove when the mouse's middle button is released 4755 4756 4757 function mouseDownHandler(e) { 4758 //middle button 4759 if (e.which == 2) { 4760 setOldPageY(e.pageY); 4761 getContainer().addEventListener('mousemove', mouseMoveHandler); 4762 } 4763 } //unbinding the mousemove when the mouse's middle button is released 4764 4765 4766 function mouseUpHandler(e) { 4767 //middle button 4768 if (e.which == 2) { 4769 getContainer().removeEventListener('mousemove', mouseMoveHandler); 4770 } 4771 } 4772 /** 4773 * Adds or remove the mouse wheel hijacking 4774 */ 4775 4776 4777 function setMouseHijack(value) { 4778 if (value) { 4779 setMouseWheelScrolling(true); 4780 addTouchHandler(); 4781 } else { 4782 setMouseWheelScrolling(false); 4783 removeTouchHandler(); 4784 } 4785 } 4786 4787 var g_canFireMouseEnterNormalScroll = true; 4788 EventEmitter.on(events.bindEvents, bindEvents$7); 4789 4790 function bindEvents$7() { 4791 /** 4792 * Applying normalScroll elements. 4793 * Ignoring the scrolls over the specified selectors. 4794 */ 4795 if (getOptions().normalScrollElements) { 4796 ['mouseenter', 'touchstart'].forEach(function (eventName) { 4797 forMouseLeaveOrTouch(eventName, false); 4798 }); 4799 ['mouseleave', 'touchend'].forEach(function (eventName) { 4800 forMouseLeaveOrTouch(eventName, true); 4801 }); 4802 } 4803 4804 EventEmitter.on(events.onDestroy, onDestroy$4); 4805 } 4806 4807 function onDestroy$4() { 4808 ['mouseenter', 'touchstart', 'mouseleave', 'touchend'].forEach(function (eventName) { 4809 docRemoveEvent(eventName, onMouseEnterOrLeave, true); //true is required! 4810 }); 4811 } 4812 4813 function forMouseLeaveOrTouch(eventName, allowScrolling) { 4814 //a way to pass arguments to the onMouseEnterOrLeave function 4815 document['fp_' + eventName] = allowScrolling; 4816 docAddEvent(eventName, onMouseEnterOrLeave, true); //capturing phase 4817 } 4818 4819 function onMouseEnterOrLeave(e) { 4820 var type = e.type; 4821 var isInsideOneNormalScroll = false; //onMouseLeave will use the destination target, not the one we are moving away from 4822 4823 var target = type === 'mouseleave' ? e.toElement || e.relatedTarget : e.target; //coming from closing a normalScrollElements modal or moving outside viewport? 4824 4825 if (target == document || !target) { 4826 setMouseHijack(true); 4827 return; 4828 } 4829 4830 if (type === 'touchend') { 4831 g_canFireMouseEnterNormalScroll = false; 4832 setTimeout(function () { 4833 g_canFireMouseEnterNormalScroll = true; 4834 }, 800); 4835 } //preventing mouseenter event to do anything when coming from a touchEnd event 4836 //fixing issue #3576 4837 4838 4839 if (type === 'mouseenter' && !g_canFireMouseEnterNormalScroll) { 4840 return; 4841 } 4842 4843 var normalSelectors = getOptions().normalScrollElements.split(','); 4844 normalSelectors.forEach(function (normalSelector) { 4845 if (!isInsideOneNormalScroll) { 4846 var isNormalScrollTarget = matches(target, normalSelector); //leaving a child inside the normalScoll element is not leaving the normalScroll #3661 4847 4848 var isNormalScrollChildFocused = closest(target, normalSelector); 4849 4850 if (isNormalScrollTarget || isNormalScrollChildFocused) { 4851 if (!FP.shared.isNormalScrollElement) { 4852 setMouseHijack(false); 4853 } 4854 4855 FP.shared.isNormalScrollElement = true; 4856 isInsideOneNormalScroll = true; 4857 } 4858 } 4859 }); //not inside a single normal scroll element anymore? 4860 4861 if (!isInsideOneNormalScroll && FP.shared.isNormalScrollElement) { 4862 setMouseHijack(true); 4863 FP.shared.isNormalScrollElement = false; 4864 } 4865 } 4866 4867 FP.silentMoveTo = silentMoveTo; 4868 /** 4869 * Moves the page to the given section and slide with no animation. 4870 * Anchors or index positions can be used as params. 4871 */ 4872 4873 function silentMoveTo(sectionAnchor, slideAnchor) { 4874 setScrollingSpeed(0, 'internal'); 4875 moveTo$1(sectionAnchor, slideAnchor); 4876 setScrollingSpeed(getOriginals().scrollingSpeed, 'internal'); 4877 } 4878 4879 var previousHeight = getWindowHeight(); 4880 var windowsWidth = getWindowWidth(); 4881 var g_resizeId; 4882 var g_isConsecutiveResize = false; 4883 var g_resizeMobileHandlerId; 4884 FP.reBuild = reBuild; 4885 EventEmitter.on(events.bindEvents, bindEvents$6); 4886 4887 function bindEvents$6() { 4888 // Setting VH correctly in mobile devices 4889 resizeHandler(); //when resizing the site, we adjust the heights of the sections, slimScroll... 4890 4891 windowAddEvent('resize', resizeHandler); 4892 EventEmitter.on(events.onDestroy, onDestroy$3); 4893 } 4894 4895 function onDestroy$3() { 4896 clearTimeout(g_resizeId); 4897 clearTimeout(g_resizeMobileHandlerId); 4898 windowRemoveEvent('resize', resizeHandler); 4899 } 4900 /* 4901 * Resize event handler. 4902 */ 4903 4904 4905 function resizeHandler() { 4906 if (!g_isConsecutiveResize) { 4907 if (getOptions().autoScrolling && !getOptions().scrollBar || !getOptions().fitToSection) { 4908 setSectionsHeight(getWindowHeight()); 4909 } 4910 } // we won't trigger fit to section on page load 4911 // otherwise it will scroll to the worng section if using anchors #4613 4912 4913 4914 if (state.isFullpageInitDone) { 4915 fitToActiveSection(); 4916 } 4917 4918 g_isConsecutiveResize = true; //in order to call the functions only when the resize is finished 4919 //http://stackoverflow.com/questions/4298612/jquery-how-to-call-resize-event-only-once-its-finished-resizing 4920 4921 clearTimeout(g_resizeId); 4922 g_resizeId = setTimeout(function () { 4923 //issue #3336 4924 //(some apps or browsers, like Chrome/Firefox for Mobile take time to report the real height) 4925 //so we check it 3 times with intervals in that case 4926 // for(var i = 0; i< 4; i++){ 4927 resizeActions(); 4928 g_isConsecutiveResize = false; // } 4929 }, 400); 4930 } 4931 4932 function fitToActiveSection() { 4933 if (isTouchDevice) { 4934 // Issue #4393 and previously in v3, #3336 4935 // (some apps or browsers, like Chrome/Firefox will delay a bit to scroll 4936 // to the focused input 4937 for (var i = 0; i < 4; i++) { 4938 g_resizeMobileHandlerId = setTimeout(function () { 4939 window.requestAnimationFrame(function () { 4940 // on Android devices the browser scrolls to the focused element 4941 // messing up the whole page structure. So we need to update the 4942 // translate3d value when the keyboard shows/hides 4943 if (getOptions().autoScrolling && !getOptions().scrollBar) { 4944 setState({ 4945 isResizing: true 4946 }); 4947 silentMoveTo(state.activeSection.index() + 1); 4948 setState({ 4949 isResizing: false 4950 }); 4951 } 4952 }); 4953 }, 200 * i); 4954 } 4955 } 4956 } 4957 /** 4958 * Checks if VH units need to be set based on scrolling configuration 4959 */ 4960 4961 4962 function shouldSetVhUnits() { 4963 return !state.isBeyondFullpage && !getOptions().autoScrolling; 4964 } 4965 /** 4966 * When resizing the site, we adjust the heights of the sections, slimScroll... 4967 */ 4968 4969 4970 function resizeActions() { 4971 setState({ 4972 isResizing: true 4973 }); 4974 4975 if (!isTouchDevice || getOptions().adjustOnNavChange) { 4976 setSectionsHeight(''); 4977 4978 if (shouldSetVhUnits()) { 4979 setVhUnits(); 4980 } 4981 } 4982 4983 EventEmitter.emit(events.contentChanged); 4984 updateState(); //checking if it needs to get responsive 4985 4986 responsive(); // rebuild immediately on touch devices 4987 4988 if (isTouchDevice) { 4989 var activeElement = doc.activeElement; //if the keyboard is NOT visible 4990 4991 if (!matches(activeElement, 'textarea') && !matches(activeElement, 'input') && !matches(activeElement, 'select')) { 4992 var currentHeight = getWindowHeight(); //making sure the change in the viewport size is enough to force a rebuild. (20 % of the window to avoid problems when hidding scroll bars) 4993 4994 if (Math.abs(currentHeight - previousHeight) > 20 * Math.max(previousHeight, currentHeight) / 100) { 4995 reBuild(true); 4996 previousHeight = currentHeight; 4997 } 4998 } 4999 } else { 5000 adjustToNewViewport(); 5001 } 5002 5003 setState({ 5004 isResizing: false 5005 }); 5006 } 5007 /** 5008 * When resizing is finished, we adjust the slides sizes and positions 5009 */ 5010 5011 5012 function reBuild(resizing) { 5013 if (hasClass(getContainer(), DESTROYED)) { 5014 return; 5015 } //nothing to do if the plugin was destroyed 5016 //updating global vars 5017 5018 5019 setState({ 5020 isResizing: true, 5021 windowsHeight: getWindowHeight(), 5022 windowsWidth: getWindowWidth() 5023 }); 5024 var sections = getState().sections; 5025 5026 for (var i = 0; i < sections.length; ++i) { 5027 var section = sections[i]; 5028 var slidesWrap = $(SLIDES_WRAPPER_SEL, section.item)[0]; 5029 var slides = section.slides; //adjusting the position fo the FULL WIDTH slides... 5030 5031 if (slides.length > 1) { 5032 landscapeScroll(slidesWrap, section.activeSlide.item); 5033 } 5034 } 5035 5036 if (getOptions().scrollOverflow) { 5037 scrollOverflowHandler.makeScrollable(); 5038 } 5039 5040 var sectionIndex = getState().activeSection.index(); 5041 5042 if (!state.isBeyondFullpage) { 5043 //isn't it the first section? 5044 if (sectionIndex) { 5045 //adjusting the position for the current section 5046 silentMoveTo(sectionIndex + 1); 5047 } 5048 } 5049 5050 setState({ 5051 isResizing: false 5052 }); 5053 5054 if (isFunction(getOptions().afterResize) && resizing) { 5055 getOptions().afterResize.call(getContainer(), win.innerWidth, win.innerHeight); 5056 } 5057 5058 if (isFunction(getOptions().afterReBuild) && !resizing) { 5059 getOptions().afterReBuild.call(getContainer()); 5060 } 5061 5062 trigger(getContainer(), 'afterRebuild'); 5063 } 5064 /** 5065 * Adjusts a section to the viewport if it has changed. 5066 */ 5067 5068 5069 function adjustToNewViewport() { 5070 var newWindowHeight = getWindowHeight(); 5071 var newWindowWidth = getWindowWidth(); 5072 5073 if (state.windowsHeight !== newWindowHeight || windowsWidth !== newWindowWidth) { 5074 setState({ 5075 windowsHeight: newWindowHeight 5076 }); 5077 windowsWidth = newWindowWidth; 5078 reBuild(true); 5079 } 5080 } 5081 5082 function setSectionsHeight(value) { 5083 var propertyValue = value === '' ? '' : value + 'px'; 5084 getState().sections.forEach(function (section) { 5085 css(section.item, { 5086 'height': propertyValue 5087 }); 5088 }); 5089 } 5090 /** 5091 * Defining the value in px of a VH unit. (Used for autoScrolling: false) 5092 * To fix the height issue on mobile devices when using VH units. 5093 * https://css-tricks.com/the-trick-to-viewport-units-on-mobile/ 5094 */ 5095 5096 5097 function setVhUnits() { 5098 // First we get the viewport height and we multiple it by 1% to get a value for a vh unit 5099 var vh = win.innerHeight * 0.01; // Then we set the value in the --vh custom property to the root of the document 5100 5101 doc.documentElement.style.setProperty('--vh', "".concat(vh, "px")); 5102 } 5103 5104 function getAnchorsURL() { 5105 var section; 5106 var slide; 5107 var hash = win.location.hash; 5108 5109 if (hash.length) { 5110 //getting the anchor link in the URL and deleting the `#` 5111 var anchorsParts = hash.replace('#', '').split('/'); //using / for visual reasons and not as a section/slide separator #2803 5112 5113 var isFunkyAnchor = hash.indexOf('#/') > -1; 5114 section = isFunkyAnchor ? '/' + anchorsParts[1] : decodeURIComponent(anchorsParts[0]); 5115 var slideAnchor = isFunkyAnchor ? anchorsParts[2] : anchorsParts[1]; 5116 5117 if (slideAnchor && slideAnchor.length) { 5118 slide = decodeURIComponent(slideAnchor); 5119 } 5120 } 5121 5122 return { 5123 section: section, 5124 slide: slide 5125 }; 5126 } 5127 5128 FP.setLockAnchors = setLockAnchors; 5129 EventEmitter.on(events.bindEvents, bindEvents$5); 5130 5131 function bindEvents$5() { 5132 //detecting any change on the URL to scroll to the given anchor link 5133 //(a way to detect back history button as we play with the hashes on the URL) 5134 windowAddEvent('hashchange', hashChangeHandler); 5135 EventEmitter.on(events.onDestroy, onDestroy$2); 5136 } 5137 5138 function onDestroy$2() { 5139 windowRemoveEvent('hashchange', hashChangeHandler); 5140 } 5141 /** 5142 * Sets lockAnchors 5143 */ 5144 5145 5146 function setLockAnchors(value) { 5147 getOptions().lockAnchors = value; 5148 } 5149 /** 5150 * Detecting any change on the URL to scroll to the given anchor link 5151 * (a way to detect back history button as we play with the hashes on the URL) 5152 */ 5153 5154 5155 function hashChangeHandler() { 5156 if (!state.isScrolling && !getOptions().lockAnchors) { 5157 var anchors = getAnchorsURL(); 5158 var sectionAnchor = anchors.section; 5159 var slideAnchor = anchors.slide; //when moving to a slide in the first section for the first time (first time to add an anchor to the URL) 5160 5161 var isFirstSlideMove = typeof state.lastScrolledDestiny === 'undefined'; 5162 var isFirstScrollMove = typeof state.lastScrolledDestiny === 'undefined' && typeof slideAnchor === 'undefined' && !state.slideMoving; 5163 5164 if (sectionAnchor && sectionAnchor.length) { 5165 /*in order to call scrollpage() only once for each destination at a time 5166 It is called twice for each scroll otherwise, as in case of using anchorlinks `hashChange` 5167 event is fired on every scroll too.*/ 5168 if (sectionAnchor && sectionAnchor !== state.lastScrolledDestiny && !isFirstSlideMove || isFirstScrollMove || !state.slideMoving && state.lastScrolledSlide != slideAnchor) { 5169 EventEmitter.emit(events.onScrollPageAndSlide, { 5170 sectionAnchor: sectionAnchor, 5171 slideAnchor: slideAnchor 5172 }); 5173 } 5174 } 5175 } 5176 } 5177 5178 EventEmitter.on(events.bindEvents, bindEvents$4); 5179 5180 function bindEvents$4() { 5181 docAddEvent('wheel', wheelDataHandler.registerEvent, getPassiveOptionsIfPossible()); 5182 EventEmitter.on(events.scrollBeyondFullpage, scrollBeyondFullPage); 5183 EventEmitter.on(events.onKeyDown, onKeyDown); 5184 } 5185 5186 EventEmitter.on(events.bindEvents, bindEvents$3); 5187 5188 function bindEvents$3() { 5189 EventEmitter.on(events.onClickOrTouch, onClickOrTouch$1); 5190 } 5191 5192 function onClickOrTouch$1(params) { 5193 var target = params.target; 5194 5195 if (closest(target, getOptions().menu + ' [data-menuanchor]')) { 5196 menuItemsHandler.call(target, params.e); 5197 } 5198 } //Menu item handler when not using anchors or using lockAnchors:true 5199 5200 5201 function menuItemsHandler(e) { 5202 setState({ 5203 scrollTrigger: 'menu' 5204 }); 5205 5206 if ($(getOptions().menu)[0] && (getOptions().lockAnchors || !getOptions().anchors.length)) { 5207 preventDefault(e); 5208 var menuAnchorEl = closest(this, '[data-menuanchor]'); 5209 /*jshint validthis:true */ 5210 5211 EventEmitter.emit(events.onMenuClick, { 5212 anchor: getAttr(menuAnchorEl, 'data-menuanchor') 5213 }); 5214 } 5215 } 5216 5217 EventEmitter.on(events.bindEvents, bindEvents$2); 5218 5219 function bindEvents$2() { 5220 EventEmitter.on(events.onClickOrTouch, onClickOrTouch); 5221 } 5222 5223 function onClickOrTouch(params) { 5224 var target = params.target; 5225 5226 if (target && closest(target, SECTION_NAV_SEL + ' a')) { 5227 sectionBulletHandler.call(target, params.e); 5228 } else if (matches(target, SECTION_NAV_TOOLTIP_SEL)) { 5229 tooltipTextHandler.call(target); 5230 } else if (matches(target, SLIDES_NAV_LINK_SEL) || closest(target, SLIDES_NAV_LINK_SEL) != null) { 5231 slideBulletHandler.call(target, params.e); 5232 } 5233 } 5234 5235 var lastScroll = 0; 5236 var g_scrollId; 5237 var g_scrollId2; 5238 EventEmitter.on(events.onDestroy, onDestroy$1); //when scrolling... 5239 5240 function scrollHandler(e) { 5241 var currentSection; 5242 var currentSectionElem; 5243 5244 if (state.isResizing || !getState().activeSection) { 5245 return; 5246 } 5247 5248 getLast(getState().sections); 5249 5250 if (getState().isBeyondFullpage || getState().isAboutToScrollToFullPage) { 5251 return; 5252 } 5253 5254 if (!getOptions().autoScrolling || getOptions().scrollBar) { 5255 var currentScroll = getScrollTop(); 5256 var scrollDirection = getScrollDirection(currentScroll); 5257 var visibleSectionIndex = 0; 5258 var screen_mid = currentScroll + getWindowHeight() / 2.0; 5259 var isAtBottom = $body.scrollHeight - getWindowHeight() === currentScroll; 5260 var sections = getState().sections; 5261 setState({ 5262 scrollY: currentScroll 5263 }); //when using `auto-height` for a small last section it won't be centered in the viewport 5264 5265 if (isAtBottom) { 5266 visibleSectionIndex = sections.length - 1; 5267 } //is at top? when using `auto-height` for a small first section it won't be centered in the viewport 5268 else if (!currentScroll) { 5269 visibleSectionIndex = 0; 5270 } //taking the section which is showing more content in the viewport 5271 else { 5272 for (var i = 0; i < sections.length; ++i) { 5273 var section = sections[i].item; // Pick the the last section which passes the middle line of the screen. 5274 5275 if (section.offsetTop <= screen_mid) { 5276 visibleSectionIndex = i; 5277 } 5278 } 5279 } 5280 5281 if (isCompletelyInViewPort(scrollDirection)) { 5282 if (!hasClass(getState().activeSection.item, COMPLETELY)) { 5283 addClass(getState().activeSection.item, COMPLETELY); 5284 removeClass(siblings(getState().activeSection.item), COMPLETELY); 5285 } 5286 } //geting the last one, the current one on the screen 5287 5288 5289 currentSection = sections[visibleSectionIndex]; 5290 currentSectionElem = currentSection.item; //setting the visible section as active when manually scrolling 5291 //executing only once the first time we reach the section 5292 5293 if (!currentSection.isActive) { 5294 setState({ 5295 isScrolling: true 5296 }); 5297 var leavingSection = getState().activeSection.item; 5298 var leavingSectionIndex = getState().activeSection.index() + 1; 5299 var yMovement = getYmovement(getState().activeSection, currentSectionElem); 5300 var anchorLink = currentSection.anchor; 5301 var sectionIndex = currentSection.index() + 1; 5302 var activeSlide = currentSection.activeSlide; 5303 var slideIndex; 5304 var slideAnchorLink; 5305 var callbacksParams = { 5306 activeSection: leavingSection, 5307 sectionIndex: sectionIndex - 1, 5308 anchorLink: anchorLink, 5309 element: currentSectionElem, 5310 leavingSection: leavingSectionIndex, 5311 direction: yMovement, 5312 items: { 5313 origin: getState().activeSection, 5314 destination: currentSection 5315 } 5316 }; 5317 5318 if (activeSlide) { 5319 slideAnchorLink = activeSlide.anchor; 5320 slideIndex = activeSlide.index(); 5321 } 5322 5323 if (state.canScroll) { 5324 addClass(currentSectionElem, ACTIVE); 5325 removeClass(siblings(currentSectionElem), ACTIVE); 5326 5327 if (isFunction(getOptions().beforeLeave)) { 5328 fireCallbackOncePerScroll('beforeLeave', callbacksParams); 5329 } 5330 5331 if (isFunction(getOptions().onLeave)) { 5332 fireCallback('onLeave', callbacksParams); 5333 } 5334 5335 if (isFunction(getOptions().afterLoad)) { 5336 fireCallback('afterLoad', callbacksParams); 5337 } 5338 5339 stopMedia(leavingSection); 5340 lazyLoadPanels(currentSection); 5341 playMedia(currentSectionElem); 5342 activateMenuAndNav(anchorLink, sectionIndex - 1); 5343 5344 if (getOptions().anchors.length) { 5345 //needed to enter in hashChange event when using the menu with anchor links 5346 setState({ 5347 lastScrolledDestiny: anchorLink 5348 }); 5349 } 5350 5351 updateState(); 5352 setPageStatus(slideIndex, slideAnchorLink, anchorLink); 5353 } //small timeout in order to avoid entering in hashChange event when scrolling is not finished yet 5354 5355 5356 clearTimeout(g_scrollId); 5357 g_scrollId = setTimeout(function () { 5358 setState({ 5359 isScrolling: false 5360 }); 5361 }, 100); 5362 } 5363 5364 if (getOptions().fitToSection && state.canScroll) { 5365 clearTimeout(g_scrollId2); 5366 g_scrollId2 = setTimeout(function () { 5367 var fixedSections = state.sections.filter(function (section) { 5368 var sectionValues = section.item.getBoundingClientRect(); 5369 return Math.round(sectionValues.bottom) === Math.round(getWindowHeight()) || Math.round(sectionValues.top) === 0; 5370 }); // No section is fitting the viewport? Let's fix that! 5371 5372 if (!fixedSections.length) { 5373 if (isTouchDevice && isFormElementFocused()) { 5374 // Exit early to avoid fixing the section while interacting with form elements 5375 return; 5376 } else { 5377 fitToSection(); 5378 } 5379 } 5380 }, getOptions().fitToSectionDelay); 5381 } 5382 } 5383 } 5384 5385 function isFormElementFocused() { 5386 var focusedElement = document.activeElement; 5387 if (!focusedElement) return false; // Include only elements that trigger the keyboard on mobile 5388 5389 return focusedElement.matches('input, textarea'); 5390 } 5391 5392 function onDestroy$1() { 5393 clearTimeout(g_scrollId); 5394 clearTimeout(g_scrollId2); 5395 } 5396 /** 5397 * Gets the directon of the the scrolling fired by the scroll event. 5398 */ 5399 5400 5401 function getScrollDirection(currentScroll) { 5402 var direction = currentScroll > lastScroll ? 'down' : 'up'; 5403 lastScroll = currentScroll; //needed for auto-height sections to determine if we want to scroll to the top or bottom of the destination 5404 5405 setState({ 5406 previousDestTop: currentScroll 5407 }); 5408 return direction; 5409 } 5410 /** 5411 * Determines whether the active section has seen in its whole or not. 5412 */ 5413 5414 5415 function isCompletelyInViewPort(movement) { 5416 var top = getState().activeSection.item.offsetTop; 5417 var bottom = top + getWindowHeight(); 5418 5419 if (movement == 'up') { 5420 return bottom >= getScrollTop() + getWindowHeight(); 5421 } 5422 5423 return top <= getScrollTop(); 5424 } 5425 5426 EventEmitter.on(events.bindEvents, bindEvents$1); 5427 EventEmitter.on(events.onDestroy, onDestroy); 5428 5429 function onDestroy() { 5430 windowRemoveEvent('scroll', scrollHandler); 5431 } 5432 5433 function bindEvents$1() { 5434 windowAddEvent('scroll', scrollHandler); 5435 doc.body.addEventListener('scroll', scrollHandler); 5436 EventEmitter.on(events.onScrollPageAndSlide, function (params) { 5437 scrollPageAndSlide(params.sectionAnchor, params.slideAnchor); 5438 }); 5439 EventEmitter.on(events.onMenuClick, function (params) { 5440 moveTo$1(params.anchor, undefined); 5441 }); 5442 EventEmitter.on(events.onScrollOverflowScrolled, function (params) { 5443 var scrollSection = params.direction === 'down' ? moveSectionDown : moveSectionUp; 5444 scrollSection(); 5445 }); 5446 EventEmitter.on(events.scrollPage, function (params) { 5447 scrollPage(params.destination); 5448 }); 5449 } 5450 5451 FP.getActiveSlide = getActiveSlide; 5452 5453 FP.getScrollX = function () { 5454 return state.scrollX; 5455 }; 5456 5457 EventEmitter.on(events.bindEvents, bindEvents); 5458 5459 function bindEvents() { 5460 EventEmitter.on(events.onDestroy, onDestroy$6); 5461 EventEmitter.on(events.landscapeScroll, function (params) { 5462 landscapeScroll(params.slides, params.destination); 5463 }); 5464 EventEmitter.on(events.moveSlideRight, function (params) { 5465 moveSlideRight(params.section); 5466 }); 5467 EventEmitter.on(events.moveSlideLeft, function (params) { 5468 moveSlideLeft(params.section); 5469 }); 5470 EventEmitter.on(events.afterSectionLoads, updateScrollX); 5471 } 5472 5473 function updateScrollX(params) { 5474 var activeSlide = params.items.destination.activeSlide; 5475 var scrollX = activeSlide ? Math.round(activeSlide.offsetLeft) : 0; 5476 setState({ 5477 scrollX: scrollX 5478 }); 5479 } 5480 /** 5481 * Gets the active slide. 5482 */ 5483 5484 5485 function getActiveSlide() { 5486 return nullOrSlide(getState().activeSection.activeSlide); 5487 } 5488 5489 EventEmitter.on(events.bindEvents, init$1); 5490 5491 function init$1() { 5492 var position = getOptions().credits.position || 'right'; 5493 var positionStyle = ['left', 'right'].indexOf(position) > -1 ? "".concat(position, ": 0;") : ''; 5494 var waterMark = ""//"\n <div class=\"".concat(WATERMARK, "\" style=\"").concat(positionStyle, "\">\n <a href=\"https://alvarotrigo.com/fullPage/\" \n rel=\"nofollow noopener\" \n target=\"_blank\" \n style=\"text-decoration:none; color: #000;\">\n ").concat(getOptions().credits.label || 'Made with fullPage.js', "\n </a>\n </div>\n "); 5495 var lastSection = getLast(state.sections); 5496 var shouldUseWaterMark = !state.isValid || getOptions().credits.enabled; 5497 5498 if (lastSection && lastSection.item && shouldUseWaterMark) { 5499 lastSection.item.insertAdjacentHTML('beforeend', waterMark); 5500 } 5501 } 5502 5503 !function () { 5504 EventEmitter.on(events.onInitialise, function () { 5505 var n, a, l; 5506 setState({ 5507 isValid: (getOptions().licenseKey, n = getOptions().licenseKey, a = function (n) { 5508 return true; 5509 var e = parseInt("\x35\x31\x34").toString(16); 5510 if (!n || n.length < 29 || 4 === n.split(t[0]).length) return null; 5511 var r = ["\x45\x61\x63\x68", "\x66\x6f\x72"][i()]().join(""), 5512 a = n[["\x73\x70\x6c\x69\x74"]]("-"), 5513 l = []; 5514 a[r](function (t, n) { 5515 if (n < 4) { 5516 var r = function (t) { 5517 var n = t[t.length - 1], 5518 e = ["\x4e\x61\x4e", "\x69\x73"][i()]().join(""); 5519 return window[e](n) ? o(n) : function (t) { 5520 return t - ACTIVE.length; 5521 }(n); 5522 }(t); 5523 5524 l.push(r); 5525 var s = o(t[r]); 5526 5527 if (1 === n) { 5528 var a = ["\x70\x61", "\x64\x53", "\x74", "\x61\x72\x74"].join(""); 5529 s = s.toString()[a](2, "0"); 5530 } 5531 5532 e += s, 0 !== n && 1 !== n || (e += "-"); 5533 } 5534 }); 5535 var f = 0, 5536 m = ""; 5537 return n.split("-").forEach(function (t, n) { 5538 if (n < 4) { 5539 var _i = 0; 5540 5541 for (var e = 0; e < 4; e++) { 5542 e !== l[n] && (_i += Math.abs(o(t[e])), isNaN(t[e]) || f++); 5543 } 5544 5545 var r = s(_i); 5546 m += r; 5547 } 5548 }), m += s(f), { 5549 v: new Date(e + "T00:00"), 5550 o: e.split("-")[2] === 8 * (ACTIVE.length - 2) + "", 5551 l: m 5552 }; 5553 }(n), l = function (t) { 5554 var n = r[i()]().join(""); 5555 return t && 0 === n.indexOf(t) && t.length === n.length; 5556 }(n) || function (t) { 5557 return new RegExp("^(?=.*?[A-Y])(?=.*?[a-y])(?=.*?[0-8])(?=.*?[#?!@$%^&*-]).{8,}$").test(t); 5558 }(n), (a || l) && (a && e <= a.v && a.l === n.split(t[0])[4] || l || a.o) || !1) 5559 }); 5560 }); 5561 var t = ["-"]; 5562 var n = "\x32\x30\x32\x35\x2d\x32\x2d\x33".split("-"), 5563 e = new Date(n[0], n[1], n[2]), 5564 r = ["se", "licen", "-", "v3", "l", "gp"]; 5565 5566 function i() { 5567 return [["\x72\x65", "\x76\x65\x72\x73\x65"].join("")]["".length]; 5568 } 5569 5570 function o(t) { 5571 return t ? isNaN(t) ? t.charCodeAt(0) - 72 : t : ""; 5572 } 5573 5574 function s(t) { 5575 var n = 72 + t; 5576 return n > 90 && n < 97 && (n += 15), String.fromCharCode(n).toUpperCase(); 5577 } 5578 }(); 5579 5580 EventEmitter.on(events.onPerformMovement, onSlideOrScroll); 5581 EventEmitter.on(events.afterSectionLoads, afterPanelLoad); 5582 EventEmitter.on(events.onSlideLeave, onSlideOrScroll); 5583 EventEmitter.on(events.afterSlideLoads, afterPanelLoad); 5584 5585 function onSlideOrScroll(params) { 5586 var skipValue = getOptions().skipIntermediateItems; 5587 var scrollType = params.items.origin.isSection ? 'sections' : 'slides'; 5588 var areConsecutivePanels = Math.abs(params.items.origin.index() - params.items.destination.index()) > 1; 5589 var doesApply = (skipValue === true || skipValue === scrollType) && areConsecutivePanels; 5590 5591 if (doesApply) { 5592 setScrollingSpeed(0, 'internal'); 5593 } 5594 } 5595 5596 function afterPanelLoad(params) { 5597 if (getOptions().skipIntermediateItems) { 5598 setVariableState('scrollingSpeed', getOriginals().scrollingSpeed, 'internal'); 5599 } 5600 } 5601 5602 //@ts-check 5603 EventEmitter.on(events.beforeInit, beforeInit); 5604 FP.setKeyboardScrolling = setKeyboardScrolling; 5605 5606 function beforeInit() { 5607 setKeyboardScrolling(true
vendor: 7,306 bytes, lines 5607-5831
5607); 5608 } 5609 /** 5610 * Adds or remove the possibility of scrolling through sections by using the keyboard arrow keys 5611 */ 5612 5613 5614 function setKeyboardScrolling(value, directions) { 5615 if (typeof directions !== 'undefined') { 5616 directions = directions.replace(/ /g, '').split(','); 5617 directions.forEach(function (direction) { 5618 setIsScrollAllowed(value, direction, 'k'); 5619 }); 5620 } else { 5621 setIsScrollAllowed(value, 'all', 'k'); 5622 getOptions().keyboardScrolling = value; 5623 } 5624 } 5625 5626 /** 5627 * Sets the data-anchor attributes to the menu elements and activates the current one. 5628 */ 5629 5630 function styleMenu(section) { 5631 var index = section.index(); 5632 5633 if (typeof getOptions().anchors[index] !== 'undefined') { 5634 //activating the menu / nav element on load 5635 if (section.isActive) { 5636 activateMenuAndNav(getOptions().anchors[index], index); 5637 } 5638 } //moving the menu outside the main container if it is inside (avoid problems with fixed positions when using CSS3 tranforms) 5639 5640 5641 if (getOptions().menu && getOptions().css3 && closest($(getOptions().menu)[0], WRAPPER_SEL) != null) { 5642 $(getOptions().menu).forEach(function (menu) { 5643 $body.appendChild(menu); 5644 }); 5645 } 5646 } 5647 5648 /** 5649 * Works over the DOM structure to set it up for the current fullpage getOptions(). 5650 */ 5651 5652 function prepareDom() { 5653 css(getParentsUntil(getContainer(), 'body'), { 5654 'height': '100%', 5655 'position': 'relative' 5656 }); //adding a class to recognize the container internally in the code 5657 5658 addClass(getContainer(), WRAPPER); 5659 addClass($html, ENABLED); //due to https://github.com/alvarotrigo/fullPage.js/issues/1502 5660 5661 setState({ 5662 windowsHeight: getWindowHeight() 5663 }); 5664 removeClass(getContainer(), DESTROYED); //in case it was destroyed before initializing it again 5665 5666 addInternalSelectors(); 5667 var sections = getState().sectionsIncludingHidden; //styling the sections / slides / menu 5668 5669 for (var i = 0; i < sections.length; i++) { 5670 var section = sections[i]; 5671 var slides = section.allSlidesItems; //caching the original styles to add them back on destroy('all') 5672 5673 var originalStyles = getAttr(section.item, 'style'); 5674 5675 if (originalStyles) { 5676 section.item.setAttribute('data-fp-styles', originalStyles); 5677 } 5678 5679 styleSection(section); 5680 styleMenu(section); // if there's any slide 5681 5682 if (slides.length > 0) { 5683 styleSlides(section); 5684 } 5685 } //fixed elements need to be moved out of the plugin container due to problems with CSS3. 5686 5687 5688 if (getOptions().fixedElements && getOptions().css3) { 5689 $(getOptions().fixedElements).forEach(function (item) { 5690 $body.appendChild(item); 5691 }); 5692 } //vertical centered of the navigation + active bullet 5693 5694 5695 if (getOptions().navigation) { 5696 addVerticalNavigation(); 5697 } 5698 5699 enableYoutubeAPI(); 5700 5701 if (getOptions().scrollOverflow) { 5702 scrollOverflowHandler.makeScrollable(); 5703 } 5704 } 5705 5706 FP.shared.afterRenderActions = afterRenderActions; 5707 /** 5708 * Actions and callbacks to fire afterRender 5709 */ 5710 5711 function afterRenderActions() { 5712 var section = getState().activeSection; 5713 var sectionElem = getState().activeSection.item; 5714 addClass(sectionElem, COMPLETELY); 5715 lazyLoadPanels(getState().activeSection); 5716 lazyLoadOthers(); 5717 playMedia(sectionElem); 5718 5719 if (isDestinyTheStartingSection() && isFunction(getOptions().afterLoad)) { 5720 fireCallback('afterLoad', { 5721 activeSection: sectionElem, 5722 element: sectionElem, 5723 direction: null, 5724 //for backwards compatibility callback (to be removed in a future!) 5725 anchorLink: section.anchor, 5726 sectionIndex: section.index(), 5727 items: { 5728 origin: getState().activeSection, 5729 destination: getState().activeSection 5730 } 5731 }); 5732 } 5733 5734 if (isFunction(getOptions().afterRender)) { 5735 fireCallback('afterRender'); 5736 } 5737 } 5738 /** 5739 * Determines if the URL anchor destiny is the starting section (the one using 'active' class before initialization) 5740 */ 5741 5742 function isDestinyTheStartingSection() { 5743 var anchor = getAnchorsURL(); 5744 var destinationSection = getSectionByAnchor(anchor.section); 5745 return !anchor.section || !destinationSection || typeof destinationSection !== 'undefined' && destinationSection.index() === index(getStartingSection()); 5746 } 5747 5748 FP.setAllowScrolling = setAllowScrolling; 5749 /** 5750 * Adds or remove the possibility of scrolling through sections by using the mouse wheel/trackpad or touch gestures. 5751 * Optionally a second parameter can be used to specify the direction for which the action will be applied. 5752 * 5753 * @param directions string containing the direction or directions separated by comma. 5754 */ 5755 5756 function setAllowScrolling(value, directions) { 5757 if (typeof directions !== 'undefined') { 5758 directions = directions.replace(/ /g, '').split(','); 5759 directions.forEach(function (direction) { 5760 setIsScrollAllowed(value, direction, 'm'); 5761 }); 5762 } else { 5763 setIsScrollAllowed(value, 'all', 'm'); 5764 } 5765 } 5766 5767 /** 5768 * Scrolls to the anchor in the URL when loading the site 5769 */ 5770 5771 function scrollToAnchor() { 5772 var anchors = getAnchorsURL(); 5773 var sectionAnchor = anchors.section; 5774 var slideAnchor = anchors.slide; 5775 5776 if (sectionAnchor) { 5777 //if theres any # 5778 if (getOptions().animateAnchor) { 5779 scrollPageAndSlide(sectionAnchor, slideAnchor); 5780 } else { 5781 silentMoveTo(sectionAnchor, slideAnchor); 5782 } 5783 } else { 5784 EventEmitter.emit(events.onAfterRenderNoAnchor, null); 5785 } 5786 } 5787 5788 /* 5789 * Removes inline styles added by fullpage.js 5790 */ 5791 5792 function destroyStructure() { 5793 //reseting the `top` or `translate` properties to 0 5794 silentScroll(0); //loading all the lazy load content 5795 5796 $('img[data-src], source[data-src], audio[data-src], iframe[data-src]', getContainer()).forEach(function (item) { 5797 setSrc(item, 'src'); 5798 }); 5799 $('img[data-srcset]').forEach(function (item) { 5800 setSrc(item, 'srcset'); 5801 }); 5802 remove($(SECTION_NAV_SEL + ', ' + SLIDES_NAV_SEL + ', ' + SLIDES_ARROW_SEL + ', ' + WATERMARK_SEL)); //removing inline styles 5803 5804 css(getNodes(getState().sections), { 5805 'height': '', 5806 'background-color': '', 5807 'padding': '' 5808 }); 5809 css(getNodes(getState().slides), { 5810 'width': '' 5811 }); 5812 css(getContainer(), { 5813 'height': '', 5814 'position': '', 5815 '-ms-touch-action': '', 5816 'touch-action': '' 5817 }); 5818 css($htmlBody, { 5819 'overflow': '', 5820 'height': '' 5821 }); // remove .fp-enabled class 5822 5823 removeClass($html, ENABLED); // remove .fp-responsive class & .fp-scrollable 5824 5825 removeClass($body, RESPONSIVE + ' ' + SCROLLABLE); // remove all of the .fp-viewing- classes 5826 5827 $body.className.split(/\s+/).forEach(function (className) { 5828 if (className.indexOf(VIEWING_PREFIX) === 0) { 5829 removeClass($body, className); 5830 } 5831 });
5831 //removing added classes 5832 5833 getNodes(getState().panels).forEach(function (item) { 5834 if (getOptions().scrollOverflow) { 5835 scrollOverflowHandler.destroyWrapper(item); 5836 } 5837 5838 removeClass(item, TABLE + ' ' + ACTIVE + ' ' + COMPLETELY + ' ' + IS_OVERFLOW + ' ' + LOADED); 5839 var previousStyles = getAttr(item, 'data-fp-styles'); 5840 5841 if (previousStyles) { 5842 item.setAttribute('style', previousStyles); 5843 } //removing anchors if they were not set using the HTML markup 5844 5845 5846 if (hasClass(item, SECTION) && !getInitialAnchorsInDom()) { 5847 item.removeAttribute('data-anchor'); 5848 } 5849 }); //removing the applied transition from the fullpage wrapper 5850 5851 removeAnimation(getContainer()); //Unwrapping content 5852 5853 [TABLE_CELL_SEL, SLIDES_CONTAINER_SEL, SLIDES_WRAPPER_SEL].forEach(function (selector) { 5854 $(selector, getContainer()).forEach(function (item) { 5855 //unwrap not being use in case there's no child element inside and its just text 5856 unwrap(item); 5857 }); 5858 }); //removing the applied transition from the fullpage wrapper 5859 5860 css(getContainer(), { 5861 '-webkit-transition': 'none', 5862 'transition': 'none' 5863 }); 5864 removeClass(getContainer(), WRAPPER); //scrolling the page to the top with no animation 5865 5866 win.scrollTo(0, 0); //removing selectors 5867 5868 var usedSelectors = [SECTION, SLIDE, SLIDES_CONTAINER]; 5869 usedSelectors.forEach(function (item) { 5870 removeClass($('.' + item), item); 5871 }); 5872 } 5873 5874 FP.destroy = destroy; 5875 function init() { 5876 updateStructuralState(); 5877 updateState(); 5878 getOptions().scrollBar = getOptions().scrollBar || getOptions().hybrid; 5879 setOptionsFromDOM(); 5880 prepareDom(); 5881 setAllowScrolling(true); 5882 setMouseHijack(true); 5883 setAutoScrolling(getOptions().autoScrolling, 'internal'); 5884 responsive(); //setting the class for the body element 5885 5886 setBodyClass(); 5887 5888 if (doc.readyState === 'complete') { 5889 scrollToAnchor(); 5890 } 5891 5892 windowAddEvent('load', scrollToAnchor); 5893 afterRenderActions(); // Updating the state again with the new DOM 5894 5895 updateStructuralState(); 5896 updateState(); 5897 } 5898 /* 5899 * Destroys fullpage.js plugin events and optinally its html markup and styles 5900 */ 5901 5902 function destroy(all) { 5903 setAutoScrolling(false, 'internal'); 5904 setAllowScrolling(true); 5905 setMouseHijack(false); 5906 setKeyboardScrolling(false); 5907 addClass(getContainer(), DESTROYED); 5908 EventEmitter.emit(events.onDestroy); //lets make a mess! 5909 5910 if (all) { 5911 destroyStructure(); 5912 } 5913 } 5914 5915 var isOK = function isOK() { 5916 return true; 5917 return getOptions() && state.isValid || doc.domain.indexOf('al' + 'varotri' + 'go' + '.' + 'com') > -1; 5918 }; 5919 /** 5920 * Displays warnings 5921 */ 5922 5923 5924 function displayWarnings() { 5925 var l = getOptions()['li' + 'c' + 'enseK' + 'e' + 'y']; 5926 var msgStyle = 'font-size: 15px;background:yellow;'; 5927 5928 if (false && getOptions().licenseKey.trim() === '') { 5929 showError('error', 'Fullpage.js requires a `licenseKey` option. Read about it on the following website:'); 5930 showError('error', 'https://alvarotrigo.com/fullPage/docs/#licensekey'); 5931 } else if (!isOK()) { 5932 showError('error', 'Incorrect `licenseKey`. Get one for fullPage.js version 4 here:'); 5933 showError('error', 'https://alvarotrigo.com/fullPage/pricing'); 5934 } else if (l && l.length < 20) { 5935 console.warn('%c This website was made using fullPage.js slider. Learn more on the following website:', msgStyle); 5936 console.warn('%c https://alvarotrigo.com/fullPage/', msgStyle); 5937 } 5938 5939 if (hasClass($html, ENABLED)) { 5940 showError('error', 'Fullpage.js can only be initialized once and you are doing it multiple times!'); 5941 return; 5942 } // Disable mutually exclusive settings 5943 5944 5945 if (getOptions().continuousVertical && (getOptions().loopTop || getOptions().loopBottom)) { 5946 getOptions().continuousVertical = false;
vendor: 5,053 bytes, lines 5947-6097
5947 showError('warn', 'Option `loopTop/loopBottom` is mutually exclusive with `continuousVertical`; `continuousVertical` disabled'); 5948 } 5949 5950 if (getOptions().scrollOverflow && (getOptions().scrollBar || !getOptions().autoScrolling)) { 5951 showError('warn', 'Options scrollBar:true and autoScrolling:false are mutually exclusive with scrollOverflow:true. Sections with scrollOverflow might not work well in Firefox'); 5952 } 5953 5954 if (getOptions().continuousVertical && (getOptions().scrollBar || !getOptions().autoScrolling)) { 5955 getOptions().continuousVertical = false; 5956 showError('warn', 'Scroll bars (`scrollBar:true` or `autoScrolling:false`) are mutually exclusive with `continuousVertical`; `continuousVertical` disabled'); 5957 } //using extensions? Wrong file! 5958 5959 5960 extensions.forEach(function (extension) { 5961 //is the option set to true? 5962 if (getOptions()[extension]) { 5963 showError('warn', 'fullpage.js extensions require fullpage.extensions.min.js file instead of the usual fullpage.js. Requested: ' + extension); 5964 } 5965 }); //anchors can not have the same value as any element ID or NAME 5966 5967 getOptions().anchors.forEach(function (name) { 5968 //case insensitive selectors (http://stackoverflow.com/a/19465187/1081396) 5969 var nameAttr = [].slice.call($('[name]')).filter(function (item) { 5970 return getAttr(item, 'name') && getAttr(item, 'name').toLowerCase() == name.toLowerCase(); 5971 }); 5972 var idAttr = [].slice.call($('[id]')).filter(function (item) { 5973 return getAttr(item, 'id') && getAttr(item, 'id').toLowerCase() == name.toLowerCase(); 5974 }); 5975 5976 if (idAttr.length || nameAttr.length) { 5977 showError('error', 'data-anchor tags can not have the same value as any `id` element on the site (or `name` element for IE).'); 5978 var propertyName = idAttr.length ? 'id' : 'name'; 5979 5980 if (idAttr.length || nameAttr.length) { 5981 showError('error', '"' + name + '" is is being used by another element `' + propertyName + '` property'); 5982 } 5983 } 5984 }); 5985 } 5986 5987 function fullpage(containerSelector, options) { 5988 setCache(); //only once my friend! 5989 5990 if (hasClass($html, ENABLED)) { 5991 displayWarnings(); 5992 return; 5993 } 5994 5995 setOption('touchWrapper', typeof containerSelector === 'string' ? $(containerSelector)[0] : containerSelector); // Creating some defaults, extending them with any options that were provided 5996 5997 setOptions(options); 5998 setContainer(typeof containerSelector === 'string' ? $(containerSelector)[0] : containerSelector); 5999 EventEmitter.emit(events.onInitialise); 6000 displayWarnings(); 6001 setAPI(); 6002 6003 if (getContainer()) { 6004 EventEmitter.emit(events.beforeInit); 6005 init(); 6006 EventEmitter.emit(events.bindEvents); 6007 } 6008 6009 setState({ 6010 isFullpageInitDone: true 6011 }); // @ts-ignore 6012 6013 return win.fullpage_api; 6014 } 6015 6016 function setAPI() { 6017 FP.getFullpageData = function () { 6018 return { 6019 options: getOptions() 6020 }; 6021 }; //public functions 6022 6023 6024 FP.version = '4.0.34'; 6025 FP.test = Object.assign(FP.test, { 6026 top: '0px', 6027 translate3d: 'translate3d(0px, 0px, 0px)', 6028 translate3dH: function () { 6029 var a = []; 6030 6031 for (var i = 0; i < $(getOptions().sectionSelector, getContainer()).length; i++) { 6032 a.push('translate3d(0px, 0px, 0px)'); 6033 } 6034 6035 return a; 6036 }(), 6037 left: function () { 6038 var a = []; 6039 6040 for (var i = 0; i < $(getOptions().sectionSelector, getContainer()).length; i++) { 6041 a.push(0); 6042 } 6043 6044 return a; 6045 }(), 6046 options: getOptions(), 6047 setAutoScrolling: null 6048 }); //functions we want to share across files but which are not 6049 //mean to be used on their own by developers 6050 6051 FP.shared = Object.assign(FP.shared, { 6052 afterRenderActions: null, 6053 isNormalScrollElement: false 6054 }); // @ts-ignore 6055 6056 win.fullpage_api = FP; 6057 } 6058 6059 // @ts-ignore 6060 6061 win.fp_easings = deepExtend(win.fp_easings, { 6062 easeInOutCubic: function easeInOutCubic(t, b, c, d) { 6063 if ((t /= d / 2) < 1) return c / 2 * t * t * t + b; 6064 return c / 2 * ((t -= 2) * t * t + 2) + b; 6065 } 6066 }); 6067 6068 /** 6069 * jQuery adapter for fullPage.js 3.0.0 6070 */ 6071 // @ts-ignore 6072 6073 if (win.jQuery) { 6074 (function ($, fullpage) { 6075 6076 if (!$ || !fullpage) { 6077 showError('error', 'jQuery is required to use the jQuery fullpage adapter!'); 6078 return; 6079 } 6080 6081 $.fn.fullpage = function (options) { 6082 options = $.extend({}, options, { 6083 '$': $ 6084 }); 6085 new fullpage(this[0], options); // Creating the $.fn.fullpage object 6086 6087 Object.keys(FP).forEach(function (key) { 6088 getOptions().$.fn.fullpage[key] = FP[key]; 6089 }); 6090 }; // @ts-ignore 6091 6092 })(win.jQuery, fullpage); 6093 } 6094 6095 return fullpage; 6096 6097}));
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.