intersection-observer
Advanced tools
Comparing version 0.3.2 to 0.3.3
@@ -566,13 +566,8 @@ /** | ||
var spy = sinon.spy(); | ||
io = new IntersectionObserver(spy); | ||
io = new IntersectionObserver(spy, {root: rootEl}); | ||
runSequence([ | ||
function(done) { | ||
rootEl.style.position = 'absolute'; | ||
rootEl.style.top = '0px'; | ||
rootEl.style.left = '0px'; | ||
rootEl.style.width = '0px'; | ||
rootEl.style.height = '0px'; | ||
rootEl.style.display = 'none'; | ||
io.observe(rootEl); | ||
io.observe(targetEl1); | ||
setTimeout(function() { | ||
@@ -599,3 +594,3 @@ expect(spy.callCount).to.be(1); | ||
function(done) { | ||
rootEl.style.display = 'none'; | ||
parentEl.style.display = 'none'; | ||
setTimeout(function() { | ||
@@ -609,2 +604,24 @@ expect(spy.callCount).to.be(3); | ||
}, ASYNC_TIMEOUT); | ||
}, | ||
function(done) { | ||
parentEl.style.display = 'block'; | ||
setTimeout(function() { | ||
expect(spy.callCount).to.be(4); | ||
var records = sortRecords(spy.lastCall.args[0]); | ||
expect(records.length).to.be(1); | ||
expect(records[0].isIntersecting).to.be(true); | ||
expect(records[0].intersectionRatio).to.be(1); | ||
done(); | ||
}, ASYNC_TIMEOUT); | ||
}, | ||
function(done) { | ||
targetEl1.style.display = 'none'; | ||
setTimeout(function() { | ||
expect(spy.callCount).to.be(5); | ||
var records = sortRecords(spy.lastCall.args[0]); | ||
expect(records.length).to.be(1); | ||
expect(records[0].isIntersecting).to.be(false); | ||
expect(records[0].intersectionRatio).to.be(0); | ||
done(); | ||
}, ASYNC_TIMEOUT); | ||
} | ||
@@ -611,0 +628,0 @@ ], done); |
@@ -371,3 +371,7 @@ /** | ||
var parentRect = null; | ||
var parentComputedStyle = window.getComputedStyle(parent); | ||
// If the parent isn't displayed, an intersection can't happen. | ||
if (parentComputedStyle.display == 'none') return; | ||
// If we're at the root element, set parentRect to the already | ||
@@ -386,3 +390,3 @@ // calculated rootRect. And since <body> and <html> cannot be clipped | ||
else { | ||
if (window.getComputedStyle(parent).overflow != 'visible') { | ||
if (parentComputedStyle.overflow != 'visible') { | ||
parentRect = getBoundingClientRect(parent); | ||
@@ -389,0 +393,0 @@ } |
{ | ||
"name": "intersection-observer", | ||
"version": "0.3.2", | ||
"version": "0.3.3", | ||
"description": "A polyfill for IntersectionObserver", | ||
@@ -5,0 +5,0 @@ "main": "intersection-observer", |
66844
1519