From 4bc6cf0b50f7643a05f0cbd7f569cacca548d6d4 Mon Sep 17 00:00:00 2001 From: Isaac Alves Date: Tue, 3 Feb 2015 15:48:39 -0200 Subject: [PATCH] Add option for using a custom scrollable element (defaults to window) --- background-check.js | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/background-check.js b/background-check.js index 5aadb32..80b6fb8 100755 --- a/background-check.js +++ b/background-check.js @@ -37,16 +37,17 @@ } // Default values - attrs.debug = checkAttr(a.debug, false); - attrs.debugOverlay = checkAttr(a.debugOverlay, false); - attrs.targets = getElements(a.targets); - attrs.images = getElements(a.images || 'img', true); - attrs.changeParent = checkAttr(a.changeParent, false); - attrs.threshold = checkAttr(a.threshold, 50); - attrs.minComplexity = checkAttr(a.minComplexity, 30); - attrs.minOverlap = checkAttr(a.minOverlap, 50); - attrs.windowEvents = checkAttr(a.windowEvents, true); - attrs.maxDuration = checkAttr(a.maxDuration, 500); + attrs.debug = checkAttr(a.debug, false); + attrs.debugOverlay = checkAttr(a.debugOverlay, false); + attrs.targets = getElements(a.targets); + attrs.images = getElements(a.images || 'img', true); + attrs.changeParent = checkAttr(a.changeParent, false); + attrs.threshold = checkAttr(a.threshold, 50); + attrs.minComplexity = checkAttr(a.minComplexity, 30); + attrs.minOverlap = checkAttr(a.minOverlap, 50); + attrs.windowEvents = checkAttr(a.windowEvents, true); + attrs.maxDuration = checkAttr(a.maxDuration, 500); + attrs.scrollableElement = checkAttr(a.scrollableElement, window); attrs.mask = checkAttr(a.mask, { r: 0, @@ -75,7 +76,7 @@ check(); })); - window.addEventListener('scroll', throttle.bind(null, check)); + attrs.scrollableElement.addEventListener('scroll', throttle.bind(null, check)); resizeCanvas(); check();