Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

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.8.3 to 1.9.0

10

example/index.browser.js

@@ -129,3 +129,3 @@ (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){

// based on http://stackoverflow.com/questions/384286/javascript-isdom-how-do-you-check-if-a-javascript-object-is-a-dom-object
var isNode = typeof Node === 'object'
var isNode = typeof Node === 'function'
? function (object) { return object instanceof Node; }

@@ -350,3 +350,3 @@ : function (object) {

function isScrollable(element){
function defaultIsScrollable(element){
return (

@@ -394,5 +394,6 @@ element === window ||

var validTarget = settings.validTarget || defaultValidTarget;
var isScrollable = settings.isScrollable;
while(parent){
if(validTarget(parent, parents) && isScrollable(parent)){
if(validTarget(parent, parents) && (isScrollable ? isScrollable(parent, defaultIsScrollable) : defaultIsScrollable(parent))){
parents++;

@@ -414,2 +415,3 @@ transitionScrollTo(target, parent, settings, done);

},{}]},{},[1]);
},{}]},{},[1])
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIm5vZGVfbW9kdWxlcy9icm93c2VyLXBhY2svX3ByZWx1ZGUuanMiLCJleGFtcGxlL2luZGV4LmpzIiwibm9kZV9tb2R1bGVzL2NyZWwvY3JlbC5qcyIsInNjcm9sbEludG9WaWV3LmpzIl0sIm5hbWVz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BlO1xuICAgICAgICB9KTtcbiAgICB9XG5cbiAgICB2YXIgc2lkZSA9IDE7XG4gICAgZnVuY3Rpb24gYnV0dG9uVGV4dCgpe1xuICAgICAgICByZXR1cm4gJ2FsaWduICcgKyAoc2lkZSA/ICdyaWdodCcgOiAnbGVmdCcpICsgJyBlZGdlIHdpdGggbWVudSc7XG4gICAgfVxuICAgIGZ1bmN0aW9uIG1lbnVBbGlnbigpe1xuICAgICAgICB0YXJnZXQudGV4dENvbnRlbnQgPSAnc2Nyb2xsaW5nJztcbiAgICAgICAgc2Nyb2xsSW50b1ZpZXcodGFyZ2V0LCB7XG4gICAgICAgICAgICB0aW1lOiAxMDAwLFxuICAgICAgICAgICAgYWxpZ246e1xuICAgICAgICAgICAgICAgIHRvcDogMC41LFxuICAgICAgICAgICAgICAgIGxlZnQ6IDAsXG4gICAgICAgICAgICAgICAgbGVmdE9mZnNldDogc2lkZSA/IDIwMCA6IDQwLFxuICAgICAgICAgICAgICAgIHRvcE9mZnNldDogMFxuICAgICAgICAgICAgfVxuICAgICAgICB9LCBmdW5jdGlvbih0eXBlKXtcbiAgICAgICAgICAgIHRhcmdldC50ZXh0Q29udGVudCA9IHR5cGU7XG4gICAgICAgIH0pO1xuICAgICAgICBzaWRlID0gKHNpZGUgKyAxKSAlIDI7XG4gICAgICAgIGJ1dHRvbjMudGV4dENvbnRlbnQgPSBidXR0b25UZXh0KCk7XG4gICAgfVxuXG4gICAgdmFyIGJ1dHRvbixcbiAgICAgICAgYnV0dG9uMjtcblxuICAgIGNyZWwobWVudSxcbiAgICAgICAgYnV0dG9uID0gY3JlbCgnYnV0dG9uJywgeydzdHlsZSc6J3dpZHRoOiAxOTBweCd9LFxuICAgICAgICAgICAgJ3Njcm9sbCBpbnRvIHZpZXcnXG4gICAgICAgICksXG4gICAgICAgIGJ1dHRvbjIgPSBjcmVsKCdidXR0b24nLCB7J3N0eWxlJzond2lkdGg6IDE5MHB4J30sXG4gICAgICAgICAgICAnc2Nyb2xsIG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AgICAgICB9XHJcblxyXG4gICAgICAgIC8vIHNob3J0Y3V0IGlmIHRoZXJlIGlzIG9ubHkgb25lIGNoaWxkIHRoYXQgaXMgYSBzdHJpbmdcclxuICAgICAgICBpZigoYXJndW1lbnRzTGVuZ3RoIC0gY2hpbGRJbmRleCkgPT09IDEgJiYgdHlwZW9mIGFyZ3NbY2hpbGRJbmRleF0gPT09ICdzdHJpbmcnICYmIGVsZW1lbnQudGV4dENvbnRlbnQgIT09IHVuZGVmaW5lZCl7XHJcbiAgICAgICAgICAgIGVsZW1lbnQudGV4dENvbnRlbnQgPSBhcmdzW2NoaWxkSW5kZXhdO1xyXG4gICAgICAgIH1lbHNle1xyXG4gICAgICAgICAgICBmb3IoOyBjaGlsZEluZGV4IDwgYXJndW1lbnRzTGVuZ3RoOyArK2NoaWxkSW5kZXgpe1xyXG4gICAgICAgICAgICAgICAgY2hpbGQgPSBhcmdzW2NoaWxkSW5kZXhdO1xyXG5cclxuICAgICAgICAgICAgICAgIGlmKGNoaWxkID09IG51bGwpe1xyXG4gICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlO1xyXG4gICAgICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgICAgIGlmIChpc0FycmF5KGNoaWxkKSkge1xyXG4gICAgICAgICAgICAgICAgICBmb3IgKHZhciBpPTA7IGkgPCBjaGlsZC5sZW5ndGg7ICsraSkge1xyXG4gICAgICAgICAgICAgICAgICAgIGFwcGVuZENoaWxkKGVsZW1lbnQsIGNoaWxkW2ldKTtcclxuICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcclxuICAgICAgICAgICAgICAgICAgYXBwZW5kQ2hpbGQoZWxlbWVudCwgY2hpbGQpO1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgfVxyXG5cclxuICAgICAgICBmb3IodmFyIGtleSBpbiBzZXR0aW5ncyl7XHJcbiAgICAgICAgICAgIGl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gcGFyZW50LnBhcmVudEVsZW1lbnQ7XG5cbiAgICAgICAgaWYoIXBhcmVudCl7XG4gICAgICAgICAgICByZXR1cm47XG4gICAgICAgIH1cblxuICAgICAgICBpZihwYXJlbnQudGFnTmFtZSA9PT0gJ0JPRFknKXtcbiAgICAgICAgICAgIHBhcmVudCA9IHdpbmRvdztcbiAgICAgICAgfVxuICAgIH1cbn07XG4iXX0=

