File tree Expand file tree Collapse file tree 2 files changed +14
-4
lines changed Expand file tree Collapse file tree 2 files changed +14
-4
lines changed Original file line number Diff line number Diff line change 1
1
export Parallax from './components/Parallax' ;
2
+ export ParallaxScroller from './libs/ParallaxScroller' ;
Original file line number Diff line number Diff line change 4
4
testForPassiveScroll ,
5
5
} from '../utils/index' ;
6
6
7
- ( function ( window , document ) {
7
+ const ParallaxScroller = ( function ( ) {
8
8
9
9
function ParallaxScrollListener ( ) {
10
10
@@ -349,10 +349,19 @@ import {
349
349
350
350
// Initialize the Parallax scroll listener
351
351
_addListeners ( ) ;
352
-
353
352
}
354
353
355
- window . ParallaxScrollListener = new ParallaxScrollListener ( ) ;
354
+ return {
355
+ // Return the singleton instance if one exists
356
+ // or create one if it doesn't
357
+ init : function ( ) {
358
+ if ( ! window . ParallaxScrollListener ) {
359
+ window . ParallaxScrollListener = new ParallaxScrollListener ( ) ;
360
+ }
361
+ return window . ParallaxScrollListener ;
362
+ } ,
363
+ } ;
364
+ } ) ( ) ;
356
365
357
- } ) ( window , document ) ;
366
+ export default ParallaxScroller ;
358
367
You can’t perform that action at this time.
0 commit comments