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

@livelybone/scroll-get

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@livelybone/scroll-get - npm Package Compare versions

Comparing version 6.1.0 to 6.1.1

2

index.d.ts

@@ -134,3 +134,3 @@ declare function getRect(el: Element): DOMRect

el?: HTMLElement | null,
scroller?: HTMLElement | null,
scroller?: DOMRect | HTMLElement | null,
): boolean

@@ -137,0 +137,0 @@

/**
* Bundle of @livelybone/scroll-get
* Generated: 2021-05-27
* Version: 6.1.0
* Version: 6.1.1
* License: MIT

@@ -380,3 +380,3 @@ * Author: 2631541504@qq.com

var rect = el.getBoundingClientRect();
var scrollerRect = scroller.getBoundingClientRect();
var scrollerRect = 'nodeType' in scroller ? scroller.getBoundingClientRect() : scroller;
var windowRect = {

@@ -383,0 +383,0 @@ x: 0,

/**
* Bundle of @livelybone/scroll-get
* Generated: 2021-05-27
* Version: 6.1.0
* Version: 6.1.1
* License: MIT

@@ -9,2 +9,2 @@ * Author: 2631541504@qq.com

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).ScrollGet={})}(this,function(e){"use strict";function t(t,e){var n,r=Object.keys(t);return Object.getOwnPropertySymbols&&(n=Object.getOwnPropertySymbols(t),e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)),r}function p(r){for(var e=1;e<arguments.length;e++){var i=null!=arguments[e]?arguments[e]:{};e%2?t(Object(i),!0).forEach(function(e){var t,n;t=r,e=i[n=e],n in t?Object.defineProperty(t,n,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[n]=e}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(i)):t(Object(i)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(i,e))})}return r}function s(e,t){if(null==e)return{};var n,r=function(e,t){if(null==e)return{};for(var n,r={},i=Object.keys(e),o=0;o<i.length;o++)n=i[o],0<=t.indexOf(n)||(r[n]=e[n]);return r}(e,t);if(Object.getOwnPropertySymbols)for(var i=Object.getOwnPropertySymbols(e),o=0;o<i.length;o++)n=i[o],0<=t.indexOf(n)||Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n]);return r}function w(e){return e.getBoundingClientRect()}function n(e){return e+(1-e)*e}function v(r,i,e){function o(e){window.requestAnimationFrame(function(){e()&&o(e)})}var l=e||n;return new Promise(function(t){var n=Date.now();o(function(){var e=l(Math.min(1,(Date.now()-n)/r));return i(e),!(1<=e)||(t(),!1)})})}function m(e){var t=window.getComputedStyle(e),n={top:0,left:0};return"HTML"!==e.nodeName&&!["scroll","auto","overlay"].includes(t.overflowX)||(n.left=Math.max(0,e.scrollWidth-e.clientWidth)),"HTML"!==e.nodeName&&!["scroll","auto","overlay"].includes(t.overflowY)||(n.top=Math.max(0,e.scrollHeight-e.clientHeight)),n}function r(e){return!e.top&&!e.left}function g(e){if(null!=e&&e.style){var t=window.getComputedStyle(e);if("fixed"!==t.position){var n=e.ownerDocument;if("absolute"===t.position)return e.offsetParent?g(e.offsetParent):r(m(n.body))?g(n.body):n.body;e=e.parentElement;return e?r(m(e))&&e!==n.documentElement?g(e):e:void 0}}}e.animation=v,e.getMaxScrollOffset=m,e.getNativeScrollbarWidth=function(e){var t=e||window,n=t===window;try{var r,i,o=n?window.nativeScrollbarWidth:null;return o&&"number"==typeof o.y&&"number"==typeof o.x||(r=e&&"ownerDocument"in e?e.ownerDocument:document,i=n?r.createElement("div"):t,n&&(i.setAttribute("style","position:fixed;top:0;left:0;opacity:0;pointer-events:none;width:200px;height:200px;overflow:scroll"),r.body.appendChild(i)),o={y:i.offsetWidth-i.clientWidth,x:i.offsetHeight-i.clientHeight},n&&(window.nativeScrollbarWidth=o,r.body.removeChild(i))),o}catch(e){return{y:17,x:17}}},e.getRect=w,e.getScrollParent=g,e.getViewElementsWhenScroll=function(r,i,o){if(0<i.length){var l=[],e=function(e){var n=w(r),t=i.map(w).map(function(e,t){return e.viewHeight=Math.max(0,Math.min(e.top+e.height,n.top+n.height)-Math.max(n.top,e.top)),e.viewWidth=Math.max(0,Math.min(e.left+e.width,n.left+n.width)-Math.max(n.left,e.left)),e.height&&e.width?e.viewPercent=e.viewHeight*e.viewWidth/e.height*e.width:e.height||e.width?e.height?e.viewPercent=e.viewHeight/e.height:e.viewPercent=e.viewWidth/e.width:e.viewPercent=0,{rect:e,element:i[t]}}).filter(function(e){return 0<e.rect.viewPercent}).sort(function(e,t){var n=t.rect.viewPercent-e.rect.viewPercent;return n||t.rect.viewHeight*t.rect.viewWidth-e.rect.viewHeight*e.rect.viewWidth});t.length===l.length&&!t.some(function(e,t){return e.element!==l[t].element})||o(l=t,n,e)};return e(),r.addEventListener("scroll",e),function(){return r.removeEventListener("scroll",e)}}return function(){}},e.isElementInView=function(e,t){if(!e||!t)return!1;var n=e.getBoundingClientRect(),e=t.getBoundingClientRect(),t={x:0,y:0,width:window.innerWidth,height:window.innerHeight};return e.x=Math.max(e.x,t.x),e.y=Math.max(e.y,t.y),e.width=Math.min(e.width,t.width),e.height=Math.min(e.height,t.height),!(n.x+n.width<=e.x)&&(!(n.x>=e.x+e.width)&&(!(n.y+n.height<e.y)&&n.y<e.y+e.height))},e.posRelativeToClient=function(e){return{clientLeft:(e=w(e)).left,clientTop:e.top}},e.posRelativeToPage=function(e){for(var t={pageLeft:0,pageTop:0},n=e;n;)t.pageLeft+=n.offsetLeft,t.pageTop+=n.offsetTop,n=n.offsetParent;return t},e.scrollToElement=function e(t,n){var r=n||{},i=r.offset,o=void 0===i?0:i,n=r.time,l=void 0===n?300:n,f=s(r,["offset","time"]),i="number"==typeof o?{left:o,top:o}:{left:o.left||0,top:o.top||0},c=g(t);if(c&&(!f.topDisabled||!f.leftDisabled)){var n=function(){return e(c,p({time:l},f))},r=m(c),a=c.scrollLeft,u=c.scrollTop,o=w(t),t=w(c);"HTML"===c.nodeName&&(t.y=0);var h=Math.min(o.left-t.left+i.left,r.left-c.scrollLeft),d=Math.min(o.top-t.top+i.top,r.top-c.scrollTop);if(h&&!f.leftDisabled||d&&!f.topDisabled)return v(l,function(e){f.topDisabled||(c.scrollTop=u+d*e),f.leftDisabled||(c.scrollLeft=a+h*e)},f.rateFactor).then(f.affectParent?n:null);if(f.affectParent)return n()}return Promise.resolve()},Object.defineProperty(e,"__esModule",{value:!0})});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).ScrollGet={})}(this,function(e){"use strict";function t(t,e){var n,r=Object.keys(t);return Object.getOwnPropertySymbols&&(n=Object.getOwnPropertySymbols(t),e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)),r}function p(r){for(var e=1;e<arguments.length;e++){var i=null!=arguments[e]?arguments[e]:{};e%2?t(Object(i),!0).forEach(function(e){var t,n;t=r,e=i[n=e],n in t?Object.defineProperty(t,n,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[n]=e}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(i)):t(Object(i)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(i,e))})}return r}function s(e,t){if(null==e)return{};var n,r=function(e,t){if(null==e)return{};for(var n,r={},i=Object.keys(e),o=0;o<i.length;o++)n=i[o],0<=t.indexOf(n)||(r[n]=e[n]);return r}(e,t);if(Object.getOwnPropertySymbols)for(var i=Object.getOwnPropertySymbols(e),o=0;o<i.length;o++)n=i[o],0<=t.indexOf(n)||Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n]);return r}function w(e){return e.getBoundingClientRect()}function n(e){return e+(1-e)*e}function v(r,i,e){function o(e){window.requestAnimationFrame(function(){e()&&o(e)})}var l=e||n;return new Promise(function(t){var n=Date.now();o(function(){var e=l(Math.min(1,(Date.now()-n)/r));return i(e),!(1<=e)||(t(),!1)})})}function m(e){var t=window.getComputedStyle(e),n={top:0,left:0};return"HTML"!==e.nodeName&&!["scroll","auto","overlay"].includes(t.overflowX)||(n.left=Math.max(0,e.scrollWidth-e.clientWidth)),"HTML"!==e.nodeName&&!["scroll","auto","overlay"].includes(t.overflowY)||(n.top=Math.max(0,e.scrollHeight-e.clientHeight)),n}function r(e){return!e.top&&!e.left}function g(e){if(null!=e&&e.style){var t=window.getComputedStyle(e);if("fixed"!==t.position){var n=e.ownerDocument;if("absolute"===t.position)return e.offsetParent?g(e.offsetParent):r(m(n.body))?g(n.body):n.body;e=e.parentElement;return e?r(m(e))&&e!==n.documentElement?g(e):e:void 0}}}e.animation=v,e.getMaxScrollOffset=m,e.getNativeScrollbarWidth=function(e){var t=e||window,n=t===window;try{var r,i,o=n?window.nativeScrollbarWidth:null;return o&&"number"==typeof o.y&&"number"==typeof o.x||(r=e&&"ownerDocument"in e?e.ownerDocument:document,i=n?r.createElement("div"):t,n&&(i.setAttribute("style","position:fixed;top:0;left:0;opacity:0;pointer-events:none;width:200px;height:200px;overflow:scroll"),r.body.appendChild(i)),o={y:i.offsetWidth-i.clientWidth,x:i.offsetHeight-i.clientHeight},n&&(window.nativeScrollbarWidth=o,r.body.removeChild(i))),o}catch(e){return{y:17,x:17}}},e.getRect=w,e.getScrollParent=g,e.getViewElementsWhenScroll=function(r,i,o){if(0<i.length){var l=[],e=function(e){var n=w(r),t=i.map(w).map(function(e,t){return e.viewHeight=Math.max(0,Math.min(e.top+e.height,n.top+n.height)-Math.max(n.top,e.top)),e.viewWidth=Math.max(0,Math.min(e.left+e.width,n.left+n.width)-Math.max(n.left,e.left)),e.height&&e.width?e.viewPercent=e.viewHeight*e.viewWidth/e.height*e.width:e.height||e.width?e.height?e.viewPercent=e.viewHeight/e.height:e.viewPercent=e.viewWidth/e.width:e.viewPercent=0,{rect:e,element:i[t]}}).filter(function(e){return 0<e.rect.viewPercent}).sort(function(e,t){var n=t.rect.viewPercent-e.rect.viewPercent;return n||t.rect.viewHeight*t.rect.viewWidth-e.rect.viewHeight*e.rect.viewWidth});t.length===l.length&&!t.some(function(e,t){return e.element!==l[t].element})||o(l=t,n,e)};return e(),r.addEventListener("scroll",e),function(){return r.removeEventListener("scroll",e)}}return function(){}},e.isElementInView=function(e,t){if(!e||!t)return!1;var n=e.getBoundingClientRect(),e="nodeType"in t?t.getBoundingClientRect():t,t={x:0,y:0,width:window.innerWidth,height:window.innerHeight};return e.x=Math.max(e.x,t.x),e.y=Math.max(e.y,t.y),e.width=Math.min(e.width,t.width),e.height=Math.min(e.height,t.height),!(n.x+n.width<=e.x)&&(!(n.x>=e.x+e.width)&&(!(n.y+n.height<e.y)&&n.y<e.y+e.height))},e.posRelativeToClient=function(e){return{clientLeft:(e=w(e)).left,clientTop:e.top}},e.posRelativeToPage=function(e){for(var t={pageLeft:0,pageTop:0},n=e;n;)t.pageLeft+=n.offsetLeft,t.pageTop+=n.offsetTop,n=n.offsetParent;return t},e.scrollToElement=function e(t,n){var r=n||{},i=r.offset,o=void 0===i?0:i,n=r.time,l=void 0===n?300:n,f=s(r,["offset","time"]),i="number"==typeof o?{left:o,top:o}:{left:o.left||0,top:o.top||0},c=g(t);if(c&&(!f.topDisabled||!f.leftDisabled)){var n=function(){return e(c,p({time:l},f))},r=m(c),a=c.scrollLeft,u=c.scrollTop,o=w(t),t=w(c);"HTML"===c.nodeName&&(t.y=0);var h=Math.min(o.left-t.left+i.left,r.left-c.scrollLeft),d=Math.min(o.top-t.top+i.top,r.top-c.scrollTop);if(h&&!f.leftDisabled||d&&!f.topDisabled)return v(l,function(e){f.topDisabled||(c.scrollTop=u+d*e),f.leftDisabled||(c.scrollLeft=a+h*e)},f.rateFactor).then(f.affectParent?n:null);if(f.affectParent)return n()}return Promise.resolve()},Object.defineProperty(e,"__esModule",{value:!0})});
{
"name": "@livelybone/scroll-get",
"version": "6.1.0",
"version": "6.1.1",
"description": "Some useful tool of browser scroll, such as tool for calculating position relative to page/client, tool for getting the native scrollbar width...",

@@ -5,0 +5,0 @@ "main": "./lib/umd/index.js",

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