@interactjs/auto-scroll
Advanced tools
Comparing version 1.10.23 to 1.10.24
{ | ||
"name": "@interactjs/auto-scroll", | ||
"version": "1.10.23", | ||
"version": "1.10.24", | ||
"main": "index", | ||
@@ -13,6 +13,6 @@ "module": "index", | ||
"peerDependencies": { | ||
"@interactjs/utils": "1.10.23" | ||
"@interactjs/utils": "1.10.24" | ||
}, | ||
"optionalDependencies": { | ||
"@interactjs/interact": "1.10.23" | ||
"@interactjs/interact": "1.10.24" | ||
}, | ||
@@ -27,3 +27,3 @@ "publishConfig": { | ||
"license": "MIT", | ||
"gitHead": "9ba48631" | ||
"gitHead": "86c64a3f" | ||
} |
@@ -6,3 +6,2 @@ import * as domUtils from "../utils/domUtils.js"; | ||
import { getWindow } from "../utils/window.js"; | ||
function install(scope) { | ||
@@ -14,9 +13,6 @@ const { | ||
scope.autoScroll = autoScroll; | ||
autoScroll.now = () => scope.now(); | ||
actions.phaselessTypes.autoscroll = true; | ||
defaults.perAction.autoScroll = autoScroll.defaults; | ||
} | ||
const autoScroll = { | ||
@@ -35,2 +31,3 @@ defaults: { | ||
// the handle returned by window.setInterval | ||
// Direction each pulse is to scroll in | ||
@@ -43,3 +40,2 @@ x: 0, | ||
speed: 0, | ||
start(interaction) { | ||
@@ -53,13 +49,9 @@ autoScroll.isScrolling = true; | ||
}, | ||
stop() { | ||
autoScroll.isScrolling = false; | ||
if (autoScroll.interaction) { | ||
autoScroll.interaction.autoScroll = null; | ||
} | ||
raf.cancel(autoScroll.i); | ||
}, | ||
// scroll the window by the values in scroll.x/y | ||
@@ -77,8 +69,7 @@ scroll() { | ||
const container = getContainer(options.container, interactable, element); | ||
const now = autoScroll.now(); // change in time in seconds | ||
const dt = (now - autoScroll.prevTime) / 1000; // displacement | ||
const now = autoScroll.now(); | ||
// change in time in seconds | ||
const dt = (now - autoScroll.prevTime) / 1000; | ||
// displacement | ||
const s = options.speed * dt; | ||
if (s >= 1) { | ||
@@ -89,6 +80,4 @@ const scrollBy = { | ||
}; | ||
if (scrollBy.x || scrollBy.y) { | ||
const prevScroll = getScroll(container); | ||
if (is.window(container)) { | ||
@@ -100,3 +89,2 @@ container.scrollBy(scrollBy.x, scrollBy.y); | ||
} | ||
const curScroll = getScroll(container); | ||
@@ -107,3 +95,2 @@ const delta = { | ||
}; | ||
if (delta.x || delta.y) { | ||
@@ -120,6 +107,4 @@ interactable.fire({ | ||
} | ||
autoScroll.prevTime = now; | ||
} | ||
if (autoScroll.isScrolling) { | ||
@@ -130,10 +115,7 @@ raf.cancel(autoScroll.i); | ||
}, | ||
check(interactable, actionName) { | ||
var _options$actionName$a; | ||
const options = interactable.options; | ||
return (_options$actionName$a = options[actionName].autoScroll) == null ? void 0 : _options$actionName$a.enabled; | ||
}, | ||
onInteractionMove({ | ||
@@ -146,3 +128,2 @@ interaction, | ||
} | ||
if (interaction.simulation) { | ||
@@ -152,3 +133,2 @@ autoScroll.x = autoScroll.y = 0; | ||
} | ||
let top; | ||
@@ -165,3 +145,2 @@ let right; | ||
const container = getContainer(options.container, interactable, element); | ||
if (is.window(container)) { | ||
@@ -179,6 +158,4 @@ left = pointer.clientX < autoScroll.margin; | ||
} | ||
autoScroll.x = right ? 1 : left ? -1 : 0; | ||
autoScroll.y = bottom ? 1 : top ? -1 : 0; | ||
if (!autoScroll.isScrolling) { | ||
@@ -191,3 +168,2 @@ // set the autoScroll properties to those of the target | ||
} | ||
}; | ||
@@ -201,3 +177,2 @@ export function getContainer(value, interactable, element) { | ||
} | ||
return { | ||
@@ -212,3 +187,2 @@ x: container.scrollLeft, | ||
} | ||
return { | ||
@@ -224,3 +198,2 @@ x: container.scrollWidth, | ||
const scrollOptions = interaction && interaction.interactable.options[interaction.prepared.name].autoScroll; | ||
if (!scrollOptions || !scrollOptions.enabled) { | ||
@@ -233,3 +206,2 @@ func(); | ||
} | ||
const scrollContainer = getContainer(scrollOptions.container, interaction.interactable, element); | ||
@@ -258,3 +230,2 @@ const prevSize = getScroll(scrollContainer); | ||
autoScroll.stop(); | ||
if (autoScroll.interaction) { | ||
@@ -261,0 +232,0 @@ autoScroll.interaction = null; |
Sorry, the diff of this file is not supported yet
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
42560
300