1
1
/*!
2
- * fullPage 2.8.1
2
+ * fullPage 2.8.2
3
3
* https://github.com/alvarotrigo/fullPage.js
4
4
* @license MIT licensed
5
5
*
94
94
mouseWheel : true ,
95
95
hideScrollbars : false ,
96
96
fadeScrollbars : false ,
97
- disableMouse : true ,
98
-
99
- //fixing bug in iScroll with links: https://github.com/cubiq/iscroll/issues/783
100
- click : true
97
+ disableMouse : true
101
98
} ;
102
99
103
100
$ . fn . fullpage = function ( options ) {
143
140
scrollOverflowOptions : null ,
144
141
touchSensitivity : 5 ,
145
142
normalScrollElementTouchThreshold : 5 ,
143
+ bigSectionsDestination : null ,
146
144
147
145
//Accessibility
148
146
keyboardScrolling : true ,
176
174
onSlideLeave : null
177
175
} , options ) ;
178
176
177
+ //flag to avoid very fast sliding for landscape sliders
178
+ var slideMoving = false ;
179
+
180
+ var isTouchDevice = navigator . userAgent . match ( / ( i P h o n e | i P o d | i P a d | A n d r o i d | p l a y b o o k | s i l k | B l a c k B e r r y | B B 1 0 | W i n d o w s P h o n e | T i z e n | B a d a | w e b O S | I E M o b i l e | O p e r a M i n i ) / ) ;
181
+ var isTouch = ( ( 'ontouchstart' in window ) || ( navigator . msMaxTouchPoints > 0 ) || ( navigator . maxTouchPoints ) ) ;
182
+ var container = $ ( this ) ;
183
+ var windowsHeight = $window . height ( ) ;
184
+ var isResizing = false ;
185
+ var isWindowFocused = true ;
186
+ var lastScrolledDestiny ;
187
+ var lastScrolledSlide ;
188
+ var canScroll = true ;
189
+ var scrollings = [ ] ;
190
+ var controlPressed ;
191
+ var isScrollAllowed = { } ;
192
+ isScrollAllowed . m = { 'up' :true , 'down' :true , 'left' :true , 'right' :true } ;
193
+ isScrollAllowed . k = $ . extend ( true , { } , isScrollAllowed . m ) ;
194
+
195
+ //timeouts
196
+ var resizeId ;
197
+ var afterSectionLoadsId ;
198
+ var afterSlideLoadsId ;
199
+ var scrollId ;
200
+ var scrollId2 ;
201
+ var keydownId ;
202
+ var originals = $ . extend ( true , { } , options ) ; //deep copy
203
+
179
204
displayWarnings ( ) ;
180
205
206
+ //fixing bug in iScroll with links: https://github.com/cubiq/iscroll/issues/783
207
+ iscrollOptions . click = isTouch ; // see #2035
208
+
181
209
//extending iScroll options with the user custom ones
182
210
iscrollOptions = $ . extend ( iscrollOptions , options . scrollOverflowOptions ) ;
183
211
462
490
}
463
491
} ;
464
492
465
- //flag to avoid very fast sliding for landscape sliders
466
- var slideMoving = false ;
467
-
468
- var isTouchDevice = navigator . userAgent . match ( / ( i P h o n e | i P o d | i P a d | A n d r o i d | p l a y b o o k | s i l k | B l a c k B e r r y | B B 1 0 | W i n d o w s P h o n e | T i z e n | B a d a | w e b O S | I E M o b i l e | O p e r a M i n i ) / ) ;
469
- var isTouch = ( ( 'ontouchstart' in window ) || ( navigator . msMaxTouchPoints > 0 ) || ( navigator . maxTouchPoints ) ) ;
470
- var container = $ ( this ) ;
471
- var windowsHeight = $window . height ( ) ;
472
- var isResizing = false ;
473
- var isWindowFocused = true ;
474
- var lastScrolledDestiny ;
475
- var lastScrolledSlide ;
476
- var canScroll = true ;
477
- var scrollings = [ ] ;
478
- var nav ;
479
- var controlPressed ;
480
- var isScrollAllowed = { } ;
481
- isScrollAllowed . m = { 'up' :true , 'down' :true , 'left' :true , 'right' :true } ;
482
- isScrollAllowed . k = $ . extend ( true , { } , isScrollAllowed . m ) ;
483
- var originals = $ . extend ( true , { } , options ) ; //deep copy
484
-
485
- //timeouts
486
- var resizeId ;
487
- var afterSectionLoadsId ;
488
- var afterSlideLoadsId ;
489
- var scrollId ;
490
- var scrollId2 ;
491
- var keydownId ;
492
-
493
493
if ( $ ( this ) . length ) {
494
494
init ( ) ;
495
495
bindEvents ( ) ;
754
754
*/
755
755
function addInternalSelectors ( ) {
756
756
//adding internal class names to void problem with common ones
757
- $ ( options . sectionSelector ) . each ( function ( ) {
757
+ container . find ( options . sectionSelector ) . each ( function ( ) {
758
758
$ ( this ) . addClass ( SECTION ) ;
759
759
} ) ;
760
- $ ( options . slideSelector ) . each ( function ( ) {
760
+ container . find ( options . slideSelector ) . each ( function ( ) {
761
761
$ ( this ) . addClass ( SLIDE ) ;
762
762
} ) ;
763
763
}
895
895
var scrollDirection = getScrollDirection ( currentScroll ) ;
896
896
var visibleSectionIndex = 0 ;
897
897
var screen_mid = currentScroll + ( $window . height ( ) / 2.0 ) ;
898
+ var isAtBottom = $body . height ( ) - $window . height ( ) === currentScroll ;
899
+ var sections = document . querySelectorAll ( SECTION_SEL ) ;
900
+
901
+ //when using `auto-height` for a small last section it won't take most of the viewport
902
+ if ( isAtBottom ) {
903
+ visibleSectionIndex = sections . length - 1 ;
904
+ }
898
905
899
906
//taking the section which is showing more content in the viewport
900
- var sections = document . querySelectorAll ( SECTION_SEL ) ;
901
- for ( var i = 0 ; i < sections . length ; ++ i ) {
902
- var section = sections [ i ] ;
907
+ else {
908
+ for ( var i = 0 ; i < sections . length ; ++ i ) {
909
+ var section = sections [ i ] ;
903
910
904
- // Pick the the last section which passes the middle line of the screen.
905
- if ( section . offsetTop <= screen_mid )
906
- {
907
- visibleSectionIndex = i ;
911
+ // Pick the the last section which passes the middle line of the screen.
912
+ if ( section . offsetTop <= screen_mid )
913
+ {
914
+ visibleSectionIndex = i ;
915
+ }
908
916
}
909
917
}
910
918
937
945
currentSection . addClass ( ACTIVE ) . siblings ( ) . removeClass ( ACTIVE ) ;
938
946
939
947
$ . isFunction ( options . onLeave ) && options . onLeave . call ( leavingSection , leavingSectionIndex , sectionIndex , yMovement ) ;
940
-
941
948
$ . isFunction ( options . afterLoad ) && options . afterLoad . call ( currentSection , anchorLink , sectionIndex ) ;
949
+
950
+ stopMedia ( leavingSection ) ;
942
951
lazyLoad ( currentSection ) ;
952
+ playMedia ( currentSection ) ;
943
953
944
954
activateMenuAndNav ( anchorLink , sectionIndex - 1 ) ;
945
955
1000
1010
1001
1011
lastScroll = currentScroll ;
1002
1012
1013
+ //needed for auto-height sections to determine if we want to scroll to the top or bottom of the destination
1014
+ previousDestTop = currentScroll ;
1015
+
1003
1016
return direction ;
1004
1017
}
1005
1018
1302
1315
var position = elemPosition . top ;
1303
1316
var isScrollingDown = elemPosition . top > previousDestTop ;
1304
1317
var sectionBottom = position - windowsHeight + element . outerHeight ( ) ;
1318
+ var bigSectionsDestination = options . bigSectionsDestination ;
1305
1319
1306
1320
//is the destination element bigger than the viewport?
1307
1321
if ( element . outerHeight ( ) > windowsHeight ) {
1308
- //scrolling up?
1309
- if ( ! isScrollingDown ) {
1322
+ //scrolling up?
1323
+ if ( ! isScrollingDown && ! bigSectionsDestination || bigSectionsDestination === 'bottom' ) {
1310
1324
position = sectionBottom ;
1311
1325
}
1312
1326
}
1520
1534
function afterSectionLoads ( v ) {
1521
1535
continuousVerticalFixSectionOrder ( v ) ;
1522
1536
1523
- v . element . find ( '.fp-scrollable' ) . mouseover ( ) ;
1524
-
1525
1537
//callback (afterLoad) if the site is not just resizing and readjusting the slides
1526
1538
$ . isFunction ( options . afterLoad ) && ! v . localIsResizing && options . afterLoad . call ( v . element , v . anchorLink , ( v . sectionIndex + 1 ) ) ;
1527
1539
options . scrollOverflowHandler . afterLoad ( ) ;
2082
2094
2083
2095
//needs scroll?
2084
2096
if ( contentHeight > scrollHeight ) {
2085
- //was there already an scroll ? Updating it
2097
+ //did we already have an scrollbar ? Updating it
2086
2098
if ( scrollable . length ) {
2087
2099
scrollOverflowHandler . update ( element , scrollHeight ) ;
2088
2100
}
2599
2611
//reseting the `top` or `translate` properties to 0
2600
2612
silentScroll ( 0 ) ;
2601
2613
2614
+ //loading all the lazy load content
2615
+ container . find ( 'img[data-src], source[data-src], audio[data-src], iframe[data-src]' ) . each ( function ( ) {
2616
+ $ ( this ) . attr ( 'src' , $ ( this ) . data ( 'src' ) ) ;
2617
+ $ ( this ) . removeAttr ( 'data-src' ) ;
2618
+ } ) ;
2619
+
2602
2620
$ ( SECTION_NAV_SEL + ', ' + SLIDES_NAV_SEL + ', ' + SLIDES_ARROW_SEL ) . remove ( ) ;
2603
2621
2604
2622
//removing inline styles
2627
2645
// remove .fp-enabled class
2628
2646
$ ( 'html' ) . removeClass ( ENABLED ) ;
2629
2647
2648
+ // remove .fp-responsive class
2649
+ $body . removeClass ( RESPONSIVE ) ;
2650
+
2630
2651
// remove all of the .fp-viewing- classes
2631
2652
$ . each ( $body . get ( 0 ) . className . split ( / \s + / ) , function ( index , className ) {
2632
2653
if ( className . indexOf ( VIEWING_PREFIX ) === 0 ) {
2766
2787
*/
2767
2788
onLeave : function ( ) {
2768
2789
var scroller = $ ( SECTION_ACTIVE_SEL ) . find ( SCROLLABLE_SEL ) . data ( 'iscrollInstance' ) ;
2769
-
2770
2790
if ( typeof scroller !== 'undefined' && scroller ) {
2771
2791
scroller . wheelOff ( ) ;
2772
2792
}
2776
2796
afterLoad : function ( ) {
2777
2797
var scroller = $ ( SECTION_ACTIVE_SEL ) . find ( SCROLLABLE_SEL ) . data ( 'iscrollInstance' ) ;
2778
2798
if ( typeof scroller !== 'undefined' && scroller ) {
2779
- scroller . wheelOn ( ) ;
2799
+ scroller . wheelOn ( ) ;
2780
2800
}
2781
2801
} ,
2782
2802
2798
2818
$ ( this ) . destroy ( ) ;
2799
2819
} ) ;
2800
2820
}
2821
+
2801
2822
iScrollInstance = new IScroll ( $this . get ( 0 ) , iscrollOptions ) ;
2802
2823
iscrollHandler . iScrollInstances . push ( iScrollInstance ) ;
2803
2824
$this . data ( 'iscrollInstance' , iScrollInstance ) ;
2814
2835
*/
2815
2836
isScrolled : function ( type , scrollable ) {
2816
2837
var scroller = scrollable . data ( 'iscrollInstance' ) ;
2817
-
2838
+
2839
+ //no scroller?
2818
2840
if ( ! scroller ) {
2819
- return false ;
2841
+ return true ;
2820
2842
}
2843
+
2821
2844
if ( type === 'top' ) {
2822
2845
return scroller . y >= 0 && ! scrollable . scrollTop ( ) ;
2823
2846
} else if ( type === 'bottom' ) {
2864
2887
var iScrollInstance = scrollable . data ( 'iscrollInstance' ) ;
2865
2888
iScrollInstance . destroy ( ) ;
2866
2889
2867
- scrollable . data ( 'iscrollInstance' , 'undefined' ) ;
2890
+ scrollable . data ( 'iscrollInstance' , null ) ;
2868
2891
}
2869
2892
element . find ( SCROLLABLE_SEL ) . children ( ) . first ( ) . children ( ) . first ( ) . unwrap ( ) . unwrap ( ) ;
2870
2893
} ,
2903
2926
}
2904
2927
} ;
2905
2928
2906
- } ) ;
2929
+ } ) ;
0 commit comments