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.3.0 to 1.3.1

4

package.json
{
"name": "scroll-into-view",
"version": "1.3.0",
"version": "1.3.1",
"description": "",

@@ -14,3 +14,3 @@ "main": "scrollIntoView.js",

"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"test": "browserify test/test.js -d -o test/test.browser.js && google-chrome ./test/test.html",
"watch": "watchify test/test.js -d -o test/test.browser.js"

@@ -17,0 +17,0 @@ },

@@ -33,2 +33,10 @@ # scroll-into-view

// Scrolling done.
})
})
## Testing
Testing scrolling is really hard without stuff like webdriver, but what's there works ok for the moment.
The tests will attempt to launch google-chrome. If you don't have chrome, lol just kidding you do.
npm run test

@@ -24,4 +24,4 @@ var raf = require('raf');

y = targetPosition.top + window.scrollY - window.innerHeight / 2 + Math.min(targetPosition.height, window.innerHeight) / 2;
x = Math.max(Math.min(x, document.body.clientWidth - window.innerWidth / 2), 0);
y = Math.max(Math.min(y, document.body.clientHeight - window.innerHeight / 2), 0);
x = Math.max(Math.min(x, document.body.scrollWidth - window.innerWidth / 2), 0);
y = Math.max(Math.min(y, document.body.scrollHeight- window.innerHeight / 2), 0);
differenceX = x - window.scrollX;

@@ -28,0 +28,0 @@ differenceY = y - window.scrollY;

@@ -166,2 +166,33 @@ var test = require('tape'),

});
});
});
test('body height less than scroll height', function(t) {
var target;
t.plan(1);
queue(function(next){
crel(document.documentElement, {'style': 'height: 100%'},
crel(document.body, {'style':'height: 100%'},
crel('div', {'style':'position:relative; height:5000px;'},
crel('div', {'style':'position:relative; font-size:20em; display:inline-block'},
target = crel('span', {'style':'position:absolute; top:75%; left: 75%; box-shadow: 0 0 10px 10px red;'}),
crel('div', {style: 'white-space:nowrap;'}, 'TEXT-AND-THAT-TO-MAKE-STUFF-HELA-WIDE'),
crel('div', {style: 'white-space:nowrap;'}, 'TEXT-AND-THAT-TO-MAKE-STUFF-HELA-WIDE'),
crel('div', {style: 'white-space:nowrap;'}, 'TEXT-AND-THAT-TO-MAKE-STUFF-HELA-WIDE')
)
)
)
);
scrollIntoView(target, function(){
t.ok(
target.getBoundingClientRect().top < window.innerHeight &&
target.getBoundingClientRect().left < window.innerWidth,
'target was in view'
);
next();
});
});
});
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