@alulore/kumiko 0.20.1 → 0.20.2
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/dist/board/board-slots.js +2 -1
- package/dist/board/scrollbar-gutter.js +26 -2
- package/dist/motion/flip.js +33 -20
- package/package.json +1 -1
|
@@ -20,10 +20,11 @@ export function rootSlot(slot) {
|
|
|
20
20
|
attrs: (state) => ({ "data-rows": state.rows.length > 0 ? "" : undefined }),
|
|
21
21
|
on: { click: (event, { api }) => api.selection.clickAway(event) },
|
|
22
22
|
bind: (el, { store, api }) => {
|
|
23
|
+
/* First: a remembered gutter is written before motion's first read styles the board. */
|
|
24
|
+
const unbindGutter = bindScrollbarGutter(el);
|
|
23
25
|
const unbindMotion = bindBoardMotion(el, store);
|
|
24
26
|
const unbindPress = bindPressToDrop(store, api.transfer);
|
|
25
27
|
const unbindHome = bindRefusedHome(el, store, api);
|
|
26
|
-
const unbindGutter = bindScrollbarGutter(el);
|
|
27
28
|
const unbindCapture = api.capture.bind(el);
|
|
28
29
|
return () => {
|
|
29
30
|
unbindCapture();
|
|
@@ -5,6 +5,19 @@
|
|
|
5
5
|
* --kumiko-board-scrollbar-gutter, which they add above and below.
|
|
6
6
|
*/
|
|
7
7
|
const px = (value) => Number(value.replace("px", ""));
|
|
8
|
+
/*
|
|
9
|
+
* The last gutter measured in each page. The variable inherits, so setting it
|
|
10
|
+
* after the board has been styled restyles every card. A later board starts
|
|
11
|
+
* from it before it's styled, and measures in its first frame, writing only
|
|
12
|
+
* if its own gutter differs.
|
|
13
|
+
*/
|
|
14
|
+
const remembered = new WeakMap();
|
|
15
|
+
function write(root, value) {
|
|
16
|
+
remembered.set(root.ownerDocument, value);
|
|
17
|
+
if (root.style.getPropertyValue("--kumiko-board-scrollbar-gutter") !== value) {
|
|
18
|
+
root.style.setProperty("--kumiko-board-scrollbar-gutter", value);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
8
21
|
function measure(root) {
|
|
9
22
|
const cell = root.querySelector('[data-slot="board-cell"]:not([data-folded])');
|
|
10
23
|
if (!cell) {
|
|
@@ -13,15 +26,26 @@ function measure(root) {
|
|
|
13
26
|
const style = getComputedStyle(cell);
|
|
14
27
|
const borders = px(style.borderLeftWidth) + px(style.borderRightWidth);
|
|
15
28
|
const gutter = (cell.offsetWidth - cell.clientWidth - borders) / 2;
|
|
16
|
-
root
|
|
29
|
+
write(root, `${Math.max(0, gutter)}px`);
|
|
17
30
|
}
|
|
18
31
|
export function bindScrollbarGutter(root) {
|
|
19
32
|
const observer = new ResizeObserver(() => {
|
|
20
33
|
measure(root);
|
|
21
34
|
});
|
|
22
35
|
observer.observe(root);
|
|
23
|
-
|
|
36
|
+
const known = remembered.get(root.ownerDocument);
|
|
37
|
+
let first = 0;
|
|
38
|
+
if (known === undefined) {
|
|
39
|
+
measure(root);
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
root.style.setProperty("--kumiko-board-scrollbar-gutter", known);
|
|
43
|
+
first = requestAnimationFrame(() => {
|
|
44
|
+
measure(root);
|
|
45
|
+
});
|
|
46
|
+
}
|
|
24
47
|
return () => {
|
|
48
|
+
cancelAnimationFrame(first);
|
|
25
49
|
observer.disconnect();
|
|
26
50
|
};
|
|
27
51
|
}
|
package/dist/motion/flip.js
CHANGED
|
@@ -35,30 +35,36 @@ function parentOffset(el, moves) {
|
|
|
35
35
|
}
|
|
36
36
|
return undefined;
|
|
37
37
|
}
|
|
38
|
+
/*
|
|
39
|
+
* Each element's running slide, so cancelling it reads nothing. getAnimations()
|
|
40
|
+
* brings style up to date, and after a write that forces a recalc per element.
|
|
41
|
+
*/
|
|
42
|
+
const slides = new WeakMap();
|
|
38
43
|
function cancelFlip(el) {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
animation.cancel();
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
+
slides.get(el)?.cancel();
|
|
45
|
+
slides.delete(el);
|
|
44
46
|
}
|
|
45
|
-
function
|
|
46
|
-
|
|
47
|
-
if (duration === 0 || isStill(offset)) {
|
|
47
|
+
function slide({ el, offset, motion }) {
|
|
48
|
+
if (motion.duration === 0 || isStill(offset)) {
|
|
48
49
|
return;
|
|
49
50
|
}
|
|
50
51
|
cancelFlip(el);
|
|
51
52
|
const keyframes = [{ translate: `${offset.x}px ${offset.y}px` }, { translate: "0 0" }];
|
|
52
|
-
el.animate(keyframes, {
|
|
53
|
+
slides.set(el, el.animate(keyframes, { ...motion, id: FLIP_ID }));
|
|
53
54
|
}
|
|
54
|
-
function
|
|
55
|
+
function readFade(el) {
|
|
55
56
|
const style = getComputedStyle(el);
|
|
56
|
-
|
|
57
|
+
return {
|
|
58
|
+
el,
|
|
59
|
+
duration: parseDuration(style.getPropertyValue("--kumiko-fade-duration")),
|
|
60
|
+
easing: style.getPropertyValue("--kumiko-enter-ease").trim() || "ease-out",
|
|
61
|
+
grows: parseDuration(style.getPropertyValue("--kumiko-move-duration")) > 0
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
function fadeIn({ el, duration, easing, grows }) {
|
|
57
65
|
if (duration === 0) {
|
|
58
66
|
return;
|
|
59
67
|
}
|
|
60
|
-
const easing = style.getPropertyValue("--kumiko-enter-ease").trim() || "ease-out";
|
|
61
|
-
const grows = parseDuration(style.getPropertyValue("--kumiko-move-duration")) > 0;
|
|
62
68
|
const keyframes = grows
|
|
63
69
|
? [
|
|
64
70
|
{ opacity: 0, scale: "0.96" },
|
|
@@ -103,10 +109,13 @@ function movesOf(elements, sources, options) {
|
|
|
103
109
|
}
|
|
104
110
|
return moves;
|
|
105
111
|
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
112
|
+
/* Reads every slide's timing before the first write, so style is brought up to date once. */
|
|
113
|
+
function slidesOf(moves) {
|
|
114
|
+
return [...moves].map(([el, move]) => ({
|
|
115
|
+
el,
|
|
116
|
+
offset: withoutParent(move.offset, parentOffset(el, moves)),
|
|
117
|
+
motion: readMotion(el, move.kind)
|
|
118
|
+
}));
|
|
110
119
|
}
|
|
111
120
|
/** Adds where items are now to `starts`, keeping each item's first start; a release point always wins. */
|
|
112
121
|
function measured(options, starts) {
|
|
@@ -154,9 +163,13 @@ export function createFlip(options) {
|
|
|
154
163
|
const fallback = structural ? before : null;
|
|
155
164
|
const origin = options.origin?.() ?? VIEWPORT;
|
|
156
165
|
const sources = { origin, from: usable, before: fallback, now: rested };
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
166
|
+
const planned = slidesOf(movesOf(elements, sources, options));
|
|
167
|
+
const fades = entering.map((el) => readFade(el));
|
|
168
|
+
for (const each of planned) {
|
|
169
|
+
slide(each);
|
|
170
|
+
}
|
|
171
|
+
for (const fade of fades) {
|
|
172
|
+
fadeIn(fade);
|
|
160
173
|
}
|
|
161
174
|
};
|
|
162
175
|
const rest = () => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alulore/kumiko",
|
|
3
|
-
"version": "0.20.
|
|
3
|
+
"version": "0.20.2",
|
|
4
4
|
"description": "Polished, cozy React components with gentle motion, built on ui-sdk. Every look and behaviour can be switched with props and CSS tokens.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|