Skip to content

Commit 74cd65d

Browse files
committed
- Added: new method fitToSection() alvarotrigo#2575
1 parent e8be9c7 commit 74cd65d

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

jquery.fullPage.js

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,7 @@
535535
FP.moveTo = moveTo;
536536
FP.moveSlideRight = moveSlideRight;
537537
FP.moveSlideLeft = moveSlideLeft;
538+
FP.fitToSection = fitToSection;
538539
FP.reBuild = reBuild;
539540
FP.setResponsive = setResponsive;
540541
FP.destroy = destroy;
@@ -1018,22 +1019,27 @@
10181019
clearTimeout(scrollId2);
10191020

10201021
scrollId2 = setTimeout(function(){
1021-
//checking fitToSection again in case it was set to false before the timeout delay
1022-
if(canScroll && options.fitToSection){
1023-
//allows to scroll to an active section and
1024-
//if the section is already active, we prevent firing callbacks
1025-
if($(SECTION_ACTIVE_SEL).is(currentSection)){
1026-
isResizing = true;
1027-
}
1028-
scrollPage($(SECTION_ACTIVE_SEL));
1029-
1030-
isResizing = false;
1022+
//checking it again in case it changed during the delay
1023+
if(options.fitToSection){
1024+
fitToSection();
10311025
}
10321026
}, options.fitToSectionDelay);
10331027
}
10341028
}
10351029
}
10361030

1031+
function fitToSection(){
1032+
//checking fitToSection again in case it was set to false before the timeout delay
1033+
if(canScroll){
1034+
//allows to scroll to an active section and
1035+
//if the section is already active, we prevent firing callbacks
1036+
isResizing = true;
1037+
1038+
scrollPage($(SECTION_ACTIVE_SEL));
1039+
isResizing = false;
1040+
}
1041+
}
1042+
10371043
/**
10381044
* Determines whether the active section has seen in its whole or not.
10391045
*/

0 commit comments

Comments
 (0)