scroll-into-view
Advanced tools
Comparing version 1.0.0 to 1.0.1
{ | ||
"name": "scroll-into-view", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "", | ||
@@ -19,4 +19,4 @@ "main": "scrollIntoView.js", | ||
"tape": "~2.1.0", | ||
"crel": "~1.1.0" | ||
"crel": "^1.1.1" | ||
} | ||
} |
@@ -7,6 +7,6 @@ module.exports = function(target){ | ||
var parent = target.parentNode, | ||
targetPosition; | ||
targetPosition = target.getBoundingClientRect(), | ||
parentOverflow; | ||
while(parent && parent !== document){ | ||
targetPosition = target.getBoundingClientRect(); | ||
while(parent && parent.tagName !== 'BODY'){ | ||
parentOverflow = window.getComputedStyle(parent).overflow; | ||
@@ -19,4 +19,4 @@ if( | ||
){ | ||
parent.scrollTop += targetPosition.top - parent.clientHeight / 2; | ||
parent.scrollLeft += targetPosition.left - parent.clientWidth / 2; | ||
parent.scrollTop = target.offsetTop + (targetPosition.height / 2) - parent.clientHeight / 2; | ||
parent.scrollLeft = target.offsetTop + (targetPosition.width / 2) - parent.clientWidth / 2; | ||
} | ||
@@ -26,2 +26,7 @@ | ||
} | ||
window.scrollTo( | ||
targetPosition.left + window.scrollX - window.innerWidth / 2 + Math.min(targetPosition.width, window.innerWidth) / 2, | ||
targetPosition.top + window.scrollY - window.innerHeight / 2 + Math.min(targetPosition.height, window.innerHeight) / 2 | ||
); | ||
}; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4128
8
84