@rokkit/core 1.0.0-next.25 → 1.0.0-next.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/src/actions/pannable.js +11 -4
- package/src/mocks/index.js +7 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rokkit/core",
|
|
3
|
-
"version": "1.0.0-next.
|
|
3
|
+
"version": "1.0.0-next.26",
|
|
4
4
|
"description": "Core components, actions and stores for svelte apps.",
|
|
5
5
|
"author": "Jerry Thomas <me@jerrythomas.name>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"validators": "latest",
|
|
29
29
|
"vite": "^4.3.5",
|
|
30
30
|
"vitest": "~0.31.0",
|
|
31
|
-
"shared-config": "1.0.0-next.
|
|
31
|
+
"shared-config": "1.0.0-next.25"
|
|
32
32
|
},
|
|
33
33
|
"files": [
|
|
34
34
|
"src/**/*.js",
|
package/src/actions/pannable.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// pannable.js
|
|
1
2
|
/**
|
|
2
3
|
* Handle drag and move events
|
|
3
4
|
*
|
|
@@ -9,8 +10,8 @@ export function pannable(node) {
|
|
|
9
10
|
let y
|
|
10
11
|
|
|
11
12
|
function track(event, name, delta = {}) {
|
|
12
|
-
x = event.clientX
|
|
13
|
-
y = event.clientY
|
|
13
|
+
x = event.clientX || event.touches[0].clientX
|
|
14
|
+
y = event.clientY || event.touches[0].clientY
|
|
14
15
|
event.stopPropagation()
|
|
15
16
|
event.preventDefault()
|
|
16
17
|
node.dispatchEvent(
|
|
@@ -24,11 +25,13 @@ export function pannable(node) {
|
|
|
24
25
|
track(event, 'panstart')
|
|
25
26
|
window.addEventListener('mousemove', handleMousemove)
|
|
26
27
|
window.addEventListener('mouseup', handleMouseup)
|
|
28
|
+
window.addEventListener('touchmove', handleMousemove, { passive: false })
|
|
29
|
+
window.addEventListener('touchend', handleMouseup)
|
|
27
30
|
}
|
|
28
31
|
|
|
29
32
|
function handleMousemove(event) {
|
|
30
|
-
const dx = event.clientX - x
|
|
31
|
-
const dy = event.clientY - y
|
|
33
|
+
const dx = (event.clientX || event.touches[0].clientX) - x
|
|
34
|
+
const dy = (event.clientY || event.touches[0].clientY) - y
|
|
32
35
|
|
|
33
36
|
track(event, 'panmove', { dx, dy })
|
|
34
37
|
}
|
|
@@ -38,13 +41,17 @@ export function pannable(node) {
|
|
|
38
41
|
|
|
39
42
|
window.removeEventListener('mousemove', handleMousemove)
|
|
40
43
|
window.removeEventListener('mouseup', handleMouseup)
|
|
44
|
+
window.removeEventListener('touchmove', handleMousemove)
|
|
45
|
+
window.removeEventListener('touchend', handleMouseup)
|
|
41
46
|
}
|
|
42
47
|
|
|
43
48
|
node.addEventListener('mousedown', handleMousedown)
|
|
49
|
+
node.addEventListener('touchstart', handleMousedown, { passive: false })
|
|
44
50
|
|
|
45
51
|
return {
|
|
46
52
|
destroy() {
|
|
47
53
|
node.removeEventListener('mousedown', handleMousedown)
|
|
54
|
+
node.removeEventListener('touchstart', handleMousedown)
|
|
48
55
|
}
|
|
49
56
|
}
|
|
50
57
|
}
|
package/src/mocks/index.js
CHANGED