4

package.json
{
"name": "scroll-into-view",
"version": "1.8.3",
"version": "1.9.0",
"description": "",

@@ -22,4 +22,6 @@ "main": "scrollIntoView.js",

"devDependencies": {
"browserify": "^14.4.0",
"crel": "^1.1.1",
"tape": "~2.1.0",
"uglifyify": "^4.0.2",
"watchify": "^3.9.0"

@@ -26,0 +28,0 @@ },

@@ -27,12 +27,21 @@ # scroll-into-view

All options are optional.
```javascript
scrollIntoView(someElement, {
time: 500, // half a second
ease: function(value){
return Math.pow(value,2) - value; // Do something weird.
},
validTarget: function(target, parentsScrolled){
// Only scroll the first two elements that don't have the class "dontScroll"
return parentsScrolled < 2 && target !== window && !target.matches('.dontScroll');
},
align:{

@@ -43,3 +52,12 @@ top: 0 to 1, default 0.5 (center)

leftOffset: pixels to offset left alignment
},
isScrollable: function(target, defaultIsScrollable){
// By default scroll-into-view will only attempt to scroll elements that have overflow not set to `"hidden"` and who's scroll width/height is larger than their client height.
// You can override this check by passing an `isScrollable` function to settings:
return defaultIsScrollable(target) || ~target.className.indexOf('scrollable');
}
});

@@ -57,2 +75,6 @@ ```

## Size
Small. ~3.03 KB for the standalone.
## Testing

@@ -78,2 +100,2 @@

</script>
```
```

@@ -135,3 +135,3 @@ var COMPLETE = 'complete',

function isScrollable(element){
function defaultIsScrollable(element){
return (

@@ -179,5 +179,6 @@ element === window ||

var validTarget = settings.validTarget || defaultValidTarget;
var isScrollable = settings.isScrollable;
while(parent){
if(validTarget(parent, parents) && isScrollable(parent)){
if(validTarget(parent, parents) && (isScrollable ? isScrollable(parent, defaultIsScrollable) : defaultIsScrollable(parent))){
parents++;

@@ -184,0 +185,0 @@ transitionScrollTo(target, parent, settings, done);

(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
function raf(t){if("requestAnimationFrame"in window)return window.requestAnimationFrame(t);setTimeout(t,16)}function setElementScroll(t,e,n){t===window?t.scrollTo(e,n):(t.scrollLeft=e,t.scrollTop=n)}function getTargetScrollLocation(t,e,n){var i,l,o,r,a,s,c,f=t.getBoundingClientRect(),d=n&&null!=n.left?n.left:.5,g=n&&null!=n.top?n.top:.5,m=n&&null!=n.leftOffset?n.leftOffset:0,u=n&&null!=n.topOffset?n.topOffset:0,w=d,h=g;if(e===window)s=Math.min(f.width,window.innerWidth),c=Math.min(f.height,window.innerHeight),l=f.left+window.pageXOffset-window.innerWidth*w+s*w,o=f.top+window.pageYOffset-window.innerHeight*h+c*h,o-=u,r=(l-=m)-window.pageXOffset,a=o-window.pageYOffset;else{s=f.width,c=f.height,i=e.getBoundingClientRect();var p=f.left-(i.left-e.scrollLeft),E=f.top-(i.top-e.scrollTop);l=p+s*w-e.clientWidth*w,o=E+c*h-e.clientHeight*h,l=Math.max(Math.min(l,e.scrollWidth-e.clientWidth),0),o=Math.max(Math.min(o,e.scrollHeight-e.clientHeight),0),o-=u,r=(l-=m)-e.scrollLeft,a=o-e.scrollTop}return{x:l,y:o,differenceX:r,differenceY:a}}function animate(t){raf(function(){var e=t._scrollSettings;if(e){var n=getTargetScrollLocation(e.target,t,e.align),i=Date.now()-e.startTime,l=Math.min(1/e.time*i,1);if(i>e.time+20)return setElementScroll(t,n.x,n.y),t._scrollSettings=null,e.end(COMPLETE);var o=1-e.ease(l);setElementScroll(t,n.x-n.differenceX*o,n.y-n.differenceY*o),animate(t)}})}function transitionScrollTo(t,e,n,i){function l(t){e._scrollSettings=null,e.parentElement&&e.parentElement._scrollSettings&&e.parentElement._scrollSettings.end(t),i(t),e.removeEventListener("touchstart",o)}var o,r=!e._scrollSettings,a=e._scrollSettings,s=Date.now();a&&a.end(CANCELED),e._scrollSettings={startTime:a?a.startTime:Date.now(),target:t,time:n.time+(a?s-a.startTime:0),ease:n.ease,align:n.align,end:l},o=l.bind(null,CANCELED),e.addEventListener("touchstart",o),r&&animate(e)}function isScrollable(t){return t===window||(t.scrollHeight!==t.clientHeight||t.scrollWidth!==t.clientWidth)&&"hidden"!==getComputedStyle(t).overflow}function defaultValidTarget(){return!0}var COMPLETE="complete",CANCELED="canceled";module.exports=function(t,e,n){if(t){"function"==typeof e&&(n=e,e=null),e||(e={}),e.time=isNaN(e.time)?1e3:e.time,e.ease=e.ease||function(t){return 1-Math.pow(1-t,t/2)};for(var i=t.parentElement,l=0,o=e.validTarget||defaultValidTarget;i;){if(o(i,l)&&isScrollable(i)&&(l++,transitionScrollTo(t,i,e,function(t){--l||n&&n(t)})),!(i=i.parentElement))return;"BODY"===i.tagName&&(i=window)}}};
function raf(t){if("requestAnimationFrame"in window)return window.requestAnimationFrame(t);setTimeout(t,16)}function setElementScroll(t,e,n){t===window?t.scrollTo(e,n):(t.scrollLeft=e,t.scrollTop=n)}function getTargetScrollLocation(t,e,n){var i,l,o,r,a,f,s,c=t.getBoundingClientRect(),d=n&&null!=n.left?n.left:.5,u=n&&null!=n.top?n.top:.5,g=n&&null!=n.leftOffset?n.leftOffset:0,m=n&&null!=n.topOffset?n.topOffset:0,w=d,h=u;if(e===window)f=Math.min(c.width,window.innerWidth),s=Math.min(c.height,window.innerHeight),l=c.left+window.pageXOffset-window.innerWidth*w+f*w,o=c.top+window.pageYOffset-window.innerHeight*h+s*h,o-=m,r=(l-=g)-window.pageXOffset,a=o-window.pageYOffset;else{f=c.width,s=c.height,i=e.getBoundingClientRect();var p=c.left-(i.left-e.scrollLeft),E=c.top-(i.top-e.scrollTop);l=p+f*w-e.clientWidth*w,o=E+s*h-e.clientHeight*h,l=Math.max(Math.min(l,e.scrollWidth-e.clientWidth),0),o=Math.max(Math.min(o,e.scrollHeight-e.clientHeight),0),o-=m,r=(l-=g)-e.scrollLeft,a=o-e.scrollTop}return{x:l,y:o,differenceX:r,differenceY:a}}function animate(t){raf(function(){var e=t._scrollSettings;if(e){var n=getTargetScrollLocation(e.target,t,e.align),i=Date.now()-e.startTime,l=Math.min(1/e.time*i,1);if(i>e.time+20)return setElementScroll(t,n.x,n.y),t._scrollSettings=null,e.end(COMPLETE);var o=1-e.ease(l);setElementScroll(t,n.x-n.differenceX*o,n.y-n.differenceY*o),animate(t)}})}function transitionScrollTo(t,e,n,i){function l(t){e._scrollSettings=null,e.parentElement&&e.parentElement._scrollSettings&&e.parentElement._scrollSettings.end(t),i(t),e.removeEventListener("touchstart",o)}var o,r=!e._scrollSettings,a=e._scrollSettings,f=Date.now();a&&a.end(CANCELED),e._scrollSettings={startTime:a?a.startTime:Date.now(),target:t,time:n.time+(a?f-a.startTime:0),ease:n.ease,align:n.align,end:l},o=l.bind(null,CANCELED),e.addEventListener("touchstart",o),r&&animate(e)}function defaultIsScrollable(t){return t===window||(t.scrollHeight!==t.clientHeight||t.scrollWidth!==t.clientWidth)&&"hidden"!==getComputedStyle(t).overflow}function defaultValidTarget(){return!0}var COMPLETE="complete",CANCELED="canceled";module.exports=function(t,e,n){if(t){"function"==typeof e&&(n=e,e=null),e||(e={}),e.time=isNaN(e.time)?1e3:e.time,e.ease=e.ease||function(t){return 1-Math.pow(1-t,t/2)};for(var i=t.parentElement,l=0,o=e.validTarget||defaultValidTarget,r=e.isScrollable;i;){if(o(i,l)&&(r?r(i,defaultIsScrollable):defaultIsScrollable(i))&&(l++,transitionScrollTo(t,i,e,function(t){--l||n&&n(t)})),!(i=i.parentElement))return;"BODY"===i.tagName&&(i=window)}}};

@@ -4,0 +4,0 @@ },{}],2:[function(require,module,exports){

@@ -204,1 +204,47 @@ var test = require('tape'),

});
test('hidden scrollbars in firefox', function(t) {
var target;
if (navigator.userAgent.toLowerCase().indexOf('firefox') == -1) {
console.warn('not firefox, skipped');
return;
}
t.plan(3);
queue(function(next){
crel(document.body,
target = crel('div', {'style':'overflow: -moz-scrollbars-none;'})
);
t.ok(getComputedStyle(target).overflow === 'hidden', 'overflow reported as *hidden*')
crel(document.documentElement, {'style': 'height: 100%;'},
crel(document.body, {'style':'height: 100%;'},
crel('div', {'style':'position:relative; height:5000px; overflow: -moz-scrollbars-none;'},
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')
)
)
)
);
function isScrollable(element, defaultIsScrollable) {
return defaultIsScrollable(element) || element.parentElement === document.body;
}
scrollIntoView(target, {isScrollable: isScrollable}, function(type){
t.ok(
target.getBoundingClientRect().top < window.innerHeight &&
target.getBoundingClientRect().left < window.innerWidth,
'target was in view'
);
t.equal(type, 'complete');
next();
});
});
});

Sorry, the diff of this file is too big to display

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