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 11export Parallax from './components/Parallax' ;
2+ export ParallaxScroller from './libs/ParallaxScroller' ;
Original file line number Diff line number Diff line change 44 testForPassiveScroll ,
55} from '../utils/index' ;
66
7- ( function ( window , document ) {
7+ const ParallaxScroller = ( function ( ) {
88
99 function ParallaxScrollListener ( ) {
1010
@@ -349,10 +349,19 @@ import {
349349
350350 // Initialize the Parallax scroll listener
351351 _addListeners ( ) ;
352-
353352 }
354353
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+ } ) ( ) ;
356365
357- } ) ( window , document ) ;
366+ export default ParallaxScroller ;
358367
You can’t perform that action at this time.
0 commit comments