@nil-/doc 0.2.21 → 0.2.22
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/CHANGELOG.md +6 -0
- package/components/etc/Container.svelte +21 -9
- package/components/etc/action.d.ts +2 -0
- package/components/etc/action.js +26 -19
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -18,7 +18,6 @@
|
|
|
18
18
|
width: 100%;
|
|
19
19
|
height: 100%;
|
|
20
20
|
overflow: hidden;
|
|
21
|
-
outline: rgb(100, 96, 96) solid 1px;
|
|
22
21
|
}
|
|
23
22
|
|
|
24
23
|
/* need higher specificity than above */
|
|
@@ -29,6 +28,11 @@
|
|
|
29
28
|
overflow: visible;
|
|
30
29
|
user-select: none;
|
|
31
30
|
grid-area: divider;
|
|
31
|
+
outline: rgb(100, 96, 96) solid 1px;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.container > .divider.moving {
|
|
35
|
+
outline: rgb(255, 255, 255) solid 1px;
|
|
32
36
|
}
|
|
33
37
|
|
|
34
38
|
.container > .divider.vertical {
|
|
@@ -38,20 +42,22 @@
|
|
|
38
42
|
|
|
39
43
|
.container > .divider > .overlay {
|
|
40
44
|
width: 100%;
|
|
41
|
-
height:
|
|
45
|
+
height: 20px;
|
|
42
46
|
cursor: row-resize;
|
|
43
|
-
|
|
47
|
+
transform: translateY(-50%);
|
|
48
|
+
touch-action: none;
|
|
44
49
|
}
|
|
45
50
|
|
|
46
51
|
.container > .divider.vertical > .overlay {
|
|
47
|
-
width:
|
|
52
|
+
width: 20px;
|
|
48
53
|
height: 100%;
|
|
49
54
|
cursor: col-resize;
|
|
50
|
-
|
|
55
|
+
transform: translateX(-50%);
|
|
51
56
|
}
|
|
52
57
|
</style>
|
|
53
58
|
|
|
54
|
-
<script>import {
|
|
59
|
+
<script>import { writable } from "svelte/store";
|
|
60
|
+
import { createDraggable } from "./action";
|
|
55
61
|
// orientation of the layout
|
|
56
62
|
export let vertical = false;
|
|
57
63
|
// initial value where the divider is located
|
|
@@ -75,6 +81,7 @@ function update(w, h, limit, value) {
|
|
|
75
81
|
$: update(width, height, padding, $position);
|
|
76
82
|
$: offsetpx = collapse ? "10px" : `${offset}px`;
|
|
77
83
|
$: style = !secondary ? `auto 0px ${offsetpx}` : `${offsetpx} 0px auto`;
|
|
84
|
+
const moving = writable(false);
|
|
78
85
|
</script>
|
|
79
86
|
<div
|
|
80
87
|
class="container"
|
|
@@ -90,11 +97,16 @@ $: style = !secondary ? `auto 0px ${offsetpx}` : `${offsetpx} 0px auto`;
|
|
|
90
97
|
<slot name="primary" />
|
|
91
98
|
{/if}
|
|
92
99
|
</div>
|
|
93
|
-
<div class="divider" class:vertical>
|
|
100
|
+
<div class="divider" class:vertical class:moving={$moving}>
|
|
94
101
|
<div
|
|
95
102
|
class="overlay"
|
|
96
|
-
use:draggable={{
|
|
97
|
-
|
|
103
|
+
use:draggable={{
|
|
104
|
+
reset: () => offset,
|
|
105
|
+
reversed: !secondary,
|
|
106
|
+
vertical,
|
|
107
|
+
dbltap: () => (collapse = !collapse),
|
|
108
|
+
moving
|
|
109
|
+
}}
|
|
98
110
|
/>
|
|
99
111
|
</div>
|
|
100
112
|
<div style:grid-area="secondary">
|
package/components/etc/action.js
CHANGED
|
@@ -1,43 +1,50 @@
|
|
|
1
|
-
import { writable } from "svelte/store";
|
|
1
|
+
import { get, writable } from "svelte/store";
|
|
2
2
|
export const createDraggable = (offset) => {
|
|
3
3
|
const position = writable(offset);
|
|
4
4
|
function draggable(div, parameter) {
|
|
5
|
+
let tm = new Date().getTime();
|
|
5
6
|
let param = parameter ?? { reset: () => 0, vertical: true, reversed: false };
|
|
6
|
-
let moving = false;
|
|
7
7
|
position.set(param.reset());
|
|
8
8
|
let current_page = 0;
|
|
9
|
+
function disengage() {
|
|
10
|
+
param.moving.set(false);
|
|
11
|
+
}
|
|
12
|
+
function checkDoubleTap() {
|
|
13
|
+
const tm2 = new Date().getTime();
|
|
14
|
+
const diff = tm2 - tm;
|
|
15
|
+
tm = tm2;
|
|
16
|
+
return diff < 200;
|
|
17
|
+
}
|
|
9
18
|
function engage(e) {
|
|
10
|
-
|
|
19
|
+
if (checkDoubleTap()) {
|
|
20
|
+
param?.dbltap?.();
|
|
21
|
+
disengage();
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
param.moving.set(true);
|
|
11
25
|
position.set(param.reset());
|
|
12
26
|
current_page = param.vertical ? e.pageX : e.pageY;
|
|
13
27
|
}
|
|
14
|
-
function disengage() {
|
|
15
|
-
moving = false;
|
|
16
|
-
}
|
|
17
28
|
function move(e) {
|
|
18
|
-
if (moving) {
|
|
29
|
+
if (get(param.moving)) {
|
|
19
30
|
const page = param.vertical ? e.pageX : e.pageY;
|
|
20
31
|
position.update((v) => v + (page - current_page) * (param.reversed ? -1 : 1));
|
|
21
32
|
current_page = page;
|
|
22
33
|
}
|
|
23
34
|
}
|
|
24
|
-
div.addEventListener("
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
35
|
+
div.addEventListener("pointerdown", engage);
|
|
36
|
+
window.addEventListener("pointerup", disengage);
|
|
37
|
+
window.addEventListener("pointercancel", disengage);
|
|
38
|
+
window.addEventListener("pointermove", move);
|
|
28
39
|
return {
|
|
29
40
|
update: (parameter) => {
|
|
30
|
-
if (param.reversed !== parameter.reversed ||
|
|
31
|
-
param.vertical !== parameter.vertical) {
|
|
32
|
-
moving = false;
|
|
33
|
-
}
|
|
34
41
|
param = parameter;
|
|
35
42
|
},
|
|
36
43
|
destroy: () => {
|
|
37
|
-
div.removeEventListener("
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
44
|
+
div.removeEventListener("pointerdown", engage);
|
|
45
|
+
window.removeEventListener("pointerup", disengage);
|
|
46
|
+
window.removeEventListener("pointercancel", disengage);
|
|
47
|
+
window.removeEventListener("pointermove", move);
|
|
41
48
|
}
|
|
42
49
|
};
|
|
43
50
|
}
|