@interactjs/auto-scroll
Advanced tools
Comparing version 1.10.1 to 1.10.2
{ | ||
"name": "@interactjs/auto-scroll", | ||
"version": "1.10.1", | ||
"version": "1.10.2", | ||
"license": "MIT", | ||
"peerDependencies": { | ||
"@interactjs/utils": "1.10.1" | ||
"@interactjs/utils": "1.10.2" | ||
}, | ||
"optionalDependencies": { | ||
"@interactjs/interact": "1.10.1" | ||
"@interactjs/interact": "1.10.2" | ||
}, | ||
@@ -11,0 +11,0 @@ "publishConfig": { |
@@ -0,1 +1,2 @@ | ||
import Interaction from "../core/Interaction.js"; | ||
import * as domUtils from "../utils/domUtils.js"; | ||
@@ -2,0 +3,0 @@ import is from "../utils/is.js"; |
@@ -1,2 +0,2 @@ | ||
import*as t from"../utils/domUtils.prod.js";import n from"../utils/is.prod.js";import e from"../utils/raf.prod.js";import{getStringOptionResult as o}from"../utils/rect.prod.js";import{getWindow as i}from"../utils/window.prod.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(),p=(s-r.prevTime)/1e3,u=c.speed*p;if(u>=1){const e={x:r.x*u,y:r.y*u};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){var e;return null==(e=t.options[n].autoScroll)?void 0:e.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:p}=e,u=e.prepared.name,d=s.options[u].autoScroll,m=getContainer(d.container,s,p);if(n.window(m))a=o.clientX<r.margin,i=o.clientY<r.margin,l=o.clientX>m.innerWidth-r.margin,c=o.clientY>m.innerHeight-r.margin;else{const n=t.getElementClientRect(m);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=d.margin,r.speed=d.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=>r.onInteractionMove(t)}};export default l; | ||
import t from"../core/Interaction.prod.js";import*as n from"../utils/domUtils.prod.js";import e from"../utils/is.prod.js";import o from"../utils/raf.prod.js";import{getStringOptionResult as r}from"../utils/rect.prod.js";import{getWindow as i}from"../utils/window.prod.js";const l={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){l.isScrolling=!0,o.cancel(l.i),t.autoScroll=l,l.interaction=t,l.prevTime=l.now(),l.i=o.request(l.scroll)},stop(){l.isScrolling=!1,l.interaction&&(l.interaction.autoScroll=null),o.cancel(l.i)},scroll(){const{interaction:t}=l,{interactable:n,element:r}=t,i=t.prepared.name,c=n.options[i].autoScroll,a=getContainer(c.container,n,r),s=l.now(),p=(s-l.prevTime)/1e3,u=c.speed*p;if(u>=1){const o={x:l.x*u,y:l.y*u};if(o.x||o.y){const i=getScroll(a);e.window(a)?a.scrollBy(o.x,o.y):a&&(a.scrollLeft+=o.x,a.scrollTop+=o.y);const l=getScroll(a),c={x:l.x-i.x,y:l.y-i.y};(c.x||c.y)&&n.fire({type:"autoscroll",target:r,interactable:n,delta:c,interaction:t,container:a})}l.prevTime=s}l.isScrolling&&(o.cancel(l.i),l.i=o.request(l.scroll))},check(t,n){var e;return null==(e=t.options[n].autoScroll)?void 0:e.enabled},onInteractionMove({interaction:t,pointer:o}){if(!t.interacting()||!l.check(t.interactable,t.prepared.name))return;if(t.simulation)return void(l.x=l.y=0);let r,i,c,a;const{interactable:s,element:p}=t,u=t.prepared.name,m=s.options[u].autoScroll,d=getContainer(m.container,s,p);if(e.window(d))a=o.clientX<l.margin,r=o.clientY<l.margin,i=o.clientX>d.innerWidth-l.margin,c=o.clientY>d.innerHeight-l.margin;else{const t=n.getElementClientRect(d);a=o.clientX<t.left+l.margin,r=o.clientY<t.top+l.margin,i=o.clientX>t.right-l.margin,c=o.clientY>t.bottom-l.margin}l.x=i?1:a?-1:0,l.y=c?1:r?-1:0,l.isScrolling||(l.margin=m.margin,l.speed=m.speed,l.start(t))}};export function getContainer(t,n,o){return(e.string(t)?r(t,n,o):t)||i(o)}export function getScroll(t){return e.window(t)&&(t=window.document.body),{x:t.scrollLeft,y:t.scrollTop}}export function getScrollSize(t){return e.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 r=getContainer(o.container,t.interactable,n),i=getScroll(r);e();const l=getScroll(r);return{x:l.x-i.x,y:l.y-i.y}}const c={id:"auto-scroll",install(t){const{defaults:n,actions:e}=t;t.autoScroll=l,l.now=()=>t.now(),e.phaselessTypes.autoscroll=!0,n.perAction.autoScroll=l.defaults},listeners:{"interactions:new"({interaction:t}){t.autoScroll=null},"interactions:destroy"({interaction:t}){t.autoScroll=null,l.stop(),l.interaction&&(l.interaction=null)},"interactions:stop":l.stop,"interactions:action-move":t=>l.onInteractionMove(t)}};export default c; | ||
//# sourceMappingURL=plugin.prod.js.map |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
41192
236