Skip to content

Commit 8e9d4ed

Browse files
committed
Add handlersFor method
1 parent 1153f6c commit 8e9d4ed

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

src/layzr.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export default (options = {}) => {
3232

3333
const instance = knot({
3434
handlers: handlers,
35+
handlersFor: handlersFor,
3536
check: check,
3637
update: update
3738
})
@@ -110,6 +111,15 @@ export default (options = {}) => {
110111
;['scroll', 'resize'].forEach(event => window[action](event, requestScroll))
111112
return this
112113
}
114+
115+
function handlersFor(node, flag) {
116+
const action = flag
117+
? 'addEventListener'
118+
: 'removeEventListener'
119+
120+
;node[action]('scroll', requestFrame))
121+
return this
122+
}
113123

114124
function check() {
115125
windowHeight = window.innerHeight

0 commit comments

Comments
 (0)