1/** 2 * fullPage 2.1.2 3 * https://github.com/alvarotrigo/fullPage.js 4 * MIT licensed 5 * 6 * Copyright (C) 2013 alvarotrigo.com - A project by Alvaro Trigo 7 */ 8 9(function($) { 10 $.fn.fullpage = function(options) { 11 // Create some defaults, extending them with any options that were provided 12 options = $.extend({ 13 "verticalCentered": true, 14 'resize': true, 15 'slidesColor' : [], 16 'anchors':[], 17 'scrollingSpeed': 700, 18 'easing': 'easeInQuart', 19 'menu': false, 20 'navigation': false, 21 'navigationPosition': 'right', 22 'navigationColor': '#000', 23 'navigationTooltips': [], 24 'slidesNavigation': false, 25 'slidesNavPosition': 'bottom', 26 'controlArrowColor': '#fff', 27 'loopBottom': false, 28 'loopTop': false, 29 'loopHorizontal': true, 30 'autoScrolling': true, 31 'scrollOverflow': false, 32 'css3': false, 33 'paddingTop': 0, 34 'paddingBottom': 0, 35 'fixedElements': null, 36 'normalScrollElements': null, 37 'keyboardScrolling': true, 38 'touchSensitivity': 5, 39 'continuousVertical': false, 40 'animateAnchor': true, 41 'normalScrollElementTouchThreshold': 5, 42 43 //events 44 'afterLoad': null, 45 'onLeave': null, 46 'afterRender': null, 47 'afterResize': null, 48 'afterSlideLoad': null, 49 'onSlideLeave': null 50 }, options); 51 52 // Disable mutually exclusive settings 53 if (options.continuousVertical && 54 (options.loopTop || options.loopBottom)) { 55 options.continuousVertical = false;
56 console && console.log && console.log("Option loopTop/loopBottom is mutually exclusive with continuousVertical; continuousVertical disabled"); 57 } 58 59 //Defines the delay to take place before being able to scroll to the next section 60 //BE CAREFUL! Not recommened to change it under 400 for a good behavior in laptops and 61 //Apple devices (laptops, mouses...) 62 var scrollDelay = 600; 63 64 $.fn.fullpage.setAutoScrolling = function(value){ 65 options.autoScrolling = value; 66 67 var element = $('.section.active'); 68 69 if(options.autoScrolling){ 70 $('html, body').css({ 71 'overflow' : 'hidden', 72 'height' : '100%' 73 }); 74 75 if(element.length){ 76 //moving the container up 77 silentScroll(element.position().top); 78 } 79 80 }else{ 81 $('html, body').css({ 82 'overflow' : 'auto', 83 'height' : 'auto' 84 }); 85 86 silentScroll(0); 87 88 //scrolling the page to the section with no animation 89 $('html, body').scrollTop(element.position().top); 90 } 91 92 }; 93 94 /** 95 * Defines the scrolling speed 96 */ 97 $.fn.fullpage.setScrollingSpeed = function(value){ 98 options.scrollingSpeed = value; 99 }; 100 101 /** 102 * Adds or remove the possiblity of scrolling through sections by using the mouse wheel or the trackpad. 103 */ 104 $.fn.fullpage.setMouseWheelScrolling = function (value){ 105 if(value){ 106 addMouseWheelHandler(); 107 }else{ 108 removeMouseWheelHandler(); 109 } 110 }; 111 112 /** 113 * Adds or remove the possiblity of scrolling through sections by using the mouse wheel/trackpad or touch gestures. 114 */ 115 $.fn.fullpage.setAllowScrolling = function (value){ 116 if(value){ 117 $.fn.fullpage.setMouseWheelScrolling(true); 118 addTouchHandler(); 119 }else{ 120 $.fn.fullpage.setMouseWheelScrolling(false); 121 removeTouchHandler(); 122 } 123 }; 124 125 /** 126 * Adds or remove the possiblity of scrolling through sections by using the keyboard arrow keys 127 */ 128 $.fn.fullpage.setKeyboardScrolling = function (value){ 129 options.keyboardScrolling = value; 130 }; 131 132 //flag to avoid very fast sliding for landscape sliders 133 var slideMoving = false; 134 135 var isTouchDevice = navigator.userAgent.match(/(iPhone|iPod|iPad|Android|BlackBerry|BB10|Windows Phone|Tizen|Bada)/); 136 var container = $(this); // for compatibity reasons for fullpage < v2.0 137 var windowsHeight = $(window).height(); 138 var isMoving = false; 139 var isResizing = false; 140 var lastScrolledDestiny; 141 var lastScrolledSlide; 142 143 $.fn.fullpage.setAllowScrolling(true); 144 145 //if css3 is not supported, it will use jQuery animations 146 if(options.css3){ 147 options.css3 = support3d(); 148 } 149 150 if($(this).length){ 151 container.css({ 152 'height': '100%', 153 'position': 'relative', 154 '-ms-touch-action': 'none' 155 }); 156 } 157 158 //for compatibity reasons for fullpage < v2.0 159 else{ 160 $('body').wrapInner('<div id="superContainer" />'); 161 container = $('#superContainer'); 162 } 163 164 //creating the navigation dots 165 if (options.navigation) { 166 $('body').append('<div id="fullPage-nav"><ul></ul></div>'); 167 var nav = $('#fullPage-nav'); 168 169 nav.css('color', options.navigationColor); 170 nav.addClass(options.navigationPosition); 171 } 172 173 $('.section').each(function(index){ 174 var that = $(this); 175 var slides = $(this).find('.slide'); 176 var numSlides = slides.length; 177 178 //if no active section is defined, the 1st one will be the default one 179 if(!index && $('.section.active').length === 0) { 180 $(this).addClass('active'); 181 } 182 183 $(this).css('height', windowsHeight + 'px'); 184 185 if(options.paddingTop || options.paddingBottom){ 186 $(this).css('padding', options.paddingTop + ' 0 ' + options.paddingBottom + ' 0'); 187 } 188 189 if (typeof options.slidesColor[index] !== 'undefined') { 190 $(this).css('background-color', options.slidesColor[index]); 191 } 192 193 if (typeof options.anchors[index] !== 'undefined') { 194 $(this).attr('data-anchor', options.anchors[index]); 195 } 196 197 if (options.navigation) { 198 var link = ''; 199 if(options.anchors.length){ 200 link = options.anchors[index]; 201 } 202 var tooltip = options.navigationTooltips[index]; 203 if(typeof tooltip === 'undefined'){ 204 tooltip = ''; 205 } 206 207 nav.find('ul').append('<li data-tooltip="' + tooltip + '"><a href="#' + link + '"><span></span></a></li>'); 208 } 209 210 211 // if there's any slide 212 if (numSlides > 1) { 213 var sliderWidth = numSlides * 100; 214 var slideWidth = 100 / numSlides; 215 216 slides.wrapAll('<div class="slidesContainer" />'); 217 slides.parent().wrap('<div class="slides" />'); 218 219 $(this).find('.slidesContainer').css('width', sliderWidth + '%'); 220 $(this).find('.slides').after('<div class="controlArrow prev"></div><div class="controlArrow next"></div>'); 221 222 if(options.controlArrowColor!='#fff'){ 223 $(this).find('.controlArrow.next').css('border-color', 'transparent transparent transparent '+options.controlArrowColor); 224 $(this).find('.controlArrow.prev').css('border-color', 'transparent '+ options.controlArrowColor + ' transparent transparent'); 225 } 226 227 if(!options.loopHorizontal){ 228 $(this).find('.controlArrow.prev').hide(); 229 } 230 231 232 if(options.slidesNavigation){ 233 addSlidesNavigation($(this), numSlides); 234 } 235 236 slides.each(function(index) { 237 //if the slide won#t be an starting point, the default will be the first one 238 if(!index && that.find('.slide.active').length == 0){ 239 $(this).addClass('active'); 240 } 241 242 $(this).css('width', slideWidth + '%'); 243 244 if(options.verticalCentered){ 245 addTableClass($(this)); 246 } 247 }); 248 }else{ 249 if(options.verticalCentered){ 250 addTableClass($(this)); 251 } 252 } 253 254 255 256 257 }).promise().done(function(){ 258 $.fn.fullpage.setAutoScrolling(options.autoScrolling); 259 260 //the starting point is a slide? 261 var activeSlide = $('.section.active').find('.slide.active'); 262 if( activeSlide.length && ($('.section.active').index('.section') != 0 || ($('.section.active').index('.section') == 0 && activeSlide.index() != 0))){ 263 var prevScrollingSpeepd = options.scrollingSpeed; 264 $.fn.fullpage.setScrollingSpeed (0);
265 landscapeScroll($('.section.active').find('.slides'), activeSlide); 266 $.fn.fullpage.setScrollingSpeed(prevScrollingSpeepd); 267 } 268 269 //fixed elements need to be moved out of the plugin container due to problems with CSS3. 270 if(options.fixedElements && options.css3){ 271 $(options.fixedElements).appendTo('body'); 272 } 273 274 //vertical centered of the navigation + first bullet active 275 if(options.navigation){ 276 nav.css('margin-top', '-' + (nav.height()/2) + 'px'); 277 nav.find('li').eq($('.section.active').index('.section')).find('a').addClass('active'); 278 } 279 280 //moving the menu outside the main container (avoid problems with fixed positions when using CSS3 tranforms) 281 if(options.menu && options.css3){ 282 $(options.menu).appendTo('body'); 283 } 284 285 if(options.scrollOverflow){ 286 if(container.hasClass('fullpage-used')){ 287 createSlimScrollingHandler(); 288 } 289 //after DOM and images are loaded 290 $(window).on('load', createSlimScrollingHandler); 291 }else{ 292 $.isFunction( options.afterRender ) && options.afterRender.call( this); 293 } 294 295 296 //getting the anchor link in the URL and deleting the `#` 297 var value = window.location.hash.replace('#', '').split('index.html'); 298 var destiny = value[0]; 299 300 if(destiny.length){ 301 var section = $('[data-anchor="'+destiny+'"]'); 302 303 if(!options.animateAnchor && section.length){ 304 silentScroll(section.position().top); 305 $.isFunction( options.afterLoad ) && options.afterLoad.call( this, destiny, (section.index('.section') + 1)); 306 307 //updating the active class 308 section.addClass('active').siblings().removeClass('active'); 309 } 310 } 311 312 313 $(window).on('load', function() { 314 scrollToAnchor(); 315 }); 316 317 }); 318 319 function createSlimScrollingHandler(){ 320 $('.section').each(function(){ 321 var slides = $(this).find('.slide'); 322 323 if(slides.length){ 324 slides.each(function(){ 325 createSlimScrolling($(this)); 326 }); 327 }else{ 328 createSlimScrolling($(this)); 329 } 330 331 }); 332 $.isFunction( options.afterRender ) && options.afterRender.call( this); 333 } 334 335 336 var scrollId; 337 var isScrolling = false; 338 339 //when scrolling... 340 $(window).on('scroll', scrollHandler); 341 342 function scrollHandler(){ 343 if(!options.autoScrolling){ 344 var currentScroll = $(window).scrollTop(); 345 346 var scrolledSections = $('.section').map(function(){ 347 if ($(this).offset().top < (currentScroll + 100)){ 348 return $(this); 349 } 350 }); 351 352 //geting the last one, the current one on the screen 353 var currentSection = scrolledSections[scrolledSections.length-1]; 354 355 //executing only once the first time we reach the section 356 if(!currentSection.hasClass('active')){ 357 var leavingSection = $('.section.active').index('.section') + 1; 358 359 isScrolling = true; 360 361 var yMovement = getYmovement(currentSection); 362 363 currentSection.addClass('active').siblings().removeClass('active'); 364 365 var anchorLink = currentSection.data('anchor'); 366 $.isFunction( options.onLeave ) && options.onLeave.call( this, leavingSection, (currentSection.index('.section') + 1), yMovement); 367 368 $.isFunction( options.afterLoad ) && options.afterLoad.call( this, anchorLink, (currentSection.index('.section') + 1)); 369 370 activateMenuElement(anchorLink); 371 activateNavDots(anchorLink, 0); 372 373 374 if(options.anchors.length && !isMoving){ 375 //needed to enter in hashChange event when using the menu with anchor links 376 lastScrolledDestiny = anchorLink; 377 378 location.hash = anchorLink; 379 } 380 381 //small timeout in order to avoid entering in hashChange event when scrolling is not finished yet 382 clearTimeout(scrollId); 383 scrollId = setTimeout(function(){ 384 isScrolling = false; 385 }, 100); 386 } 387 388 } 389 } 390 391 392 var touchStartY = 0; 393 var touchStartX = 0; 394 var touchEndY = 0; 395 var touchEndX = 0; 396 397 /* Detecting touch events 398 399 * As we are changing the top property of the page on scrolling, we can not use the traditional way to detect it. 400 * This way, the touchstart and the touch moves shows an small difference between them which is the 401 * used one to determine the direction. 402 */ 403 function touchMoveHandler(event){ 404 var e = event.originalEvent; 405 406 if(options.autoScrolling){ 407 //preventing the easing on iOS devices 408 event.preventDefault(); 409 } 410 411 // additional: if one of the normalScrollElements isn't within options.normalScrollElementTouchThreshold hops up the DOM chain 412 if (!checkParentForNormalScrollElement(event.target)) { 413 414 var touchMoved = false;
415 var activeSection = $('.section.active'); 416 var scrollable; 417 418 if (!isMoving && !slideMoving) { //if theres any # 419 var touchEvents = getEventsPage(e); 420 touchEndY = touchEvents['y']; 421 touchEndX = touchEvents['x']; 422 423 //if movement in the X axys is greater than in the Y and the currect section has slides... 424 if (activeSection.find('.slides').length && Math.abs(touchStartX - touchEndX) > (Math.abs(touchStartY - touchEndY))) { 425 426 //is the movement greater than the minimum resistance to scroll? 427 if (Math.abs(touchStartX - touchEndX) > ($(window).width() / 100 * options.touchSensitivity)) { 428 if (touchStartX > touchEndX) { 429 $.fn.fullpage.moveSlideRight(); //next 430 } else { 431 $.fn.fullpage.moveSlideLeft(); //prev 432 } 433 } 434 } 435 436 //vertical scrolling (only when autoScrolling is enabled) 437 else if(options.autoScrolling){ 438 439 //if there are landscape slides, we check if the scrolling bar is in the current one or not 440 if(activeSection.find('.slides').length){ 441 scrollable= activeSection.find('.slide.active').find('.scrollable'); 442 }else{ 443 scrollable = activeSection.find('.scrollable'); 444 } 445 446 //is the movement greater than the minimum resistance to scroll? 447 if (Math.abs(touchStartY - touchEndY) > ($(window).height() / 100 * options.touchSensitivity)) { 448 if (touchStartY > touchEndY) { 449 if(scrollable.length > 0 ){ 450 //is the scrollbar at the end of the scroll? 451 if(isScrolled('bottom', scrollable)){ 452 $.fn.fullpage.moveSectionDown(); 453 }else{ 454 return true; 455 } 456 }else{ 457 // moved down 458 $.fn.fullpage.moveSectionDown(); 459 } 460 } else if (touchEndY > touchStartY) { 461 462 if(scrollable.length > 0){ 463 //is the scrollbar at the start of the scroll? 464 if(isScrolled('top', scrollable)){ 465 $.fn.fullpage.moveSectionUp(); 466 } 467 else{ 468 return true; 469 } 470 }else{ 471 // moved up 472 $.fn.fullpage.moveSectionUp(); 473 } 474 } 475 } 476 } 477 } 478 } 479 480 } 481 482 /** 483 * recursive function to loop up the parent nodes to check if one of them exists in options.normalScrollElements 484 * Currently works well for iOS - Android might need some testing 485 * @param {Element} el target element / jquery selector (in subsequent nodes) 486 * @param {int} hop current hop compared to options.normalScrollElementTouchThreshold 487 * @return {boolean} true if there is a match to options.normalScrollElements 488 */ 489 function checkParentForNormalScrollElement (el, hop) { 490 hop = hop || 0; 491 var parent = $(el).parent(); 492 493 if (hop < options.normalScrollElementTouchThreshold && 494 parent.is(options.normalScrollElements) ) { 495 return true; 496 } else if (hop == options.normalScrollElementTouchThreshold) { 497 return false; 498 } else { 499 return checkParentForNormalScrollElement(parent, ++hop); 500 } 501 } 502 503 function touchStartHandler(event){ 504 var e = event.originalEvent; 505 var touchEvents = getEventsPage(e); 506 touchStartY = touchEvents['y']; 507 touchStartX = touchEvents['x']; 508 } 509 510 511 /** 512 * Detecting mousewheel scrolling 513 * 514 * http://blogs.sitepointstatic.com/examples/tech/mouse-wheel/index.html 515 * http://www.sitepoint.com/html5-javascript-mouse-wheel/ 516 */ 517 function MouseWheelHandler(e) { 518 if(options.autoScrolling){ 519 // cross-browser wheel delta 520 e = window.event || e; 521 var delta = Math.max(-1, Math.min(1, 522 (e.wheelDelta || -e.deltaY || -e.detail))); 523 var scrollable; 524 var activeSection = $('.section.active'); 525 526 if (!isMoving) { //if theres any # 527 528 //if there are landscape slides, we check if the scrolling bar is in the current one or not 529 if(activeSection.find('.slides').length){ 530 scrollable= activeSection.find('.slide.active').find('.scrollable'); 531 }else{ 532 scrollable = activeSection.find('.scrollable'); 533 } 534 535 //scrolling down? 536 if (delta < 0) { 537 if(scrollable.length > 0 ){ 538 //is the scrollbar at the end of the scroll? 539 if(isScrolled('bottom', scrollable)){ 540 $.fn.fullpage.moveSectionDown(); 541 }else{ 542 return true; //normal scroll 543 } 544 }else{ 545 $.fn.fullpage.moveSectionDown(); 546 } 547 } 548 549 //scrolling up? 550 else { 551 if(scrollable.length > 0){ 552 //is the scrollbar at the start of the scroll? 553 if(isScrolled('top', scrollable)){ 554 $.fn.fullpage.moveSectionUp(); 555 }else{ 556 return true; //normal scroll 557 } 558 }else{ 559 $.fn.fullpage.moveSectionUp(); 560 } 561 } 562 } 563 564 return false;
565 } 566 } 567 568 569 $.fn.fullpage.moveSectionUp = function(){ 570 var prev = $('.section.active').prev('.section'); 571 572 //looping to the bottom if there's no more sections above 573 if (!prev.length && (options.loopTop || options.continuousVertical)) { 574 prev = $('.section').last(); 575 } 576 577 if (prev.length) { 578 scrollPage(prev, null, true); 579 } 580 }; 581 582 $.fn.fullpage.moveSectionDown = function (){ 583 var next = $('.section.active').next('.section'); 584 585 //looping to the top if there's no more sections below 586 if(!next.length && 587 (options.loopBottom || options.continuousVertical)){ 588 next = $('.section').first(); 589 } 590 591 if(next.length > 0 || 592 (!next.length && 593 (options.loopBottom || options.continuousVertical))){ 594 scrollPage(next, null, false); 595 } 596 }; 597 598 $.fn.fullpage.moveTo = function (section, slide){ 599 var destiny = ''; 600 601 if(isNaN(section)){ 602 destiny = $('[data-anchor="'+section+'"]'); 603 }else{ 604 destiny = $('.section').eq( (section -1) ); 605 } 606 607 if (typeof slide !== 'undefined'){ 608 scrollPageAndSlide(section, slide); 609 }else if(destiny.length > 0){ 610 scrollPage(destiny); 611 } 612 }; 613 614 $.fn.fullpage.moveSlideRight = function(){ 615 moveSlide('next'); 616 }; 617 618 $.fn.fullpage.moveSlideLeft = function(){ 619 moveSlide('prev'); 620 }; 621 622 function moveSlide(direction){ 623 var activeSection = $('.section.active'); 624 var slides = activeSection.find('.slides'); 625 626 // more than one slide needed and nothing should be sliding 627 if (!slides.length || slideMoving) { 628 return; 629 } 630 631 var currentSlide = slides.find('.slide.active'); 632 var destiny = null; 633 634 if(direction === 'prev'){ 635 destiny = currentSlide.prev('.slide'); 636 }else{ 637 destiny = currentSlide.next('.slide'); 638 } 639 640 //isn't there a next slide in the secuence? 641 if(!destiny.length){ 642 //respect loopHorizontal settin 643 if (!options.loopHorizontal) return; 644 645 if(direction === 'prev'){ 646 destiny = currentSlide.siblings(':last'); 647 }else{ 648 destiny = currentSlide.siblings(':first'); 649 } 650 } 651 652 slideMoving = true; 653 654 landscapeScroll(slides, destiny); 655 } 656 657 function scrollPage(element, callback, isMovementUp){ 658 var scrollOptions = {}, scrolledElement; 659 var dest = element.position(); 660 if(typeof dest === "undefined"){ return; } //there's no element to scroll, leaving the function 661 var dtop = dest.top; 662 var yMovement = getYmovement(element); 663 var anchorLink = element.data('anchor'); 664 var sectionIndex = element.index('.section'); 665 var activeSlide = element.find('.slide.active'); 666 var activeSection = $('.section.active'); 667 var leavingSection = activeSection.index('.section') + 1; 668 669 //caching the value of isResizing at the momment the function is called 670 //because it will be checked later inside a setTimeout and the value might change 671 var localIsResizing = isResizing; 672 673 if(activeSlide.length){ 674 var slideAnchorLink = activeSlide.data('anchor'); 675 var slideIndex = activeSlide.index(); 676 } 677 678 // If continuousVertical && we need to wrap around 679 if (options.autoScrolling && options.continuousVertical && typeof (isMovementUp) !== "undefined" && 680 ((!isMovementUp && yMovement == 'up') || // Intending to scroll down but about to go up or 681 (isMovementUp && yMovement == 'down'))) { // intending to scroll up but about to go down 682 683 // Scrolling down 684 if (!isMovementUp) { 685 // Move all previous sections to after the active section 686 $(".section.active").after(activeSection.prevAll(".section").get().reverse()); 687 } 688 else { // Scrolling up 689 // Move all next sections to before the active section 690 $(".section.active").before(activeSection.nextAll(".section")); 691 } 692 693 // Maintain the displayed position (now that we changed the element order) 694 silentScroll($('.section.active').position().top); 695 696 // save for later the elements that still need to be reordered 697 var wrapAroundElements = activeSection; 698 699 // Recalculate animation variables 700 dest = element.position(); 701 dtop = dest.top; 702 yMovement = getYmovement(element); 703 } 704 705 706 element.addClass('active').siblings().removeClass('active'); 707 708 //preventing from activating the MouseWheelHandler event 709 //more than once if the page is scrolling 710 isMoving = true; 711 712 if(typeof anchorLink !== 'undefined'){ 713 setURLHash(slideIndex, slideAnchorLink, anchorLink); 714 } 715 716 if(options.autoScrolling){ 717 scrollOptions['top'] = -dtop; 718 scrolledElement = container.selector; 719 }else{ 720 scrollOptions['scrollTop'] = dtop; 721 scrolledElement = 'html, body'; 722 } 723 724 // Fix section order after continuousVertical changes have been animated 725 var continuousVerticalFixSectionOrder = function () {
726 // If continuousVertical is in effect (and autoScrolling would also be in effect then), 727 // finish moving the elements around so the direct navigation will function more simply 728 if (!wrapAroundElements || !wrapAroundElements.length) { 729 return; 730 } 731 732 if (isMovementUp) { 733 $('.section:first').before(wrapAroundElements); 734 } 735 else { 736 $('.section:last').after(wrapAroundElements); 737 } 738 739 silentScroll($('.section.active').position().top); 740 }; 741 742 743 // Use CSS3 translate functionality or... 744 if (options.css3 && options.autoScrolling) { 745 746 //callback (onLeave) if the site is not just resizing and readjusting the slides 747 $.isFunction(options.onLeave) && !localIsResizing && options.onLeave.call(this, leavingSection, (sectionIndex + 1), yMovement); 748 749 750 var translate3d = 'translate3d(0px, -' + dtop + 'px, 0px)'; 751 transformContainer(translate3d, true); 752 753 setTimeout(function () { 754 //fix section order from continuousVertical 755 continuousVerticalFixSectionOrder(); 756 757 //callback (afterLoad) if the site is not just resizing and readjusting the slides 758 $.isFunction(options.afterLoad) && !localIsResizing && options.afterLoad.call(this, anchorLink, (sectionIndex + 1)); 759 760 setTimeout(function () { 761 isMoving = false; 762 $.isFunction(callback) && callback.call(this); 763 }, scrollDelay); 764 }, options.scrollingSpeed); 765 } else { // ... use jQuery animate 766 767 //callback (onLeave) if the site is not just resizing and readjusting the slides 768 $.isFunction(options.onLeave) && !localIsResizing && options.onLeave.call(this, leavingSection, (sectionIndex + 1), yMovement); 769 770 $(scrolledElement).animate( 771 scrollOptions 772 , options.scrollingSpeed, options.easing, function () { 773 //fix section order from continuousVertical 774 continuousVerticalFixSectionOrder(); 775 776 //callback (afterLoad) if the site is not just resizing and readjusting the slides 777 $.isFunction(options.afterLoad) && !localIsResizing && options.afterLoad.call(this, anchorLink, (sectionIndex + 1)); 778 779 setTimeout(function () { 780 isMoving = false; 781 $.isFunction(callback) && callback.call(this); 782 }, scrollDelay); 783 }); 784 } 785 786 //flag to avoid callingn `scrollPage()` twice in case of using anchor links 787 lastScrolledDestiny = anchorLink; 788 789 //avoid firing it twice (as it does also on scroll) 790 if(options.autoScrolling){ 791 activateMenuElement(anchorLink); 792 activateNavDots(anchorLink, sectionIndex); 793 } 794 } 795 796 function scrollToAnchor(){ 797 //getting the anchor link in the URL and deleting the `#` 798 var value = window.location.hash.replace('#', '').split('index.html'); 799 var section = value[0]; 800 var slide = value[1]; 801 802 if(section){ //if theres any # 803 scrollPageAndSlide(section, slide); 804 } 805 } 806 807 //detecting any change on the URL to scroll to the given anchor link 808 //(a way to detect back history button as we play with the hashes on the URL) 809 $(window).on('hashchange', hashChangeHandler); 810 811 function hashChangeHandler(){ 812 if(!isScrolling){ 813 var value = window.location.hash.replace('#', '').split('index.html'); 814 var section = value[0]; 815 var slide = value[1]; 816 817 //when moving to a slide in the first section for the first time (first time to add an anchor to the URL) 818 var isFirstSlideMove = (typeof lastScrolledDestiny === 'undefined'); 819 var isFirstScrollMove = (typeof lastScrolledDestiny === 'undefined' && typeof slide === 'undefined'); 820 821 /*in order to call scrollpage() only once for each destination at a time 822 It is called twice for each scroll otherwise, as in case of using anchorlinks `hashChange` 823 event is fired on every scroll too.*/ 824 if ((section && section !== lastScrolledDestiny) && !isFirstSlideMove || isFirstScrollMove || (!slideMoving && lastScrolledSlide != slide )) { 825 scrollPageAndSlide(section, slide); 826 } 827 } 828 } 829 830 831 /** 832 * Sliding with arrow keys, both, vertical and horizontal 833 */ 834 $(document).keydown(function(e) { 835 //Moving the main page with the keyboard arrows if keyboard scrolling is enabled 836 if (options.keyboardScrolling && !isMoving) { 837 switch (e.which) { 838 //up 839 case 38: 840 case 33: 841 $.fn.fullpage.moveSectionUp(); 842 break; 843 844 //down 845 case 40: 846 case 34: 847 $.fn.fullpage.moveSectionDown(); 848 break; 849 850 //Home 851 case 36: 852 $.fn.fullpage.moveTo(1); 853 break; 854 855 //End 856 case 35:
857 $.fn.fullpage.moveTo( $('.section').length ); 858 break; 859 860 //left 861 case 37: 862 $.fn.fullpage.moveSlideLeft(); 863 break; 864 865 //right 866 case 39: 867 $.fn.fullpage.moveSlideRight(); 868 break; 869 870 default: 871 return; // exit this handler for other keys 872 } 873 } 874 }); 875 876 //navigation action 877 $(document).on('click', '#fullPage-nav a', function(e){ 878 e.preventDefault(); 879 var index = $(this).parent().index(); 880 scrollPage($('.section').eq(index)); 881 }); 882 883 //navigation tooltips 884 $(document).on({ 885 mouseenter: function(){ 886 var tooltip = $(this).data('tooltip'); 887 $('<div class="fullPage-tooltip ' + options.navigationPosition +'">' + tooltip + '</div>').hide().appendTo($(this)).fadeIn(200); 888 }, 889 mouseleave: function(){ 890 $(this).find('.fullPage-tooltip').fadeOut().remove(); 891 } 892 }, '#fullPage-nav li'); 893 894 895 if(options.normalScrollElements){ 896 $(document).on('mouseover', options.normalScrollElements, function () { 897 $.fn.fullpage.setMouseWheelScrolling(false); 898 }); 899 900 $(document).on('mouseout', options.normalScrollElements, function(){ 901 $.fn.fullpage.setMouseWheelScrolling(true); 902 }); 903 } 904 905 /** 906 * Scrolling horizontally when clicking on the slider controls. 907 */ 908 $('.section').on('click', '.controlArrow', function() { 909 if ($(this).hasClass('prev')) { 910 $.fn.fullpage.moveSlideLeft(); 911 } else { 912 $.fn.fullpage.moveSlideRight(); 913 } 914 }); 915 916 917 /** 918 * Scrolling horizontally when clicking on the slider controls. 919 */ 920 $('.section').on('click', '.toSlide', function(e) { 921 e.preventDefault(); 922 923 var slides = $(this).closest('.section').find('.slides'); 924 var currentSlide = slides.find('.slide.active'); 925 var destiny = null; 926 927 destiny = slides.find('.slide').eq( ($(this).data('index') -1) ); 928 929 if(destiny.length > 0){ 930 landscapeScroll(slides, destiny); 931 } 932 }); 933 934 /** 935 * Scrolls horizontal sliders. 936 */ 937 function landscapeScroll(slides, destiny){ 938 var destinyPos = destiny.position(); 939 var slidesContainer = slides.find('.slidesContainer').parent(); 940 var slideIndex = destiny.index(); 941 var section = slides.closest('.section'); 942 var sectionIndex = section.index('.section'); 943 var anchorLink = section.data('anchor'); 944 var slidesNav = section.find('.fullPage-slidesNav'); 945 var slideAnchor = destiny.data('anchor'); 946 947 //caching the value of isResizing at the momment the function is called 948 //because it will be checked later inside a setTimeout and the value might change 949 var localIsResizing = isResizing; 950 951 if(options.onSlideLeave){ 952 var prevSlideIndex = section.find('.slide.active').index(); 953 var xMovement = getXmovement(prevSlideIndex, slideIndex); 954 955 //if the site is not just resizing and readjusting the slides 956 if(!localIsResizing){ 957 $.isFunction( options.onSlideLeave ) && options.onSlideLeave.call( this, anchorLink, (sectionIndex + 1), prevSlideIndex, xMovement); 958 } 959 } 960 961 destiny.addClass('active').siblings().removeClass('active'); 962 963 964 if(typeof slideAnchor === 'undefined'){ 965 slideAnchor = slideIndex; 966 } 967 968 //only changing the URL if the slides are in the current section (not for resize re-adjusting) 969 if(section.hasClass('active')){ 970 971 if(!options.loopHorizontal){ 972 //hidding it for the fist slide, showing for the rest 973 section.find('.controlArrow.prev').toggle(slideIndex!=0); 974 975 //hidding it for the last slide, showing for the rest 976 section.find('.controlArrow.next').toggle(!destiny.is(':last-child')); 977 } 978 979 setURLHash(slideIndex, slideAnchor, anchorLink); 980 } 981 982 if(options.css3){ 983 var translate3d = 'translate3d(-' + destinyPos.left + 'px, 0px, 0px)'; 984 985 slides.find('.slidesContainer').toggleClass('easing', options.scrollingSpeed>0).css(getTransforms(translate3d)); 986 987 setTimeout(function(){ 988 //if the site is not just resizing and readjusting the slides 989 if(!localIsResizing){ 990 $.isFunction( options.afterSlideLoad ) && options.afterSlideLoad.call( this, anchorLink, (sectionIndex + 1), slideAnchor, slideIndex ); 991 } 992 993 slideMoving = false; 994 }, options.scrollingSpeed, options.easing); 995 }else{ 996 slidesContainer.animate({ 997 scrollLeft : destinyPos.left 998 }, options.scrollingSpeed, options.easing, function() { 999 1000 //if the site is not just resizing and readjusting the slides 1001 if(!localIsResizing){ 1002 $.isFunction( options.afterSlideLoad ) && options.afterSlideLoad.call( this, anchorLink, (sectionIndex + 1), slideAnchor, slideIndex); 1003 } 1004 //letting them slide again 1005 slideMoving = false;
1006 }); 1007 } 1008 1009 slidesNav.find('.active').removeClass('active'); 1010 slidesNav.find('li').eq(slideIndex).find('a').addClass('active'); 1011 } 1012 1013 1014 if (!isTouchDevice) { 1015 var resizeId; 1016 1017 //when resizing the site, we adjust the heights of the sections 1018 $(window).resize(function() { 1019 //in order to call the functions only when the resize is finished 1020 //http://stackoverflow.com/questions/4298612/jquery-how-to-call-resize-event-only-once-its-finished-resizing 1021 clearTimeout(resizeId); 1022 resizeId = setTimeout($.fn.fullpage.reBuild, 500); 1023 }); 1024 1025 } 1026 1027 1028 var supportsOrientationChange = "onorientationchange" in window, 1029 orientationEvent = supportsOrientationChange ? "orientationchange" : "resize"; 1030 1031 $(window).bind(orientationEvent , function() { 1032 if(isTouchDevice){ 1033 $.fn.fullpage.reBuild(); 1034 } 1035 }); 1036 1037 1038 /** 1039 * When resizing is finished, we adjust the slides sizes and positions 1040 */ 1041 $.fn.fullpage.reBuild = function(){ 1042 isResizing = true; 1043 1044 var windowsWidth = $(window).width(); 1045 windowsHeight = $(window).height(); 1046 1047 //text and images resizing 1048 if (options.resize) { 1049 resizeMe(windowsHeight, windowsWidth); 1050 } 1051 1052 $('.section').each(function(){ 1053 var scrollHeight = windowsHeight - parseInt($(this).css('padding-bottom')) - parseInt($(this).css('padding-top')); 1054 1055 //adjusting the height of the table-cell for IE and Firefox 1056 if(options.verticalCentered){ 1057 $(this).find('.tableCell').css('height', getTableHeight($(this)) + 'px'); 1058 } 1059 1060 $(this).css('height', windowsHeight + 'px'); 1061 1062 //resizing the scrolling divs 1063 if(options.scrollOverflow){ 1064 var slides = $(this).find('.slide'); 1065 1066 if(slides.length){ 1067 slides.each(function(){ 1068 createSlimScrolling($(this)); 1069 }); 1070 }else{ 1071 createSlimScrolling($(this)); 1072 } 1073 1074 } 1075 1076 //adjusting the position fo the FULL WIDTH slides... 1077 var slides = $(this).find('.slides'); 1078 if (slides.length) { 1079 landscapeScroll(slides, slides.find('.slide.active')); 1080 } 1081 }); 1082 1083 //adjusting the position for the current section 1084 var destinyPos = $('.section.active').position(); 1085 1086 var activeSection = $('.section.active'); 1087 1088 //isn't it the first section? 1089 if(activeSection.index('.section')){ 1090 scrollPage(activeSection); 1091 } 1092 1093 isResizing = false; 1094 $.isFunction( options.afterResize ) && options.afterResize.call( this); 1095 } 1096 1097 /** 1098 * Resizing of the font size depending on the window size as well as some of the images on the site. 1099 */ 1100 function resizeMe(displayHeight, displayWidth) { 1101 //Standard height, for which the body font size is correct 1102 var preferredHeight = 825; 1103 var windowSize = displayHeight; 1104 1105 /* Problem to be solved 1106 1107 if (displayHeight < 825) { 1108 var percentage = (windowSize * 100) / preferredHeight; 1109 var newFontSize = percentage.toFixed(2); 1110 1111 $("img").each(function() { 1112 var newWidth = ((80 * percentage) / 100).toFixed(2); 1113 $(this).css("width", newWidth + '%'); 1114 }); 1115 } else { 1116 $("img").each(function() { 1117 $(this).css("width", ''); 1118 }); 1119 }*/ 1120 1121 if (displayHeight < 825 || displayWidth < 900) { 1122 if (displayWidth < 900) { 1123 windowSize = displayWidth; 1124 preferredHeight = 900; 1125 } 1126 var percentage = (windowSize * 100) / preferredHeight; 1127 var newFontSize = percentage.toFixed(2); 1128 1129 $("body").css("font-size", newFontSize + '%'); 1130 } else { 1131 $("body").css("font-size", '100%'); 1132 } 1133 } 1134 1135 /** 1136 * Activating the website navigation dots according to the given slide name. 1137 */ 1138 function activateNavDots(name, sectionIndex){ 1139 if(options.navigation){ 1140 $('#fullPage-nav').find('.active').removeClass('active'); 1141 if(name){ 1142 $('#fullPage-nav').find('a[href="#' + name + '"]').addClass('active'); 1143 }else{ 1144 $('#fullPage-nav').find('li').eq(sectionIndex).find('a').addClass('active'); 1145 } 1146 } 1147 } 1148 1149 /** 1150 * Activating the website main menu elements according to the given slide name. 1151 */ 1152 function activateMenuElement(name){ 1153 if(options.menu){ 1154 $(options.menu).find('.active').removeClass('active'); 1155 $(options.menu).find('[data-menuanchor="'+name+'"]').addClass('active'); 1156 } 1157 } 1158 1159 /** 1160 * Return a boolean depending on whether the scrollable element is at the end or at the start of the scrolling 1161 * depending on the given type. 1162 */ 1163 function isScrolled(type, scrollable){ 1164 if(type === 'top'){ 1165 return !scrollable.scrollTop(); 1166 }else if(type === 'bottom'){
1167 return scrollable.scrollTop() + 1 + scrollable.innerHeight() >= scrollable[0].scrollHeight; 1168 } 1169 } 1170 1171 /** 1172 * Retuns `up` or `down` depending on the scrolling movement to reach its destination 1173 * from the current section. 1174 */ 1175 function getYmovement(destiny){ 1176 var fromIndex = $('.section.active').index('.section'); 1177 var toIndex = destiny.index('.section'); 1178 1179 if(fromIndex > toIndex){ 1180 return 'up'; 1181 } 1182 return 'down'; 1183 } 1184 1185 /** 1186 * Retuns `right` or `left` depending on the scrolling movement to reach its destination 1187 * from the current slide. 1188 */ 1189 function getXmovement(fromIndex, toIndex){ 1190 if( fromIndex == toIndex){ 1191 return 'none' 1192 } 1193 if(fromIndex > toIndex){ 1194 return 'left'; 1195 } 1196 return 'right'; 1197 } 1198 1199 1200 function createSlimScrolling(element){ 1201 //needed to make `scrollHeight` work under Opera 12 1202 element.css('overflow', 'hidden'); 1203 1204 //in case element is a slide 1205 var section = element.closest('.section'); 1206 var scrollable = element.find('.scrollable'); 1207 1208 //if there was scroll, the contentHeight will be the one in the scrollable section 1209 if(scrollable.length){ 1210 var contentHeight = element.find('.scrollable').get(0).scrollHeight; 1211 }else{ 1212 var contentHeight = element.get(0).scrollHeight; 1213 if(options.verticalCentered){ 1214 contentHeight = element.find('.tableCell').get(0).scrollHeight; 1215 } 1216 } 1217 1218 var scrollHeight = windowsHeight - parseInt(section.css('padding-bottom')) - parseInt(section.css('padding-top')); 1219 1220 //needs scroll? 1221 if ( contentHeight > scrollHeight) { 1222 //was there already an scroll ? Updating it 1223 if(scrollable.length){ 1224 scrollable.css('height', scrollHeight + 'px').parent().css('height', scrollHeight + 'px'); 1225 } 1226 //creating the scrolling 1227 else{ 1228 if(options.verticalCentered){ 1229 element.find('.tableCell').wrapInner('<div class="scrollable" />'); 1230 }else{ 1231 element.wrapInner('<div class="scrollable" />'); 1232 } 1233 1234 1235 element.find('.scrollable').slimScroll({ 1236 height: scrollHeight + 'px', 1237 size: '10px', 1238 alwaysVisible: true 1239 }); 1240 } 1241 } 1242 1243 //removing the scrolling when it is not necessary anymore 1244 else{ 1245 removeSlimScroll(element); 1246 } 1247 1248 //undo 1249 element.css('overflow', ''); 1250 } 1251 1252 function removeSlimScroll(element){ 1253 element.find('.scrollable').children().first().unwrap().unwrap(); 1254 element.find('.slimScrollBar').remove(); 1255 element.find('.slimScrollRail').remove(); 1256 } 1257 1258 function addTableClass(element){ 1259 element.addClass('table').wrapInner('<div class="tableCell" style="height:' + getTableHeight(element) + 'px;" />'); 1260 } 1261 1262 function getTableHeight(element){ 1263 var sectionHeight = windowsHeight; 1264 1265 if(options.paddingTop || options.paddingBottom){ 1266 var section = element; 1267 if(!section.hasClass('section')){ 1268 section = element.closest('.section'); 1269 } 1270 1271 var paddings = parseInt(section.css('padding-top')) + parseInt(section.css('padding-bottom')); 1272 sectionHeight = (windowsHeight - paddings); 1273 } 1274 1275 return sectionHeight; 1276 } 1277 1278 /** 1279 * Adds a css3 transform property to the container class with or without animation depending on the animated param. 1280 */ 1281 function transformContainer(translate3d, animated){ 1282 container.toggleClass('easing', animated); 1283 1284 container.css(getTransforms(translate3d)); 1285 } 1286 1287 1288 /** 1289 * Scrolls to the given section and slide 1290 */ 1291 function scrollPageAndSlide(destiny, slide){ 1292 if (typeof slide === 'undefined') { 1293 slide = 0; 1294 } 1295 1296 if(isNaN(destiny)){ 1297 var section = $('[data-anchor="'+destiny+'"]'); 1298 }else{ 1299 var section = $('.section').eq( (destiny -1) ); 1300 } 1301 1302 1303 //we need to scroll to the section and then to the slide 1304 if (destiny !== lastScrolledDestiny && !section.hasClass('active')){ 1305 scrollPage(section, function(){ 1306 scrollSlider(section, slide) 1307 }); 1308 } 1309 //if we were already in the section 1310 else{ 1311 scrollSlider(section, slide); 1312 } 1313 1314 } 1315 1316 /** 1317 * Scrolls the slider to the given slide destination for the given section 1318 */ 1319 function scrollSlider(section, slide){ 1320 if(typeof slide != 'undefined'){ 1321 var slides = section.find('.slides'); 1322 var destiny = slides.find('[data-anchor="'+slide+'"]'); 1323 1324 if(!destiny.length){ 1325 destiny = slides.find('.slide').eq(slide); 1326 } 1327 1328 if(destiny.length){
1329 landscapeScroll(slides, destiny); 1330 } 1331 } 1332 } 1333 1334 /** 1335 * Creates a landscape navigation bar with dots for horizontal sliders. 1336 */ 1337 function addSlidesNavigation(section, numSlides){ 1338 section.append('<div class="fullPage-slidesNav"><ul></ul></div>'); 1339 var nav = section.find('.fullPage-slidesNav'); 1340 1341 //top or bottom 1342 nav.addClass(options.slidesNavPosition); 1343 1344 for(var i=0; i< numSlides; i++){ 1345 nav.find('ul').append('<li><a href="#"><span></span></a></li>'); 1346 } 1347 1348 //centering it 1349 nav.css('margin-left', '-' + (nav.width()/2) + 'px'); 1350 1351 nav.find('li').first().find('a').addClass('active'); 1352 } 1353 1354 1355 /** 1356 * Sets the URL hash for a section with slides 1357 */ 1358 function setURLHash(slideIndex, slideAnchor, anchorLink){ 1359 var sectionHash = ''; 1360 1361 if(options.anchors.length){ 1362 1363 //isn't it the first slide? 1364 if(slideIndex){ 1365 if(typeof anchorLink !== 'undefined'){ 1366 sectionHash = anchorLink; 1367 } 1368 1369 //slide without anchor link? We take the index instead. 1370 if(typeof slideAnchor === 'undefined'){ 1371 slideAnchor = slideIndex; 1372 } 1373 1374 lastScrolledSlide = slideAnchor; 1375 location.hash = sectionHash + '/' + slideAnchor; 1376 1377 //first slide won't have slide anchor, just the section one 1378 }else if(typeof slideIndex !== 'undefined'){ 1379 lastScrolledSlide = slideAnchor; 1380 location.hash = anchorLink; 1381 } 1382 1383 //section without slides 1384 else{ 1385 location.hash = anchorLink; 1386 } 1387 } 1388 } 1389 1390 /** 1391 * Scrolls the slider to the given slide destination for the given section 1392 */ 1393 $(document).on('click', '.fullPage-slidesNav a', function(e){ 1394 e.preventDefault(); 1395 var slides = $(this).closest('.section').find('.slides'); 1396 var destiny = slides.find('.slide').eq($(this).closest('li').index()); 1397 1398 landscapeScroll(slides, destiny); 1399 }); 1400 1401 1402 /** 1403 * Checks for translate3d support 1404 * @return boolean 1405 * http://stackoverflow.com/questions/5661671/detecting-transform-translate3d-support 1406 */ 1407 function support3d() { 1408 var el = document.createElement('p'), 1409 has3d, 1410 transforms = { 1411 'webkitTransform':'-webkit-transform', 1412 'OTransform':'-o-transform', 1413 'msTransform':'-ms-transform', 1414 'MozTransform':'-moz-transform', 1415 'transform':'transform' 1416 }; 1417 1418 // Add it to the body to get the computed style. 1419 document.body.insertBefore(el, null); 1420 1421 for (var t in transforms) { 1422 if (el.style[t] !== undefined) { 1423 el.style[t] = "translate3d(1px,1px,1px)"; 1424 has3d = window.getComputedStyle(el).getPropertyValue(transforms[t]); 1425 } 1426 } 1427 1428 document.body.removeChild(el); 1429 1430 return (has3d !== undefined && has3d.length > 0 && has3d !== "none"); 1431 } 1432 1433 1434 1435 /** 1436 * Removes the auto scrolling action fired by the mouse wheel and tackpad. 1437 * After this function is called, the mousewheel and trackpad movements won't scroll through sections. 1438 */ 1439 function removeMouseWheelHandler(){ 1440 if (document.addEventListener) { 1441 document.removeEventListener('mousewheel', MouseWheelHandler, false); //IE9, Chrome, Safari, Oper 1442 document.removeEventListener('wheel', MouseWheelHandler, false); //Firefox 1443 } else { 1444 document.detachEvent("onmousewheel", MouseWheelHandler); //IE 6/7/8 1445 } 1446 } 1447 1448 1449 /** 1450 * Adds the auto scrolling action for the mouse wheel and tackpad. 1451 * After this function is called, the mousewheel and trackpad movements will scroll through sections 1452 */ 1453 function addMouseWheelHandler(){ 1454 if (document.addEventListener) { 1455 document.addEventListener("mousewheel", MouseWheelHandler, false); //IE9, Chrome, Safari, Oper 1456 document.addEventListener("wheel", MouseWheelHandler, false); //Firefox 1457 } else { 1458 document.attachEvent("onmousewheel", MouseWheelHandler); //IE 6/7/8 1459 } 1460 } 1461 1462 1463 /** 1464 * Adds the possibility to auto scroll through sections on touch devices. 1465 */ 1466 function addTouchHandler(){ 1467 if(isTouchDevice){ 1468 //Microsoft pointers 1469 MSPointer = getMSPointer(); 1470 1471 $(document).off('touchstart ' + MSPointer.down).on('touchstart ' + MSPointer.down, touchStartHandler); 1472 $(document).off('touchmove ' + MSPointer.move).on('touchmove ' + MSPointer.move, touchMoveHandler); 1473 } 1474 } 1475 1476 /** 1477 * Removes the auto scrolling for touch devices. 1478 */ 1479 function removeTouchHandler(){ 1480 if(isTouchDevice){ 1481 //Microsoft pointers 1482 MSPointer = getMSPointer(); 1483 1484 $(document).off('touchstart ' + MSPointer.down); 1485 $(document).off('touchmove ' + MSPointer.move); 1486 } 1487 } 1488 1489 1490 /* 1491 * Returns and object with Microsoft pointers (for IE<11 and for IE >= 11)
1492 * http://msdn.microsoft.com/en-us/library/ie/dn304886(v=vs.85).aspx 1493 */ 1494 function getMSPointer(){ 1495 var pointer; 1496 1497 //IE >= 11 1498 if(window.PointerEvent){ 1499 pointer = { down: "pointerdown", move: "pointermove"}; 1500 } 1501 1502 //IE < 11 1503 else{ 1504 pointer = { down: "MSPointerDown", move: "MSPointerMove"}; 1505 } 1506 1507 return pointer; 1508 } 1509 /** 1510 * Gets the pageX and pageY properties depending on the browser. 1511 * https://github.com/alvarotrigo/fullPage.js/issues/194#issuecomment-34069854 1512 */ 1513 function getEventsPage(e){ 1514 var events = new Array(); 1515 if (window.navigator.msPointerEnabled){ 1516 events['y'] = e.pageY; 1517 events['x'] = e.pageX; 1518 }else{ 1519 events['y'] = e.touches[0].pageY; 1520 events['x'] = e.touches[0].pageX; 1521 } 1522 1523 return events; 1524 } 1525 1526 function silentScroll(top){ 1527 if (options.css3) { 1528 var translate3d = 'translate3d(0px, -' + top + 'px, 0px)'; 1529 transformContainer(translate3d, false); 1530 } 1531 else { 1532 container.css("top", -top); 1533 } 1534 } 1535 1536 function getTransforms(translate3d){ 1537 return { 1538 '-webkit-transform': translate3d, 1539 '-moz-transform': translate3d, 1540 '-ms-transform':translate3d, 1541 'transform': translate3d 1542 }; 1543 } 1544 1545 1546 /* 1547 * Destroys fullpage.js plugin events and optinally its html markup and styles 1548 */ 1549 $.fn.fullpage.destroy = function(all){ 1550 $.fn.fullpage.setAutoScrolling(false); 1551 $.fn.fullpage.setAllowScrolling(false); 1552 $.fn.fullpage.setKeyboardScrolling(false); 1553 1554 1555 $(window) 1556 .off('scroll', scrollHandler) 1557 .off('hashchange', hashChangeHandler); 1558 1559 $(document) 1560 .off('click', '#fullPage-nav a') 1561 .off('mouseenter', '#fullPage-nav li') 1562 .off('mouseleave', '#fullPage-nav li') 1563 .off('click', '.fullPage-slidesNav a') 1564 .off('mouseover', options.normalScrollElements) 1565 .off('mouseout', options.normalScrollElements); 1566 1567 $('.section') 1568 .off('click', '.controlArrow') 1569 .off('click', '.toSlide'); 1570 1571 //lets make a mess! 1572 if(all){ 1573 destroyStructure(); 1574 } 1575 }; 1576 1577 /* 1578 * Removes inline styles added by fullpage.js 1579 */ 1580 function destroyStructure(){ 1581 //reseting the `top` or `translate` properties to 0 1582 silentScroll(0); 1583 1584 $('#fullPage-nav, .fullPage-slidesNav, .controlArrow').remove(); 1585 1586 //removing inline styles 1587 $('.section').css( { 1588 'height': '', 1589 'background-color' : '', 1590 'padding': '' 1591 }); 1592 1593 $('.slide').css( { 1594 'width': '' 1595 }); 1596 1597 container.css({ 1598 'height': '', 1599 'position': '', 1600 '-ms-touch-action': '' 1601 }); 1602 1603 //removing added classes 1604 $('.section, .slide').each(function(){ 1605 removeSlimScroll($(this)); 1606 $(this).removeClass('table active'); 1607 }) 1608 1609 container.find('.easing').removeClass('easing'); 1610 1611 //Unwrapping content 1612 container.find('.tableCell, .slidesContainer, .slides').each(function(){ 1613 //unwrap not being use in case there's no child element inside and its just text 1614 $(this).replaceWith(this.childNodes); 1615 }); 1616 1617 //scrolling the page to the top with no animation 1618 $('html, body').scrollTop(0); 1619 1620 //to know if the plugin was already used in case it is used in a future again 1621 container.addClass('fullpage-used'); 1622 } 1623 1624 }; 1625 1626})(jQuery);
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.