Skip to content

Commit

Permalink
Add handlersFor method
Browse files Browse the repository at this point in the history
  • Loading branch information
zaccharles committed Feb 23, 2016
1 parent 1153f6c commit 8e9d4ed
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/layzr.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export default (options = {}) => {

const instance = knot({
handlers: handlers,
handlersFor: handlersFor,
check: check,
update: update
})
Expand Down Expand Up @@ -110,6 +111,15 @@ export default (options = {}) => {
;['scroll', 'resize'].forEach(event => window[action](event, requestScroll))
return this
}

function handlersFor(node, flag) {
const action = flag
? 'addEventListener'
: 'removeEventListener'

;node[action]('scroll', requestFrame))
return this
}

function check() {
windowHeight = window.innerHeight
Expand Down

0 comments on commit 8e9d4ed

Please sign in to comment.