Socket
Socket
Sign inDemoInstall

scroll-into-view

Package Overview
Dependencies
Maintainers
1
Versions
50
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

scroll-into-view - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

test/test2.html

4

package.json
{
"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
);
};
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc