Skip to content

Commit 5bdbd89

Browse files
committed
- Fixed bug: Deactivate onLeave/afterLoad event after resizing alvarotrigo#301
1 parent 904207f commit 5bdbd89

File tree

2 files changed

+47
-39
lines changed

2 files changed

+47
-39
lines changed

jquery.fullPage.js

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* fullPage 1.8.2
2+
* fullPage 1.8.3
33
* https://github.com/alvarotrigo/fullPage.js
44
* MIT licensed
55
*
@@ -583,6 +583,10 @@
583583
var activeSlide = element.find('.slide.active');
584584
var activeSection = $('.section.active');
585585

586+
//caching the value of isResizing at the momment the function is called
587+
//because it will be checked later inside a setTimeout and the value might change
588+
var localIsResizing = isResizing;
589+
586590
if(activeSlide.length){
587591
var slideAnchorLink = activeSlide.data('anchor');
588592
var slideIndex = activeSlide.index();
@@ -656,8 +660,10 @@
656660

657661
// Use CSS3 translate functionality or...
658662
if (options.css3 && options.autoScrolling) {
659-
//callback (onLeave)
660-
$.isFunction(options.onLeave) && options.onLeave.call(this, leavingSection, yMovement);
663+
664+
//callback (onLeave) if the site is not just resizing and readjusting the slides
665+
$.isFunction(options.onLeave) && !localIsResizing && options.onLeave.call(this, leavingSection, yMovement);
666+
661667

662668
var translate3d = 'translate3d(0px, -' + dtop + 'px, 0px)';
663669
transformContainer(translate3d, true);
@@ -666,25 +672,27 @@
666672
//fix section order from continuousVertical
667673
continuousVerticalFixSectionOrder();
668674

669-
//callback (afterLoad)
670-
$.isFunction(options.afterLoad) && options.afterLoad.call(this, anchorLink, (sectionIndex + 1));
675+
//callback (afterLoad) if the site is not just resizing and readjusting the slides
676+
$.isFunction(options.afterLoad) && !localIsResizing && options.afterLoad.call(this, anchorLink, (sectionIndex + 1));
671677

672678
setTimeout(function () {
673679
isMoving = false;
674680
$.isFunction(callback) && callback.call(this);
675681
}, scrollDelay);
676682
}, options.scrollingSpeed);
677-
} else { // ... use jQuery animate
678-
$.isFunction(options.onLeave) && options.onLeave.call(this, leavingSection, yMovement);
683+
} else { // ... use jQuery animate
684+
685+
//callback (onLeave) if the site is not just resizing and readjusting the slides
686+
$.isFunction(options.onLeave) && !localIsResizing && options.onLeave.call(this, leavingSection, yMovement);
679687

680688
$(scrolledElement).animate(
681689
scrollOptions
682690
, options.scrollingSpeed, options.easing, function () {
683691
//fix section order from continuousVertical
684692
continuousVerticalFixSectionOrder();
685693

686-
//callback (afterLoad)
687-
$.isFunction(options.afterLoad) && options.afterLoad.call(this, anchorLink, (sectionIndex + 1));
694+
//callback (afterLoad) if the site is not just resizing and readjusting the slides
695+
$.isFunction(options.afterLoad) && !localIsResizing && options.afterLoad.call(this, anchorLink, (sectionIndex + 1));
688696

689697
setTimeout(function () {
690698
isMoving = false;

0 commit comments

Comments
 (0)