scroll-into-view
Advanced tools
Comparing version 1.3.0 to 1.3.1
{ | ||
"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(); | ||
}); | ||
}); | ||
}); |
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
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
14598
297
1
41