intersection-observer
Advanced tools
Comparing version 0.9.0 to 0.10.0
@@ -54,3 +54,3 @@ /** | ||
* that the polyfill is configured to work in a cross-origin mode. | ||
* @type {function(DOMRect, DOMRect)} | ||
* @type {function(DOMRect|ClientRect, DOMRect|ClientRect)} | ||
*/ | ||
@@ -61,3 +61,3 @@ var crossOriginUpdater = null; | ||
* The current cross-origin intersection. Only used in the cross-origin mode. | ||
* @type {DOMRect} | ||
* @type {DOMRect|ClientRect} | ||
*/ | ||
@@ -76,5 +76,5 @@ var crossOriginRect = null; | ||
this.target = entry.target; | ||
this.rootBounds = entry.rootBounds; | ||
this.boundingClientRect = entry.boundingClientRect; | ||
this.intersectionRect = entry.intersectionRect || getEmptyRect(); | ||
this.rootBounds = ensureDOMRect(entry.rootBounds); | ||
this.boundingClientRect = ensureDOMRect(entry.boundingClientRect); | ||
this.intersectionRect = ensureDOMRect(entry.intersectionRect || getEmptyRect()); | ||
this.isIntersecting = !!entry.intersectionRect; | ||
@@ -173,3 +173,3 @@ | ||
* window, e.g. via messaging. | ||
* @return {function(DOMRect, DOMRect)} | ||
* @return {function(DOMRect|ClientRect, DOMRect|ClientRect)} | ||
*/ | ||
@@ -179,4 +179,4 @@ IntersectionObserver._setupCrossOriginUpdater = function() { | ||
/** | ||
* @param {DOMRect} boundingClientRect | ||
* @param {DOMRect} intersectionRect | ||
* @param {DOMRect|ClientRect} boundingClientRect | ||
* @param {DOMRect|ClientRect} intersectionRect | ||
*/ | ||
@@ -601,3 +601,3 @@ crossOriginUpdater = function(boundingClientRect, intersectionRect) { | ||
* Returns the root rect after being expanded by the rootMargin value. | ||
* @return {Object} The expanded root rect. | ||
* @return {ClientRect} The expanded root rect. | ||
* @private | ||
@@ -628,4 +628,4 @@ */ | ||
* Accepts a rect and expands it by the rootMargin value. | ||
* @param {Object} rect The rect object to expand. | ||
* @return {Object} The expanded rect. | ||
* @param {DOMRect|ClientRect} rect The rect object to expand. | ||
* @return {ClientRect} The expanded rect. | ||
* @private | ||
@@ -802,4 +802,4 @@ */ | ||
* @param {Object} rect2 The second rect. | ||
* @return {?Object} The intersection rect or undefined if no intersection | ||
* is found. | ||
* @return {?Object|?ClientRect} The intersection rect or undefined if no | ||
* intersection is found. | ||
*/ | ||
@@ -828,3 +828,3 @@ function computeRectIntersection(rect1, rect2) { | ||
* @param {Element} el The element whose bounding rect to get. | ||
* @return {Object} The (possibly shimmed) rect of the element. | ||
* @return {DOMRect|ClientRect} The (possibly shimmed) rect of the element. | ||
*/ | ||
@@ -861,3 +861,3 @@ function getBoundingClientRect(el) { | ||
* is not in the DOM. | ||
* @return {Object} The empty rect. | ||
* @return {ClientRect} The empty rect. | ||
*/ | ||
@@ -877,7 +877,36 @@ function getEmptyRect() { | ||
/** | ||
* Ensure that the result has all of the necessary fields of the DOMRect. | ||
* Specifically this ensures that `x` and `y` fields are set. | ||
* | ||
* @param {?DOMRect|?ClientRect} rect | ||
* @return {?DOMRect} | ||
*/ | ||
function ensureDOMRect(rect) { | ||
// A `DOMRect` object has `x` and `y` fields. | ||
if (!rect || 'x' in rect) { | ||
return rect; | ||
} | ||
// A IE's `ClientRect` type does not have `x` and `y`. The same is the case | ||
// for internally calculated Rect objects. For the purposes of | ||
// `IntersectionObserver`, it's sufficient to simply mirror `left` and `top` | ||
// for these fields. | ||
return { | ||
top: rect.top, | ||
y: rect.top, | ||
bottom: rect.bottom, | ||
left: rect.left, | ||
x: rect.left, | ||
right: rect.right, | ||
width: rect.width, | ||
height: rect.height | ||
}; | ||
} | ||
/** | ||
* Inverts the intersection and bounding rect from the parent (frame) BCR to | ||
* the local BCR space. | ||
* @param {Object} parentBoundingRect The parent's bound client rect. | ||
* @param {Object} parentIntersectionRect The parent's own intersection rect. | ||
* @return {Object} The local root bounding rect for the parent's children. | ||
* @param {DOMRect|ClientRect} parentBoundingRect The parent's bound client rect. | ||
* @param {DOMRect|ClientRect} parentIntersectionRect The parent's own intersection rect. | ||
* @return {ClientRect} The local root bounding rect for the parent's children. | ||
*/ | ||
@@ -884,0 +913,0 @@ function convertFromParentRect(parentBoundingRect, parentIntersectionRect) { |
{ | ||
"name": "intersection-observer", | ||
"version": "0.9.0", | ||
"version": "0.10.0", | ||
"description": "A polyfill for IntersectionObserver", | ||
@@ -5,0 +5,0 @@ "main": "intersection-observer", |
Sorry, the diff of this file is too big to display
131022
3094