@nil-/xit 0.1.27 → 0.1.29
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/assets/bundler.js +257 -91
- package/assets/index.js +1954 -1930
- package/assets/svelte/index.js +1617 -1356
- package/assets/svelte/internal/client.js +1329 -1195
- package/assets/svelte/motion.js +399 -133
- package/assets/svelte/store.js +99 -93
- package/components/layouts/Container.svelte +24 -0
- package/components/layouts/Container.svelte.d.ts +7 -0
- package/components/layouts/Scrollable.svelte +22 -0
- package/components/layouts/Scrollable.svelte.d.ts +5 -0
- package/components/layouts/Split.svelte +114 -0
- package/components/layouts/Split.svelte.d.ts +19 -0
- package/components/utilities/DividerOverlay.svelte +78 -0
- package/components/utilities/DividerOverlay.svelte.d.ts +8 -0
- package/components/utilities/draggable.d.ts +17 -0
- package/components/utilities/draggable.js +67 -0
- package/index.d.ts +2 -2
- package/package.json +24 -1
package/assets/svelte/store.js
CHANGED
|
@@ -1,78 +1,75 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { n as l, u as h, s as z, r as j, a as A, e as m, g as O, b as S, t as B, c as C, d as E } from "./index.js";
|
|
2
2
|
import "./internal/client.js";
|
|
3
|
-
function
|
|
4
|
-
q(e, e.v + 1);
|
|
5
|
-
}
|
|
6
|
-
function m(e, t, n) {
|
|
3
|
+
function v(e, r, t) {
|
|
7
4
|
if (e == null)
|
|
8
|
-
return
|
|
9
|
-
const
|
|
5
|
+
return r(void 0), t && t(void 0), l;
|
|
6
|
+
const n = h(
|
|
10
7
|
() => e.subscribe(
|
|
11
|
-
|
|
8
|
+
r,
|
|
12
9
|
// @ts-expect-error
|
|
13
|
-
|
|
10
|
+
t
|
|
14
11
|
)
|
|
15
12
|
);
|
|
16
|
-
return
|
|
13
|
+
return n.unsubscribe ? () => n.unsubscribe() : n;
|
|
17
14
|
}
|
|
18
|
-
const
|
|
19
|
-
function
|
|
15
|
+
const a = [];
|
|
16
|
+
function w(e, r) {
|
|
20
17
|
return {
|
|
21
|
-
subscribe: g(e,
|
|
18
|
+
subscribe: g(e, r).subscribe
|
|
22
19
|
};
|
|
23
20
|
}
|
|
24
|
-
function g(e,
|
|
25
|
-
let
|
|
26
|
-
const
|
|
27
|
-
function
|
|
28
|
-
if (z(e, i) && (e = i,
|
|
29
|
-
const f = !
|
|
30
|
-
for (const
|
|
31
|
-
|
|
21
|
+
function g(e, r = l) {
|
|
22
|
+
let t = null;
|
|
23
|
+
const n = /* @__PURE__ */ new Set();
|
|
24
|
+
function s(i) {
|
|
25
|
+
if (z(e, i) && (e = i, t)) {
|
|
26
|
+
const f = !a.length;
|
|
27
|
+
for (const u of n)
|
|
28
|
+
u[1](), a.push(u, e);
|
|
32
29
|
if (f) {
|
|
33
|
-
for (let
|
|
34
|
-
|
|
35
|
-
|
|
30
|
+
for (let u = 0; u < a.length; u += 2)
|
|
31
|
+
a[u][0](a[u + 1]);
|
|
32
|
+
a.length = 0;
|
|
36
33
|
}
|
|
37
34
|
}
|
|
38
35
|
}
|
|
39
|
-
function
|
|
40
|
-
|
|
36
|
+
function c(i) {
|
|
37
|
+
s(i(
|
|
41
38
|
/** @type {T} */
|
|
42
39
|
e
|
|
43
40
|
));
|
|
44
41
|
}
|
|
45
|
-
function
|
|
46
|
-
const
|
|
47
|
-
return
|
|
42
|
+
function o(i, f = l) {
|
|
43
|
+
const u = [i, f];
|
|
44
|
+
return n.add(u), n.size === 1 && (t = r(s, c) || l), i(
|
|
48
45
|
/** @type {T} */
|
|
49
46
|
e
|
|
50
47
|
), () => {
|
|
51
|
-
|
|
48
|
+
n.delete(u), n.size === 0 && t && (t(), t = null);
|
|
52
49
|
};
|
|
53
50
|
}
|
|
54
|
-
return { set:
|
|
51
|
+
return { set: s, update: c, subscribe: o };
|
|
55
52
|
}
|
|
56
|
-
function
|
|
57
|
-
const
|
|
58
|
-
if (!
|
|
53
|
+
function M(e, r, t) {
|
|
54
|
+
const n = !Array.isArray(e), s = n ? [e] : e;
|
|
55
|
+
if (!s.every(Boolean))
|
|
59
56
|
throw new Error("derived() expects stores as input, got a falsy value");
|
|
60
|
-
const
|
|
61
|
-
return
|
|
57
|
+
const c = r.length < 2;
|
|
58
|
+
return w(t, (o, i) => {
|
|
62
59
|
let f = !1;
|
|
63
|
-
const
|
|
64
|
-
let d = 0, p =
|
|
60
|
+
const u = [];
|
|
61
|
+
let d = 0, p = l;
|
|
65
62
|
const y = () => {
|
|
66
63
|
if (d)
|
|
67
64
|
return;
|
|
68
65
|
p();
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
-
},
|
|
72
|
-
(
|
|
73
|
-
|
|
74
|
-
(
|
|
75
|
-
|
|
66
|
+
const b = r(n ? u[0] : u, o, i);
|
|
67
|
+
c ? o(b) : p = typeof b == "function" ? b : l;
|
|
68
|
+
}, q = s.map(
|
|
69
|
+
(b, _) => v(
|
|
70
|
+
b,
|
|
71
|
+
(x) => {
|
|
72
|
+
u[_] = x, d &= ~(1 << _), f && y();
|
|
76
73
|
},
|
|
77
74
|
() => {
|
|
78
75
|
d |= 1 << _;
|
|
@@ -80,83 +77,92 @@ function P(e, t, n) {
|
|
|
80
77
|
)
|
|
81
78
|
);
|
|
82
79
|
return f = !0, y(), function() {
|
|
83
|
-
j(
|
|
80
|
+
j(q), p(), f = !1;
|
|
84
81
|
};
|
|
85
82
|
});
|
|
86
83
|
}
|
|
87
|
-
function
|
|
84
|
+
function P(e) {
|
|
88
85
|
return {
|
|
89
86
|
// @ts-expect-error TODO i suspect the bind is unnecessary
|
|
90
87
|
subscribe: e.subscribe.bind(e)
|
|
91
88
|
};
|
|
92
89
|
}
|
|
93
|
-
function
|
|
94
|
-
let
|
|
95
|
-
return
|
|
90
|
+
function k(e) {
|
|
91
|
+
let r;
|
|
92
|
+
return v(e, (t) => r = t)(), r;
|
|
93
|
+
}
|
|
94
|
+
function T(e) {
|
|
95
|
+
A(e, e.v + 1);
|
|
96
|
+
}
|
|
97
|
+
function $(e) {
|
|
98
|
+
let r = 0, t = C(0), n;
|
|
99
|
+
return () => {
|
|
100
|
+
m() && (O(t), S(() => (r === 0 && (n = h(() => e(() => T(t)))), r += 1, () => {
|
|
101
|
+
B().then(() => {
|
|
102
|
+
r -= 1, r === 0 && (n == null || n(), n = void 0);
|
|
103
|
+
});
|
|
104
|
+
})));
|
|
105
|
+
};
|
|
96
106
|
}
|
|
97
|
-
function
|
|
98
|
-
let
|
|
99
|
-
const
|
|
100
|
-
let
|
|
101
|
-
const
|
|
102
|
-
|
|
107
|
+
function D(e, r) {
|
|
108
|
+
let t = e();
|
|
109
|
+
const n = g(t, (s) => {
|
|
110
|
+
let c = t !== e();
|
|
111
|
+
const o = E(() => {
|
|
112
|
+
S(() => {
|
|
103
113
|
const i = e();
|
|
104
|
-
|
|
114
|
+
c && s(i);
|
|
105
115
|
});
|
|
106
116
|
});
|
|
107
|
-
return
|
|
117
|
+
return c = !0, o;
|
|
108
118
|
});
|
|
109
|
-
return
|
|
110
|
-
set:
|
|
111
|
-
update: (
|
|
112
|
-
subscribe:
|
|
119
|
+
return r ? {
|
|
120
|
+
set: r,
|
|
121
|
+
update: (s) => r(s(e())),
|
|
122
|
+
subscribe: n.subscribe
|
|
113
123
|
} : {
|
|
114
|
-
subscribe:
|
|
124
|
+
subscribe: n.subscribe
|
|
115
125
|
};
|
|
116
126
|
}
|
|
117
|
-
function
|
|
118
|
-
let
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
C().then(() => {
|
|
129
|
-
r -= 1, r === 0 && u();
|
|
130
|
-
});
|
|
131
|
-
};
|
|
132
|
-
}), t) : w(e);
|
|
127
|
+
function F(e) {
|
|
128
|
+
let r;
|
|
129
|
+
const t = $((s) => {
|
|
130
|
+
let c = !1;
|
|
131
|
+
const o = e.subscribe((i) => {
|
|
132
|
+
r = i, c && s();
|
|
133
|
+
});
|
|
134
|
+
return c = !0, o;
|
|
135
|
+
});
|
|
136
|
+
function n() {
|
|
137
|
+
return m() ? (t(), r) : k(e);
|
|
133
138
|
}
|
|
134
139
|
return "set" in e ? {
|
|
135
140
|
get current() {
|
|
136
|
-
return
|
|
141
|
+
return n();
|
|
137
142
|
},
|
|
138
|
-
set current(
|
|
139
|
-
e.set(
|
|
143
|
+
set current(s) {
|
|
144
|
+
e.set(s);
|
|
140
145
|
}
|
|
141
146
|
} : {
|
|
142
147
|
get current() {
|
|
143
|
-
return
|
|
148
|
+
return n();
|
|
144
149
|
}
|
|
145
150
|
};
|
|
146
151
|
}
|
|
147
|
-
const
|
|
152
|
+
const I = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
148
153
|
__proto__: null,
|
|
149
|
-
derived:
|
|
150
|
-
fromStore:
|
|
151
|
-
get:
|
|
152
|
-
readable:
|
|
153
|
-
readonly:
|
|
154
|
-
toStore:
|
|
154
|
+
derived: M,
|
|
155
|
+
fromStore: F,
|
|
156
|
+
get: k,
|
|
157
|
+
readable: w,
|
|
158
|
+
readonly: P,
|
|
159
|
+
toStore: D,
|
|
155
160
|
writable: g
|
|
156
161
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
157
162
|
export {
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
163
|
+
$ as c,
|
|
164
|
+
k as g,
|
|
165
|
+
I as i,
|
|
166
|
+
v as s,
|
|
161
167
|
g as w
|
|
162
168
|
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
<script lang="ts">let { children } = $props();
|
|
2
|
+
</script>
|
|
3
|
+
|
|
4
|
+
{#if children}
|
|
5
|
+
<div class="container">
|
|
6
|
+
<div>
|
|
7
|
+
{@render children()}
|
|
8
|
+
</div>
|
|
9
|
+
</div>
|
|
10
|
+
{/if}
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
<style>
|
|
14
|
+
.container {
|
|
15
|
+
width: 100%;
|
|
16
|
+
height: 100%;
|
|
17
|
+
position: relative;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.container > div {
|
|
21
|
+
inset: 0;
|
|
22
|
+
position: absolute;
|
|
23
|
+
}
|
|
24
|
+
</style>
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
<script lang="ts">let { children } = $props();
|
|
2
|
+
</script>
|
|
3
|
+
|
|
4
|
+
<div>
|
|
5
|
+
{@render children()}
|
|
6
|
+
</div>
|
|
7
|
+
|
|
8
|
+
<style>
|
|
9
|
+
div {
|
|
10
|
+
width: 100%;
|
|
11
|
+
height: 100%;
|
|
12
|
+
overflow: scroll;
|
|
13
|
+
/* Firefox */
|
|
14
|
+
scrollbar-width: none;
|
|
15
|
+
/* IE and Edge */
|
|
16
|
+
-ms-overflow-style: none;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
div::-webkit-scrollbar {
|
|
20
|
+
display: none;
|
|
21
|
+
}
|
|
22
|
+
</style>
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
<script lang="ts">import Container from "./Container.svelte";
|
|
2
|
+
import DividerOverlay from "../utilities/DividerOverlay.svelte";
|
|
3
|
+
import {} from "svelte";
|
|
4
|
+
import { create } from "../utilities/draggable.js";
|
|
5
|
+
let {
|
|
6
|
+
min = 2,
|
|
7
|
+
side_a,
|
|
8
|
+
side_b,
|
|
9
|
+
divider,
|
|
10
|
+
offset = $bindable(0),
|
|
11
|
+
vertical = false,
|
|
12
|
+
alt = false
|
|
13
|
+
} = $props();
|
|
14
|
+
let active = $state(false);
|
|
15
|
+
let width = $state(offset + min + 1);
|
|
16
|
+
let height = $state(offset + min + 1);
|
|
17
|
+
let max = $derived((vertical ? width : height) - min - 1);
|
|
18
|
+
const clamped = $derived(Math.max(Math.min(offset, max), min));
|
|
19
|
+
let last = null;
|
|
20
|
+
const draggable = create({
|
|
21
|
+
reset: () => $state.snapshot(clamped),
|
|
22
|
+
move: (value) => {
|
|
23
|
+
offset = value;
|
|
24
|
+
},
|
|
25
|
+
move_start: () => {
|
|
26
|
+
active = true;
|
|
27
|
+
},
|
|
28
|
+
move_end: () => {
|
|
29
|
+
active = false;
|
|
30
|
+
},
|
|
31
|
+
dbltap: () => {
|
|
32
|
+
if (offset > min) {
|
|
33
|
+
last = offset;
|
|
34
|
+
offset = min;
|
|
35
|
+
} else if (last != null) {
|
|
36
|
+
offset = last;
|
|
37
|
+
last = null;
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
tap: () => {
|
|
41
|
+
if (offset > min) {
|
|
42
|
+
last = offset;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
</script>
|
|
47
|
+
|
|
48
|
+
<div
|
|
49
|
+
class="split"
|
|
50
|
+
class:vertical
|
|
51
|
+
class:alt
|
|
52
|
+
class:active
|
|
53
|
+
class:at_limit={clamped < min || clamped > max}
|
|
54
|
+
style:--nil-xit-split-value={`${clamped}px`}
|
|
55
|
+
bind:clientWidth={width}
|
|
56
|
+
bind:clientHeight={height}
|
|
57
|
+
>
|
|
58
|
+
<Container>{@render side_a()}</Container>
|
|
59
|
+
<div
|
|
60
|
+
class="splitter"
|
|
61
|
+
use:draggable={{ reversed: alt, vertical }}
|
|
62
|
+
>
|
|
63
|
+
{#if divider != null}
|
|
64
|
+
{@render divider({active, alt, vertical})}
|
|
65
|
+
{:else}
|
|
66
|
+
<DividerOverlay {alt} {vertical} {active}></DividerOverlay>
|
|
67
|
+
{/if}
|
|
68
|
+
</div>
|
|
69
|
+
<Container>{@render side_b()}</Container>
|
|
70
|
+
</div>
|
|
71
|
+
|
|
72
|
+
<style>
|
|
73
|
+
.split {
|
|
74
|
+
width: 100%;
|
|
75
|
+
height: 100%;
|
|
76
|
+
display: grid;
|
|
77
|
+
transition: 350ms;
|
|
78
|
+
grid-template-columns: none;
|
|
79
|
+
grid-template-rows: auto 1px var(--nil-xit-split-value);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.split.active {
|
|
83
|
+
transition: 50ms;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.split.at_limit {
|
|
87
|
+
transition: none;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.split.vertical {
|
|
91
|
+
grid-template-columns: auto 1px var(--nil-xit-split-value);
|
|
92
|
+
grid-template-rows: none
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.split.alt {
|
|
96
|
+
grid-template-columns: none;
|
|
97
|
+
grid-template-rows: var(--nil-xit-split-value) 1px auto;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.split.vertical.alt {
|
|
101
|
+
grid-template-columns: var(--nil-xit-split-value) 1px auto;
|
|
102
|
+
grid-template-rows: none
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.splitter {
|
|
106
|
+
touch-action: none;
|
|
107
|
+
z-index: 1;
|
|
108
|
+
cursor: ns-resize;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
.vertical > .splitter {
|
|
112
|
+
cursor: ew-resize;
|
|
113
|
+
}
|
|
114
|
+
</style>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type Snippet } from "svelte";
|
|
2
|
+
type Props = {
|
|
3
|
+
min?: number;
|
|
4
|
+
side_a: Snippet;
|
|
5
|
+
side_b: Snippet;
|
|
6
|
+
divider?: Snippet<[
|
|
7
|
+
{
|
|
8
|
+
active: boolean;
|
|
9
|
+
alt: boolean;
|
|
10
|
+
vertical: boolean;
|
|
11
|
+
}
|
|
12
|
+
]>;
|
|
13
|
+
offset?: number;
|
|
14
|
+
vertical?: boolean;
|
|
15
|
+
alt?: boolean;
|
|
16
|
+
};
|
|
17
|
+
declare const Split: import("svelte").Component<Props, {}, "offset">;
|
|
18
|
+
type Split = ReturnType<typeof Split>;
|
|
19
|
+
export default Split;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
<script lang="ts">let { vertical, alt, active } = $props();
|
|
2
|
+
const title = $derived(`Collapse ${vertical ? alt ? "left" : "right" : alt ? "top" : "bottom"}`);
|
|
3
|
+
</script>
|
|
4
|
+
|
|
5
|
+
<div
|
|
6
|
+
class="parent"
|
|
7
|
+
class:primary={!alt}
|
|
8
|
+
class:secondary={alt}
|
|
9
|
+
class:active
|
|
10
|
+
class:vertical
|
|
11
|
+
class:horizontal={!vertical}>
|
|
12
|
+
<div {title}></div>
|
|
13
|
+
</div>
|
|
14
|
+
|
|
15
|
+
<style>
|
|
16
|
+
.parent {
|
|
17
|
+
user-select: none;
|
|
18
|
+
width: 100%;
|
|
19
|
+
height: 100%;
|
|
20
|
+
transform: translateY(-1px);
|
|
21
|
+
|
|
22
|
+
transition:
|
|
23
|
+
border-color 350ms,
|
|
24
|
+
background-color 350ms;
|
|
25
|
+
background-color: hsl(0, 2%, 40%);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.parent.vertical {
|
|
29
|
+
transform: translateX(-1px);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.parent > div {
|
|
33
|
+
touch-action: none;
|
|
34
|
+
cursor: ns-resize;
|
|
35
|
+
width: 100%;
|
|
36
|
+
height: calc(100% + 20px);
|
|
37
|
+
transform: translateY(-10px);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.parent.vertical > div {
|
|
41
|
+
cursor: ew-resize;
|
|
42
|
+
height: 100%;
|
|
43
|
+
width: calc(100% + 20px);
|
|
44
|
+
transform: translateX(-10px);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/* borders */
|
|
48
|
+
|
|
49
|
+
.parent.horizontal {
|
|
50
|
+
border-bottom: hsl(0, 2%, 40%) solid 1px;
|
|
51
|
+
border-top: hsl(0, 2%, 40%) solid 1px;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.parent.vertical {
|
|
55
|
+
border-left: hsl(0, 2%, 40%) solid 1px;
|
|
56
|
+
border-right: hsl(0, 2%, 40%) solid 1px;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.parent.primary.horizontal:hover,
|
|
60
|
+
.parent.primary.horizontal.active {
|
|
61
|
+
border-bottom: hsl(0, 0%, 100%) solid 1px;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.parent.secondary.horizontal:hover,
|
|
65
|
+
.parent.secondary.horizontal.active {
|
|
66
|
+
border-top: hsl(0, 0%, 100%) solid 1px;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.parent.primary.vertical:hover,
|
|
70
|
+
.parent.primary.vertical.active {
|
|
71
|
+
border-right: hsl(0, 0%, 100%) solid 1px;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.parent.secondary.vertical:hover,
|
|
75
|
+
.parent.secondary.vertical.active {
|
|
76
|
+
border-left: hsl(0, 0%, 100%) solid 1px;
|
|
77
|
+
}
|
|
78
|
+
</style>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
type Parameter = {
|
|
2
|
+
vertical: boolean;
|
|
3
|
+
reversed: boolean;
|
|
4
|
+
};
|
|
5
|
+
type Options = {
|
|
6
|
+
reset?: () => number;
|
|
7
|
+
move?: (value: number) => void;
|
|
8
|
+
move_start?: () => void;
|
|
9
|
+
move_end?: () => void;
|
|
10
|
+
dbltap?: () => void;
|
|
11
|
+
tap?: () => void;
|
|
12
|
+
};
|
|
13
|
+
export declare const create: ({ move, move_start, move_end, reset, dbltap, tap }: Options) => (div: HTMLElement, param: Parameter) => {
|
|
14
|
+
update: (new_params: Parameter) => Parameter;
|
|
15
|
+
destroy: () => void;
|
|
16
|
+
};
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
export const create = ({ move, move_start, move_end, reset, dbltap, tap }) => {
|
|
2
|
+
return (div, param) => {
|
|
3
|
+
let tm = new Date().getTime();
|
|
4
|
+
let position = reset?.() ?? 0;
|
|
5
|
+
let refPage = 0;
|
|
6
|
+
let engaged = false;
|
|
7
|
+
let moving = false;
|
|
8
|
+
const is_double_tap = () => {
|
|
9
|
+
const tm2 = new Date().getTime();
|
|
10
|
+
const diff = tm2 - tm;
|
|
11
|
+
tm = tm2;
|
|
12
|
+
return diff < 200;
|
|
13
|
+
};
|
|
14
|
+
const pointer_move = (e) => {
|
|
15
|
+
if (!engaged) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
if (!moving) {
|
|
19
|
+
moving = true;
|
|
20
|
+
move_start?.();
|
|
21
|
+
}
|
|
22
|
+
const page = param.vertical ? e.pageX : e.pageY;
|
|
23
|
+
const delta = (page - refPage) * (param.reversed ? 1 : -1);
|
|
24
|
+
position = position + delta;
|
|
25
|
+
refPage = page;
|
|
26
|
+
move?.(position);
|
|
27
|
+
};
|
|
28
|
+
const disengage = () => {
|
|
29
|
+
if (!engaged) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
if (moving) {
|
|
33
|
+
moving = false;
|
|
34
|
+
move_end?.();
|
|
35
|
+
}
|
|
36
|
+
engaged = false;
|
|
37
|
+
};
|
|
38
|
+
const engage = (e) => {
|
|
39
|
+
if (engaged) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
engaged = true;
|
|
43
|
+
if (is_double_tap()) {
|
|
44
|
+
dbltap?.();
|
|
45
|
+
disengage();
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
position = reset?.() ?? 0;
|
|
49
|
+
refPage = param.vertical ? e.pageX : e.pageY;
|
|
50
|
+
tap?.();
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
div.addEventListener("pointerdown", engage);
|
|
54
|
+
window.addEventListener("pointerup", disengage);
|
|
55
|
+
window.addEventListener("pointercancel", disengage);
|
|
56
|
+
window.addEventListener("pointermove", pointer_move);
|
|
57
|
+
return {
|
|
58
|
+
update: (new_params) => param = new_params,
|
|
59
|
+
destroy: () => {
|
|
60
|
+
div.removeEventListener("pointerdown", engage);
|
|
61
|
+
window.removeEventListener("pointerup", disengage);
|
|
62
|
+
window.removeEventListener("pointercancel", disengage);
|
|
63
|
+
window.removeEventListener("pointermove", pointer_move);
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
};
|
package/index.d.ts
CHANGED
|
@@ -44,7 +44,7 @@ export type Context = {
|
|
|
44
44
|
tag: string | null;
|
|
45
45
|
};
|
|
46
46
|
export declare const json_string: {
|
|
47
|
-
encode: (o: any) => Uint8Array
|
|
48
|
-
decode: (o: Uint8Array) => any;
|
|
47
|
+
encode: (o: any) => Uint8Array<ArrayBufferLike>;
|
|
48
|
+
decode: (o: Uint8Array<ArrayBufferLike>) => any;
|
|
49
49
|
};
|
|
50
50
|
export declare const xit: () => Context;
|
package/package.json
CHANGED
|
@@ -1,12 +1,35 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nil-/xit",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.29",
|
|
4
|
+
"peerDependencies": {
|
|
5
|
+
"svelte": "^5.7.1"
|
|
6
|
+
},
|
|
4
7
|
"type": "module",
|
|
5
8
|
"exports": {
|
|
6
9
|
"./package.json": "./package.json",
|
|
7
10
|
".": {
|
|
8
11
|
"types": "./index.d.ts",
|
|
9
12
|
"default": "./index.js"
|
|
13
|
+
},
|
|
14
|
+
"./components/layouts/Container.svelte": {
|
|
15
|
+
"types": "./components/layouts/Container.svelte.d.ts",
|
|
16
|
+
"svelte": "./components/layouts/Container.svelte"
|
|
17
|
+
},
|
|
18
|
+
"./components/layouts/Scrollable.svelte": {
|
|
19
|
+
"types": "./components/layouts/Scrollable.svelte.d.ts",
|
|
20
|
+
"svelte": "./components/layouts/Scrollable.svelte"
|
|
21
|
+
},
|
|
22
|
+
"./components/layouts/Split.svelte": {
|
|
23
|
+
"types": "./components/layouts/Split.svelte.d.ts",
|
|
24
|
+
"svelte": "./components/layouts/Split.svelte"
|
|
25
|
+
},
|
|
26
|
+
"./components/utilities/DividerOverlay.svelte": {
|
|
27
|
+
"types": "./components/utilities/DividerOverlay.svelte.d.ts",
|
|
28
|
+
"svelte": "./components/utilities/DividerOverlay.svelte"
|
|
29
|
+
},
|
|
30
|
+
"./components/utilities/draggable.js": {
|
|
31
|
+
"types": "./components/utilities/draggable.d.ts",
|
|
32
|
+
"default": "./components/utilities/draggable.js"
|
|
10
33
|
}
|
|
11
34
|
}
|
|
12
35
|
}
|