Skip to content

Commit 0c7a1a2

Browse files
committed
call _addListeners after the function declaration
1 parent 6511970 commit 0c7a1a2

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

src/libs/ParallaxController.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,17 @@ function ParallaxController() {
3636
// Passive support
3737
const supportsPassive = testForPassiveScroll();
3838

39+
function _addListeners() {
40+
window.addEventListener('scroll', _handleScroll, supportsPassive ? { passive: true } : false);
41+
window.addEventListener('resize', _handleResize, false);
42+
}
43+
3944
function _removeListeners() {
4045
window.removeEventListener('scroll', _handleScroll, supportsPassive ? { passive: true } : false);
4146
window.removeEventListener('resize', _handleResize, false);
4247
}
4348

44-
function _addListeners() {
45-
window.addEventListener('scroll', _handleScroll, supportsPassive ? { passive: true } : false);
46-
window.addEventListener('resize', _handleResize, false);
47-
}
49+
_addListeners();
4850

4951
/**
5052
* Window scroll handler sets the scrollY
@@ -351,9 +353,6 @@ function ParallaxController() {
351353
_removeParallaxStyles();
352354
window.ParallaxController = null;
353355
};
354-
355-
// Initialize the Parallax scroll listener
356-
_addListeners();
357356
}
358357

359358
/**

0 commit comments

Comments
 (0)