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

@interactjs/auto-scroll

Package Overview
Dependencies
Maintainers
2
Versions
137
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@interactjs/auto-scroll - npm Package Compare versions

Comparing version 1.9.2 to 1.9.3

2

index.min.js

@@ -1,2 +0,2 @@

import*as t from"../utils/domUtils.min.js";import*as n from"../utils/is.min.js";import e from"../utils/raf.min.js";import{getStringOptionResult as o}from"../utils/rect.min.js";import{getWindow as i}from"../utils/window.min.js";const r={defaults:{enabled:!1,margin:60,container:null,speed:300},now:Date.now,interaction:null,i:0,x:0,y:0,isScrolling:!1,prevTime:0,margin:0,speed:0,start(t){r.isScrolling=!0,e.cancel(r.i),t.autoScroll=r,r.interaction=t,r.prevTime=r.now(),r.i=e.request(r.scroll)},stop(){r.isScrolling=!1,r.interaction&&(r.interaction.autoScroll=null),e.cancel(r.i)},scroll(){const{interaction:t}=r,{interactable:o,element:i}=t,l=t.prepared.name,c=o.options[l].autoScroll,a=getContainer(c.container,o,i),s=r.now(),u=(s-r.prevTime)/1e3,m=c.speed*u;if(m>=1){const e={x:r.x*m,y:r.y*m};if(e.x||e.y){const r=getScroll(a);n.window(a)?a.scrollBy(e.x,e.y):a&&(a.scrollLeft+=e.x,a.scrollTop+=e.y);const l=getScroll(a),c={x:l.x-r.x,y:l.y-r.y};(c.x||c.y)&&o.fire({type:"autoscroll",target:i,interactable:o,delta:c,interaction:t,container:a})}r.prevTime=s}r.isScrolling&&(e.cancel(r.i),r.i=e.request(r.scroll))},check(t,n){const e=t.options;return e[n].autoScroll&&e[n].autoScroll.enabled},onInteractionMove({interaction:e,pointer:o}){if(!e.interacting()||!r.check(e.interactable,e.prepared.name))return;if(e.simulation)return void(r.x=r.y=0);let i,l,c,a;const{interactable:s,element:u}=e,m=e.prepared.name,p=s.options[m].autoScroll,g=getContainer(p.container,s,u);if(n.window(g))a=o.clientX<r.margin,i=o.clientY<r.margin,l=o.clientX>g.innerWidth-r.margin,c=o.clientY>g.innerHeight-r.margin;else{const n=t.getElementClientRect(g);a=o.clientX<n.left+r.margin,i=o.clientY<n.top+r.margin,l=o.clientX>n.right-r.margin,c=o.clientY>n.bottom-r.margin}r.x=l?1:a?-1:0,r.y=c?1:i?-1:0,r.isScrolling||(r.margin=p.margin,r.speed=p.speed,r.start(e))}};export function getContainer(t,e,r){return(n.string(t)?o(t,e,r):t)||i(r)}export function getScroll(t){return n.window(t)&&(t=window.document.body),{x:t.scrollLeft,y:t.scrollTop}}export function getScrollSize(t){return n.window(t)&&(t=window.document.body),{x:t.scrollWidth,y:t.scrollHeight}}export function getScrollSizeDelta({interaction:t,element:n},e){const o=t&&t.interactable.options[t.prepared.name].autoScroll;if(!o||!o.enabled)return e(),{x:0,y:0};const i=getContainer(o.container,t.interactable,n),r=getScroll(i);e();const l=getScroll(i);return{x:l.x-r.x,y:l.y-r.y}}const l={id:"auto-scroll",install:function(t){const{defaults:n,actions:e}=t;t.autoScroll=r,r.now=()=>t.now(),e.phaselessTypes.autoscroll=!0,n.perAction.autoScroll=r.defaults},listeners:{"interactions:new":({interaction:t})=>{t.autoScroll=null},"interactions:destroy":({interaction:t})=>{t.autoScroll=null,r.stop(),r.interaction&&(r.interaction=null)},"interactions:stop":r.stop,"interactions:action-move":t=>r.onInteractionMove(t)}};export default l;
import*as t from"../utils/domUtils.min.js";import*as n from"../utils/is.min.js";import e from"../utils/raf.min.js";import{getStringOptionResult as o}from"../utils/rect.min.js";import{getWindow as i}from"../utils/window.min.js";const r={defaults:{enabled:!1,margin:60,container:null,speed:300},now:Date.now,interaction:null,i:0,x:0,y:0,isScrolling:!1,prevTime:0,margin:0,speed:0,start(t){r.isScrolling=!0,e.cancel(r.i),t.autoScroll=r,r.interaction=t,r.prevTime=r.now(),r.i=e.request(r.scroll)},stop(){r.isScrolling=!1,r.interaction&&(r.interaction.autoScroll=null),e.cancel(r.i)},scroll(){const{interaction:t}=r,{interactable:o,element:i}=t,l=t.prepared.name,c=o.options[l].autoScroll,a=getContainer(c.container,o,i),s=r.now(),u=(s-r.prevTime)/1e3,m=c.speed*u;if(m>=1){const e={x:r.x*m,y:r.y*m};if(e.x||e.y){const r=getScroll(a);n.window(a)?a.scrollBy(e.x,e.y):a&&(a.scrollLeft+=e.x,a.scrollTop+=e.y);const l=getScroll(a),c={x:l.x-r.x,y:l.y-r.y};(c.x||c.y)&&o.fire({type:"autoscroll",target:i,interactable:o,delta:c,interaction:t,container:a})}r.prevTime=s}r.isScrolling&&(e.cancel(r.i),r.i=e.request(r.scroll))},check(t,n){const e=t.options;return e[n].autoScroll&&e[n].autoScroll.enabled},onInteractionMove({interaction:e,pointer:o}){if(!e.interacting()||!r.check(e.interactable,e.prepared.name))return;if(e.simulation)return void(r.x=r.y=0);let i,l,c,a;const{interactable:s,element:u}=e,m=e.prepared.name,p=s.options[m].autoScroll,g=getContainer(p.container,s,u);if(n.window(g))a=o.clientX<r.margin,i=o.clientY<r.margin,l=o.clientX>g.innerWidth-r.margin,c=o.clientY>g.innerHeight-r.margin;else{const n=t.getElementClientRect(g);a=o.clientX<n.left+r.margin,i=o.clientY<n.top+r.margin,l=o.clientX>n.right-r.margin,c=o.clientY>n.bottom-r.margin}r.x=l?1:a?-1:0,r.y=c?1:i?-1:0,r.isScrolling||(r.margin=p.margin,r.speed=p.speed,r.start(e))}};export function getContainer(t,e,r){return(n.string(t)?o(t,e,r):t)||i(r)}export function getScroll(t){return n.window(t)&&(t=window.document.body),{x:t.scrollLeft,y:t.scrollTop}}export function getScrollSize(t){return n.window(t)&&(t=window.document.body),{x:t.scrollWidth,y:t.scrollHeight}}export function getScrollSizeDelta({interaction:t,element:n},e){const o=t&&t.interactable.options[t.prepared.name].autoScroll;if(!o||!o.enabled)return e(),{x:0,y:0};const i=getContainer(o.container,t.interactable,n),r=getScroll(i);e();const l=getScroll(i);return{x:l.x-r.x,y:l.y-r.y}}const l={id:"auto-scroll",install(t){const{defaults:n,actions:e}=t;t.autoScroll=r,r.now=()=>t.now(),e.phaselessTypes.autoscroll=!0,n.perAction.autoScroll=r.defaults},listeners:{"interactions:new"({interaction:t}){t.autoScroll=null},"interactions:destroy"({interaction:t}){t.autoScroll=null,r.stop(),r.interaction&&(r.interaction=null)},"interactions:stop":r.stop,"interactions:action-move"(t){return r.onInteractionMove(t)}}};export default l;
//# sourceMappingURL=index.min.js.map
{
"name": "@interactjs/auto-scroll",
"version": "1.9.2",
"version": "1.9.3",
"license": "MIT",
"peerDependencies": {
"@interactjs/utils": "1.9.2"
"@interactjs/utils": "1.9.3"
},
"devDependencies": {
"@interactjs/_dev": "1.9.2"
"@interactjs/_dev": "1.9.3"
},
"optionalDependencies": {
"@interactjs/interact": "1.9.2"
"@interactjs/interact": "1.9.3"
},

@@ -17,3 +17,3 @@ "publishConfig": {

},
"gitHead": "77b581be"
"gitHead": "2032dde4"
}

Sorry, the diff of this file is not supported yet

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