@interactjs/auto-scroll
Advanced tools
Comparing version 1.10.26 to 1.10.27
/** | ||
* interact.js 1.10.26 | ||
* interact.js 1.10.27 | ||
* | ||
@@ -4,0 +4,0 @@ * Copyright (c) 2012-present Taye Adeyemi <dev@taye.me> |
@@ -1,4 +0,4 @@ | ||
/* interact.js 1.10.26 | https://raw.github.com/taye/interact.js/main/LICENSE */ | ||
/* interact.js 1.10.27 | https://raw.github.com/taye/interact.js/main/LICENSE */ | ||
import autoScrollPlugin from"./plugin.prod.js";import interact from"../interact/index.prod.js";import"../utils/domUtils.prod.js";import"../utils/is.prod.js";import"../utils/raf.prod.js";import"../utils/rect.prod.js";import"../utils/window.prod.js";interact.use(autoScrollPlugin); | ||
//# sourceMappingURL=index.prod.js.map |
{ | ||
"name": "@interactjs/auto-scroll", | ||
"version": "1.10.26", | ||
"version": "1.10.27", | ||
"main": "index", | ||
@@ -13,6 +13,6 @@ "module": "index", | ||
"peerDependencies": { | ||
"@interactjs/utils": "1.10.26" | ||
"@interactjs/utils": "1.10.27" | ||
}, | ||
"optionalDependencies": { | ||
"@interactjs/interact": "1.10.26" | ||
"@interactjs/interact": "1.10.27" | ||
}, | ||
@@ -27,3 +27,3 @@ "publishConfig": { | ||
"license": "MIT", | ||
"gitHead": "6e7a136f" | ||
"gitHead": "3ace1cad" | ||
} |
/** | ||
* interact.js 1.10.26 | ||
* interact.js 1.10.27 | ||
* | ||
@@ -4,0 +4,0 @@ * Copyright (c) 2012-present Taye Adeyemi <dev@taye.me> |
@@ -1,4 +0,4 @@ | ||
/* interact.js 1.10.26 | https://raw.github.com/taye/interact.js/main/LICENSE */ | ||
/* interact.js 1.10.27 | https://raw.github.com/taye/interact.js/main/LICENSE */ | ||
import*as domUtils from"../utils/domUtils.prod.js";import is from"../utils/is.prod.js";import raf from"../utils/raf.prod.js";import{getStringOptionResult}from"../utils/rect.prod.js";import{getWindow}from"../utils/window.prod.js";function install(o){const{defaults:t,actions:l}=o;o.autoScroll=autoScroll,autoScroll.now=()=>o.now(),l.phaselessTypes.autoscroll=!0,t.perAction.autoScroll=autoScroll.defaults}const autoScroll={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(o){autoScroll.isScrolling=!0,raf.cancel(autoScroll.i),o.autoScroll=autoScroll,autoScroll.interaction=o,autoScroll.prevTime=autoScroll.now(),autoScroll.i=raf.request(autoScroll.scroll)},stop(){autoScroll.isScrolling=!1,autoScroll.interaction&&(autoScroll.interaction.autoScroll=null),raf.cancel(autoScroll.i)},scroll(){const{interaction:o}=autoScroll,{interactable:t,element:l}=o,r=o.prepared.name,n=t.options[r].autoScroll,e=getContainer(n.container,t,l),i=autoScroll.now(),c=(i-autoScroll.prevTime)/1e3,a=n.speed*c;if(a>=1){const r={x:autoScroll.x*a,y:autoScroll.y*a};if(r.x||r.y){const n=getScroll(e);is.window(e)?e.scrollBy(r.x,r.y):e&&(e.scrollLeft+=r.x,e.scrollTop+=r.y);const i=getScroll(e),c={x:i.x-n.x,y:i.y-n.y};(c.x||c.y)&&t.fire({type:"autoscroll",target:l,interactable:t,delta:c,interaction:o,container:e})}autoScroll.prevTime=i}autoScroll.isScrolling&&(raf.cancel(autoScroll.i),autoScroll.i=raf.request(autoScroll.scroll))},check(o,t){var l;return null==(l=o.options[t].autoScroll)?void 0:l.enabled},onInteractionMove(o){let t,l,r,n,{interaction:e,pointer:i}=o;if(!e.interacting()||!autoScroll.check(e.interactable,e.prepared.name))return;if(e.simulation)return void(autoScroll.x=autoScroll.y=0);const{interactable:c,element:a}=e,u=e.prepared.name,s=c.options[u].autoScroll,S=getContainer(s.container,c,a);if(is.window(S))n=i.clientX<autoScroll.margin,t=i.clientY<autoScroll.margin,l=i.clientX>S.innerWidth-autoScroll.margin,r=i.clientY>S.innerHeight-autoScroll.margin;else{const o=domUtils.getElementClientRect(S);n=i.clientX<o.left+autoScroll.margin,t=i.clientY<o.top+autoScroll.margin,l=i.clientX>o.right-autoScroll.margin,r=i.clientY>o.bottom-autoScroll.margin}autoScroll.x=l?1:n?-1:0,autoScroll.y=r?1:t?-1:0,autoScroll.isScrolling||(autoScroll.margin=s.margin,autoScroll.speed=s.speed,autoScroll.start(e))}};function getContainer(o,t,l){return(is.string(o)?getStringOptionResult(o,t,l):o)||getWindow(l)}function getScroll(o){return is.window(o)&&(o=window.document.body),{x:o.scrollLeft,y:o.scrollTop}}function getScrollSize(o){return is.window(o)&&(o=window.document.body),{x:o.scrollWidth,y:o.scrollHeight}}function getScrollSizeDelta(o,t){let{interaction:l,element:r}=o;const n=l&&l.interactable.options[l.prepared.name].autoScroll;if(!n||!n.enabled)return t(),{x:0,y:0};const e=getContainer(n.container,l.interactable,r),i=getScroll(e);t();const c=getScroll(e);return{x:c.x-i.x,y:c.y-i.y}}const autoScrollPlugin={id:"auto-scroll",install:install,listeners:{"interactions:new"(o){let{interaction:t}=o;t.autoScroll=null},"interactions:destroy"(o){let{interaction:t}=o;t.autoScroll=null,autoScroll.stop(),autoScroll.interaction&&(autoScroll.interaction=null)},"interactions:stop":autoScroll.stop,"interactions:action-move"(o){return autoScroll.onInteractionMove(o)}}};export{autoScrollPlugin as default,getContainer,getScroll,getScrollSize,getScrollSizeDelta}; | ||
//# sourceMappingURL=plugin.prod.js.map |
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