kuinetic 0.1.1 → 0.1.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/README.md +16 -9
- package/dist/esm/{chunk-R3TGDJKA.mjs → chunk-5EVG7CIY.mjs} +1 -1
- package/dist/esm/{chunk-QZIJ7WZI.mjs → chunk-WPU33HDL.mjs} +115 -28
- package/dist/esm/core/index.mjs +1 -1
- package/dist/esm/effects/index.mjs +1 -1
- package/dist/esm/index.mjs +2 -2
- package/dist/kuinetic.all.js +117 -30
- package/dist/kuinetic.css +80 -43
- package/dist/kuinetic.js +116 -29
- package/dist/types/effects/forms/primitives.d.ts +2 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -56,15 +56,22 @@ kuinetic({ observe: true }).start()
|
|
|
56
56
|
|
|
57
57
|
### CDN reference
|
|
58
58
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
| `kuinetic.
|
|
66
|
-
| `kuinetic.
|
|
67
|
-
|
|
59
|
+
Every file is mirrored on jsDelivr and unpkg — both update automatically from every npm release,
|
|
60
|
+
no separate action needed — and additionally self-hosted on Cloudflare at **`kuinetic.pages.dev`**:
|
|
61
|
+
|
|
62
|
+
| File | cdn.jsdelivr.net | unpkg.com | kuinetic.pages.dev |
|
|
63
|
+
|---|---|---|---|
|
|
64
|
+
| `kuinetic.js` | [`/npm/kuinetic`](https://cdn.jsdelivr.net/npm/kuinetic) † | [`/kuinetic`](https://unpkg.com/kuinetic) † | [`/kuinetic.js`](https://kuinetic.pages.dev/kuinetic.js) |
|
|
65
|
+
| `kuinetic.css` | [`/npm/kuinetic/dist/kuinetic.css`](https://cdn.jsdelivr.net/npm/kuinetic/dist/kuinetic.css) | [`/kuinetic/dist/kuinetic.css`](https://unpkg.com/kuinetic/dist/kuinetic.css) | [`/kuinetic.css`](https://kuinetic.pages.dev/kuinetic.css) |
|
|
66
|
+
| `kuinetic.all.js` | [`/npm/kuinetic/dist/kuinetic.all.js`](https://cdn.jsdelivr.net/npm/kuinetic/dist/kuinetic.all.js) | [`/kuinetic/dist/kuinetic.all.js`](https://unpkg.com/kuinetic/dist/kuinetic.all.js) | [`/kuinetic.all.js`](https://kuinetic.pages.dev/kuinetic.all.js) |
|
|
67
|
+
|
|
68
|
+
† shorthand — resolves via the `"jsdelivr"`/`"unpkg"` fields in `package.json`; only `kuinetic.js`
|
|
69
|
+
gets one, since a package can only designate a single default file that way.
|
|
70
|
+
|
|
71
|
+
`kuinetic.js` is the split bundle — side-effect-free on load, pair it with `kuinetic.css`, which
|
|
72
|
+
keeps working even if the JS is slow,
|
|
73
|
+
blocked, or fails to load. `kuinetic.all.js` is the one-tag drop-in — CSS embedded, auto-started
|
|
74
|
+
with `observe: true` — trading that CSS-independence guarantee for one less step.
|
|
68
75
|
|
|
69
76
|
## Your first animation
|
|
70
77
|
|
|
@@ -824,7 +824,7 @@ function timelineProperties(config, capabilities, useNativeTimeline) {
|
|
|
824
824
|
"animation-timeline": config.timeline === "scroll" ? "scroll()" : "view()"
|
|
825
825
|
};
|
|
826
826
|
if (capabilities.animationRange) {
|
|
827
|
-
properties["animation-range"] = config.range || "entry 0% cover 60%";
|
|
827
|
+
properties["animation-range"] = config.range || (config.timeline === "scroll" ? "0% 100%" : "entry 0% cover 60%");
|
|
828
828
|
}
|
|
829
829
|
return properties;
|
|
830
830
|
}
|
|
@@ -53,7 +53,8 @@ var float = {
|
|
|
53
53
|
};
|
|
54
54
|
var pulse = {
|
|
55
55
|
duration: { type: "time", default: "2.2s", cssProperty: "--kui-duration" },
|
|
56
|
-
ease: { type: "easing", default: "ease-in-out", cssProperty: "--kui-ease" }
|
|
56
|
+
ease: { type: "easing", default: "ease-in-out", cssProperty: "--kui-ease" },
|
|
57
|
+
scale: { type: "number", default: "1.15", cssProperty: "--kui-pulse-scale", finite: true, minimum: 1 }
|
|
57
58
|
};
|
|
58
59
|
var AMBIENT_PRIMITIVES = [
|
|
59
60
|
cssPrimitive("ambient-gradient", [CHANNEL.background], {
|
|
@@ -156,7 +157,8 @@ var spin = {
|
|
|
156
157
|
};
|
|
157
158
|
var dotPulse = {
|
|
158
159
|
duration: { type: "time", default: "1.2s", cssProperty: "--kui-duration" },
|
|
159
|
-
ease: { type: "easing", default: "ease-in-out", cssProperty: "--kui-ease" }
|
|
160
|
+
ease: { type: "easing", default: "ease-in-out", cssProperty: "--kui-ease" },
|
|
161
|
+
dotSize: { type: "length", default: "8px", cssProperty: "--kui-dot-size" }
|
|
160
162
|
};
|
|
161
163
|
var progressTrack = {
|
|
162
164
|
duration: { type: "time", default: "1.4s", cssProperty: "--kui-duration" },
|
|
@@ -173,7 +175,8 @@ var shake = {
|
|
|
173
175
|
};
|
|
174
176
|
var pop = {
|
|
175
177
|
duration: { type: "time", default: "420ms", cssProperty: "--kui-duration" },
|
|
176
|
-
ease: { type: "easing", default: "back-out", cssProperty: "--kui-ease" }
|
|
178
|
+
ease: { type: "easing", default: "back-out", cssProperty: "--kui-ease" },
|
|
179
|
+
scale: { type: "number", default: "1.18", cssProperty: "--kui-pop-scale", finite: true, minimum: 1 }
|
|
177
180
|
};
|
|
178
181
|
var ripple = {
|
|
179
182
|
duration: { type: "time", default: "600ms", cssProperty: "--kui-duration" },
|
|
@@ -184,6 +187,9 @@ var confirm = {
|
|
|
184
187
|
duration: { type: "time", default: "1400ms", cssProperty: "--kui-duration" },
|
|
185
188
|
ease: { type: "easing", default: "linear", cssProperty: "--kui-ease" }
|
|
186
189
|
};
|
|
190
|
+
var pull = {
|
|
191
|
+
distance: { type: "length", default: "36px", cssProperty: "--kui-pull-distance" }
|
|
192
|
+
};
|
|
187
193
|
var FEEDBACK_PRIMITIVES = [
|
|
188
194
|
cssPrimitive("feedback-shimmer", [CHANNEL.background], {
|
|
189
195
|
parameters: loop,
|
|
@@ -255,6 +261,7 @@ var FEEDBACK_PRIMITIVES = [
|
|
|
255
261
|
defaultActivation: "click"
|
|
256
262
|
}),
|
|
257
263
|
cssPrimitive("feedback-pull", [CHANNEL.translate], {
|
|
264
|
+
parameters: pull,
|
|
258
265
|
defaultActivation: "manual"
|
|
259
266
|
})
|
|
260
267
|
];
|
|
@@ -285,18 +292,23 @@ var FEEDBACK_PRESETS = [
|
|
|
285
292
|
},
|
|
286
293
|
{ name: "ripple", primitive: "feedback-ripple", keyframes: "kui-ripple" },
|
|
287
294
|
{ name: "badge-pop", primitive: "feedback-pop", keyframes: "kui-badge-pop" },
|
|
288
|
-
{
|
|
295
|
+
{
|
|
296
|
+
name: "count-bump",
|
|
297
|
+
primitive: "feedback-pop",
|
|
298
|
+
keyframes: "kui-count-bump",
|
|
299
|
+
params: { duration: "280ms", scale: "1.3" }
|
|
300
|
+
},
|
|
289
301
|
{
|
|
290
302
|
name: "heart-burst",
|
|
291
303
|
primitive: "feedback-burst",
|
|
292
304
|
keyframes: "kui-heart-burst",
|
|
293
|
-
params: { duration: "700ms" }
|
|
305
|
+
params: { duration: "700ms", scale: "1.4" }
|
|
294
306
|
},
|
|
295
307
|
{
|
|
296
308
|
name: "confetti-burst",
|
|
297
309
|
primitive: "feedback-burst",
|
|
298
310
|
keyframes: "kui-confetti-burst",
|
|
299
|
-
params: { duration: "900ms" }
|
|
311
|
+
params: { duration: "900ms", scale: "1.15" }
|
|
300
312
|
},
|
|
301
313
|
{ name: "copy-confirm", primitive: "feedback-confirm", keyframes: "kui-copy-confirm" },
|
|
302
314
|
{
|
|
@@ -441,12 +453,15 @@ var hoverTiming = {
|
|
|
441
453
|
duration: { type: "time", default: "220ms", cssProperty: "--kui-duration" },
|
|
442
454
|
ease: { type: "easing", default: "ease-out", cssProperty: "--kui-ease" }
|
|
443
455
|
};
|
|
444
|
-
|
|
456
|
+
var liftParams = {
|
|
457
|
+
distance: { type: "length", default: "6px", cssProperty: "--kui-lift-distance" }
|
|
458
|
+
};
|
|
459
|
+
function hoverPrimitive(id, channels, extraParams = {}) {
|
|
445
460
|
return {
|
|
446
461
|
id,
|
|
447
462
|
renderer: "javascript",
|
|
448
463
|
channels,
|
|
449
|
-
parameters: hoverTiming,
|
|
464
|
+
parameters: { ...hoverTiming, ...extraParams },
|
|
450
465
|
supportedTimelines: ["time"],
|
|
451
466
|
supportedActivations: ["load"],
|
|
452
467
|
defaultActivation: "load",
|
|
@@ -461,8 +476,8 @@ function hoverPrimitive(id, channels) {
|
|
|
461
476
|
};
|
|
462
477
|
}
|
|
463
478
|
var HOVER_PRIMITIVES = [
|
|
464
|
-
hoverPrimitive("lift", ["translate"]),
|
|
465
|
-
hoverPrimitive("lift-shadow", ["translate", "shadow"]),
|
|
479
|
+
hoverPrimitive("lift", ["translate"], liftParams),
|
|
480
|
+
hoverPrimitive("lift-shadow", ["translate", "shadow"], liftParams),
|
|
466
481
|
hoverPrimitive("shine-sweep", ["sweep"]),
|
|
467
482
|
hoverPrimitive("split-flap", ["rotate"]),
|
|
468
483
|
hoverPrimitive("border-draw", ["border"]),
|
|
@@ -511,6 +526,13 @@ var springParams = {
|
|
|
511
526
|
finite: true,
|
|
512
527
|
minimum: 0.1,
|
|
513
528
|
maximum: 1e3
|
|
529
|
+
},
|
|
530
|
+
mass: {
|
|
531
|
+
type: "number",
|
|
532
|
+
default: "1",
|
|
533
|
+
cssProperty: "--kui-mass",
|
|
534
|
+
finite: true,
|
|
535
|
+
minimum: 0.1
|
|
514
536
|
}
|
|
515
537
|
};
|
|
516
538
|
function pointerPrimitive(id, channels, parameters, prepare) {
|
|
@@ -534,7 +556,8 @@ function springFrom(params) {
|
|
|
534
556
|
return {
|
|
535
557
|
...DEFAULT_SPRING,
|
|
536
558
|
stiffness: params.num("stiffness", DEFAULT_SPRING.stiffness),
|
|
537
|
-
damping: params.num("damping", DEFAULT_SPRING.damping)
|
|
559
|
+
damping: params.num("damping", DEFAULT_SPRING.damping),
|
|
560
|
+
mass: params.num("mass", DEFAULT_SPRING.mass)
|
|
538
561
|
};
|
|
539
562
|
}
|
|
540
563
|
function springDepsFor(ctx) {
|
|
@@ -791,7 +814,7 @@ var MEDIA_PRIMITIVES = [
|
|
|
791
814
|
perfClass: "paint"
|
|
792
815
|
}),
|
|
793
816
|
cssPrimitive("media-blur-up", [CHANNEL.translate, CHANNEL.filter], {
|
|
794
|
-
parameters: geometry,
|
|
817
|
+
parameters: { ...geometry, blur: { type: "length", default: "16px", cssProperty: "--kui-blur" } },
|
|
795
818
|
perfClass: "paint"
|
|
796
819
|
}),
|
|
797
820
|
cssPrimitive("media-parallax-frame", [CHANNEL.translate], {
|
|
@@ -1354,11 +1377,18 @@ var fontWidthParams = {
|
|
|
1354
1377
|
};
|
|
1355
1378
|
var fontSlantParams = {
|
|
1356
1379
|
from: { type: "angle", default: "0deg", cssProperty: "--kui-from-slant" },
|
|
1357
|
-
to: { type: "angle", default: "
|
|
1380
|
+
to: { type: "angle", default: "10deg", cssProperty: "--kui-to-slant" }
|
|
1381
|
+
};
|
|
1382
|
+
var textSweepParams = {
|
|
1383
|
+
color: { type: "color", default: "currentColor", cssProperty: "--kui-sweep-color" }
|
|
1384
|
+
};
|
|
1385
|
+
var extrudeParams = {
|
|
1386
|
+
angle: { type: "angle", default: "-20deg", cssProperty: "--kui-from-angle" },
|
|
1387
|
+
distance: { type: "length", default: "32px", cssProperty: "--kui-distance" }
|
|
1358
1388
|
};
|
|
1359
1389
|
var TEXT_CSS_PRIMITIVES = [
|
|
1360
1390
|
cssPrimitive("text-shimmer", [CHANNEL.background], { reducedMotion: "disable" }),
|
|
1361
|
-
cssPrimitive("text-sweep", [CHANNEL.background]),
|
|
1391
|
+
cssPrimitive("text-sweep", [CHANNEL.background], { parameters: textSweepParams }),
|
|
1362
1392
|
cssPrimitive("text-outline-fill", [CHANNEL.stroke, CHANNEL.color]),
|
|
1363
1393
|
cssPrimitive("var-weight", ["font"], { parameters: fontWeightParams }),
|
|
1364
1394
|
cssPrimitive("var-width", ["font"], { parameters: fontWidthParams }),
|
|
@@ -1368,12 +1398,17 @@ var TEXT_CSS_PRIMITIVES = [
|
|
|
1368
1398
|
reducedMotion: "disable"
|
|
1369
1399
|
}),
|
|
1370
1400
|
cssPrimitive("redaction-reveal", [CHANNEL.clip]),
|
|
1371
|
-
cssPrimitive("text-3d-extrude", [CHANNEL.rotate, CHANNEL.translate])
|
|
1401
|
+
cssPrimitive("text-3d-extrude", [CHANNEL.rotate, CHANNEL.translate], { parameters: extrudeParams })
|
|
1372
1402
|
];
|
|
1373
1403
|
var TEXT_CSS_PRESETS = [
|
|
1374
1404
|
{ name: "gradient-shimmer", primitive: "text-shimmer", keyframes: "kui-gradient-shimmer" },
|
|
1375
1405
|
{ name: "gradient-sweep", primitive: "text-sweep", keyframes: "kui-gradient-sweep" },
|
|
1376
|
-
{
|
|
1406
|
+
{
|
|
1407
|
+
name: "highlight-sweep",
|
|
1408
|
+
primitive: "text-sweep",
|
|
1409
|
+
keyframes: "kui-highlight-sweep",
|
|
1410
|
+
params: { color: "gold" }
|
|
1411
|
+
},
|
|
1377
1412
|
{ name: "underline-draw", primitive: "text-sweep", keyframes: "kui-underline-draw" },
|
|
1378
1413
|
{ name: "text-outline-fill", primitive: "text-outline-fill", keyframes: "kui-text-outline-fill" },
|
|
1379
1414
|
{ name: "var-weight", primitive: "var-weight", keyframes: "kui-var-weight" },
|
|
@@ -1847,6 +1882,29 @@ var NATIVE_STATE_PRIMITIVE = {
|
|
|
1847
1882
|
reducedMotion: "disable",
|
|
1848
1883
|
prepare: () => inertInstance()
|
|
1849
1884
|
};
|
|
1885
|
+
function prepareSiblingScale(cssProperty) {
|
|
1886
|
+
return (el, params) => {
|
|
1887
|
+
const sibling = el.nextElementSibling;
|
|
1888
|
+
sibling?.style.setProperty(cssProperty, String(params.num("scale", 1)));
|
|
1889
|
+
return () => sibling?.style.removeProperty(cssProperty);
|
|
1890
|
+
};
|
|
1891
|
+
}
|
|
1892
|
+
function siblingScalePrimitive(id, cssProperty) {
|
|
1893
|
+
return {
|
|
1894
|
+
id,
|
|
1895
|
+
renderer: "javascript",
|
|
1896
|
+
channels: [CHANNEL.translate, CHANNEL.scale, CHANNEL.opacity, CHANNEL.stroke, CHANNEL.color],
|
|
1897
|
+
parameters: { scale: { type: "number", default: "1", cssProperty } },
|
|
1898
|
+
supportedTimelines: ["time"],
|
|
1899
|
+
supportedActivations: ["load"],
|
|
1900
|
+
defaultActivation: "load",
|
|
1901
|
+
perfClass: "compositor",
|
|
1902
|
+
reducedMotion: "disable",
|
|
1903
|
+
prepare: deferPrepare(prepareSiblingScale(cssProperty))
|
|
1904
|
+
};
|
|
1905
|
+
}
|
|
1906
|
+
var TOGGLE_MORPH_PRIMITIVE = siblingScalePrimitive("toggle-morph", "--kui-toggle-scale");
|
|
1907
|
+
var RADIO_FILL_PRIMITIVE = siblingScalePrimitive("radio-fill", "--kui-radio-scale");
|
|
1850
1908
|
var FOCUS_RING_PRIMITIVE = cssPrimitive("focus-ring", ["shadow"], {
|
|
1851
1909
|
activations: ["focus", "manual"],
|
|
1852
1910
|
defaultActivation: "focus"
|
|
@@ -1939,7 +1997,7 @@ function prepareStepProgress(el, params) {
|
|
|
1939
1997
|
var STEP_PROGRESS_PRIMITIVE = jsInputPrimitive(
|
|
1940
1998
|
"step-progress",
|
|
1941
1999
|
["state"],
|
|
1942
|
-
{ steps: { type: "number", default: "4", cssProperty: "--kui-steps", minimum: 1, integer: true } },
|
|
2000
|
+
{ steps: { type: "number", default: "4", cssProperty: "--kui-steps", minimum: 1, maximum: 20, integer: true } },
|
|
1943
2001
|
deferPrepare(prepareStepProgress)
|
|
1944
2002
|
);
|
|
1945
2003
|
function nextSubmitStage(stage) {
|
|
@@ -1993,6 +2051,8 @@ var FORMS_PRIMITIVES = [
|
|
|
1993
2051
|
VALIDATE_SHAKE_PRIMITIVE,
|
|
1994
2052
|
VALIDATE_CHECK_PRIMITIVE,
|
|
1995
2053
|
STRENGTH_METER_PRIMITIVE,
|
|
2054
|
+
TOGGLE_MORPH_PRIMITIVE,
|
|
2055
|
+
RADIO_FILL_PRIMITIVE,
|
|
1996
2056
|
RANGE_FILL_PRIMITIVE,
|
|
1997
2057
|
STEP_PROGRESS_PRIMITIVE,
|
|
1998
2058
|
SUBMIT_FLOW_PRIMITIVE
|
|
@@ -2004,9 +2064,9 @@ var FORMS_PRESETS = [
|
|
|
2004
2064
|
{ name: "validate-shake", primitive: "validate-shake", keyframes: "kui-validate-shake" },
|
|
2005
2065
|
{ name: "validate-check", primitive: "validate-check", keyframes: "kui-validate-check" },
|
|
2006
2066
|
{ name: "strength-meter", primitive: "strength-meter" },
|
|
2007
|
-
{ name: "toggle-morph", primitive: "
|
|
2067
|
+
{ name: "toggle-morph", primitive: "toggle-morph" },
|
|
2008
2068
|
{ name: "checkbox-draw", primitive: "native-state" },
|
|
2009
|
-
{ name: "radio-fill", primitive: "
|
|
2069
|
+
{ name: "radio-fill", primitive: "radio-fill" },
|
|
2010
2070
|
{ name: "range-fill", primitive: "range-fill" },
|
|
2011
2071
|
{ name: "submit-to-spinner-to-check", primitive: "submit-flow" },
|
|
2012
2072
|
{ name: "step-progress", primitive: "step-progress" }
|
|
@@ -2047,6 +2107,7 @@ function recognise(el, handlers, options = {}, deps = defaultGestureDeps()) {
|
|
|
2047
2107
|
let origin = null;
|
|
2048
2108
|
let active = false;
|
|
2049
2109
|
let longPressTimer = null;
|
|
2110
|
+
let longPressFired = false;
|
|
2050
2111
|
function sampleOf(event) {
|
|
2051
2112
|
return { x: event.clientX, y: event.clientY, time: deps.now() };
|
|
2052
2113
|
}
|
|
@@ -2063,9 +2124,13 @@ function recognise(el, handlers, options = {}, deps = defaultGestureDeps()) {
|
|
|
2063
2124
|
origin = sampleOf(event);
|
|
2064
2125
|
samples = [origin];
|
|
2065
2126
|
active = false;
|
|
2127
|
+
longPressFired = false;
|
|
2066
2128
|
el.setPointerCapture?.(event.pointerId);
|
|
2067
2129
|
if (longPressMs > 0) {
|
|
2068
|
-
longPressTimer = deps.setTimer(() =>
|
|
2130
|
+
longPressTimer = deps.setTimer(() => {
|
|
2131
|
+
longPressFired = true;
|
|
2132
|
+
handlers.onLongPress?.(origin);
|
|
2133
|
+
}, longPressMs);
|
|
2069
2134
|
}
|
|
2070
2135
|
}
|
|
2071
2136
|
function onMove(event) {
|
|
@@ -2093,9 +2158,12 @@ function recognise(el, handlers, options = {}, deps = defaultGestureDeps()) {
|
|
|
2093
2158
|
handlers.onEnd?.(vector, sample);
|
|
2094
2159
|
const direction = swipeDirection(vector, swipeVelocity);
|
|
2095
2160
|
if (direction) handlers.onSwipe?.(direction, vector);
|
|
2161
|
+
} else if (longPressFired) {
|
|
2162
|
+
handlers.onEnd?.(vector, sample);
|
|
2096
2163
|
}
|
|
2097
2164
|
origin = null;
|
|
2098
2165
|
active = false;
|
|
2166
|
+
longPressFired = false;
|
|
2099
2167
|
samples = [];
|
|
2100
2168
|
}
|
|
2101
2169
|
el.addEventListener("pointerdown", onDown);
|
|
@@ -2141,6 +2209,13 @@ var springParams2 = {
|
|
|
2141
2209
|
finite: true,
|
|
2142
2210
|
minimum: 0.1,
|
|
2143
2211
|
maximum: 1e3
|
|
2212
|
+
},
|
|
2213
|
+
mass: {
|
|
2214
|
+
type: "number",
|
|
2215
|
+
default: "1",
|
|
2216
|
+
cssProperty: "--kui-mass",
|
|
2217
|
+
finite: true,
|
|
2218
|
+
minimum: 0.1
|
|
2144
2219
|
}
|
|
2145
2220
|
};
|
|
2146
2221
|
function gesturePrimitive(id, channels, parameters, prepare) {
|
|
@@ -2161,7 +2236,8 @@ function springFrom2(params) {
|
|
|
2161
2236
|
return {
|
|
2162
2237
|
...DEFAULT_SPRING,
|
|
2163
2238
|
stiffness: params.num("stiffness", DEFAULT_SPRING.stiffness),
|
|
2164
|
-
damping: params.num("damping", DEFAULT_SPRING.damping)
|
|
2239
|
+
damping: params.num("damping", DEFAULT_SPRING.damping),
|
|
2240
|
+
mass: params.num("mass", DEFAULT_SPRING.mass)
|
|
2165
2241
|
};
|
|
2166
2242
|
}
|
|
2167
2243
|
function springDeps(ctx) {
|
|
@@ -2175,6 +2251,8 @@ function prepareDraggable(el, params, ctx) {
|
|
|
2175
2251
|
const bounds = params.num("bounds", 0);
|
|
2176
2252
|
const returns = params.is("return");
|
|
2177
2253
|
const inertia = params.is("inertia");
|
|
2254
|
+
const resistance = params.num("resistance", 0.55);
|
|
2255
|
+
const momentum = params.num("momentum", 0.2);
|
|
2178
2256
|
const offset = { x: 0, y: 0 };
|
|
2179
2257
|
const deps = springDeps(ctx);
|
|
2180
2258
|
const runners = {
|
|
@@ -2195,11 +2273,11 @@ function prepareDraggable(el, params, ctx) {
|
|
|
2195
2273
|
el.setAttribute("data-kui-dragging", "true");
|
|
2196
2274
|
},
|
|
2197
2275
|
onMove(vector) {
|
|
2198
|
-
write({ x: resist(vector.dx, bounds), y: resist(vector.dy, bounds) });
|
|
2276
|
+
write({ x: resist(vector.dx, bounds, resistance), y: resist(vector.dy, bounds, resistance) });
|
|
2199
2277
|
},
|
|
2200
2278
|
onEnd(vector) {
|
|
2201
2279
|
el.setAttribute("data-kui-dragging", "false");
|
|
2202
|
-
settle(runners, offset, vector, { returns, inertia });
|
|
2280
|
+
settle(runners, offset, vector, { returns, inertia, momentum });
|
|
2203
2281
|
}
|
|
2204
2282
|
},
|
|
2205
2283
|
{ axis: params.text("axis", "both") }
|
|
@@ -2212,8 +2290,8 @@ function prepareDraggable(el, params, ctx) {
|
|
|
2212
2290
|
el.removeAttribute("data-kui-dragging");
|
|
2213
2291
|
};
|
|
2214
2292
|
}
|
|
2215
|
-
function resist(delta, bounds) {
|
|
2216
|
-
return bounds > 0 ? rubberBand(delta, bounds) : delta;
|
|
2293
|
+
function resist(delta, bounds, tension) {
|
|
2294
|
+
return bounds > 0 ? rubberBand(delta, bounds, tension) : delta;
|
|
2217
2295
|
}
|
|
2218
2296
|
function settle(runners, offset, vector, mode) {
|
|
2219
2297
|
runners.x.set(offset.x, mode.inertia ? vector.vx : 0);
|
|
@@ -2223,8 +2301,8 @@ function settle(runners, offset, vector, mode) {
|
|
|
2223
2301
|
runners.y.to(0);
|
|
2224
2302
|
return;
|
|
2225
2303
|
}
|
|
2226
|
-
runners.x.to(offset.x + vector.vx *
|
|
2227
|
-
runners.y.to(offset.y + vector.vy *
|
|
2304
|
+
runners.x.to(offset.x + vector.vx * mode.momentum);
|
|
2305
|
+
runners.y.to(offset.y + vector.vy * mode.momentum);
|
|
2228
2306
|
}
|
|
2229
2307
|
function prepareSwipeable(el, params) {
|
|
2230
2308
|
const stop = recognise(
|
|
@@ -2311,7 +2389,16 @@ var GESTURE_PRIMITIVES = [
|
|
|
2311
2389
|
default: "false",
|
|
2312
2390
|
cssProperty: "--kui-inertia",
|
|
2313
2391
|
values: ["true", "false"]
|
|
2314
|
-
}
|
|
2392
|
+
},
|
|
2393
|
+
resistance: {
|
|
2394
|
+
type: "number",
|
|
2395
|
+
default: "0.55",
|
|
2396
|
+
cssProperty: "--kui-resistance",
|
|
2397
|
+
finite: true,
|
|
2398
|
+
minimum: 0,
|
|
2399
|
+
maximum: 1
|
|
2400
|
+
},
|
|
2401
|
+
momentum: { type: "number", default: "0.2", cssProperty: "--kui-momentum", finite: true }
|
|
2315
2402
|
},
|
|
2316
2403
|
deferPrepare(prepareDraggable)
|
|
2317
2404
|
),
|
package/dist/esm/core/index.mjs
CHANGED
package/dist/esm/index.mjs
CHANGED
|
@@ -10,13 +10,13 @@ import {
|
|
|
10
10
|
resolveTargets,
|
|
11
11
|
silentReporter,
|
|
12
12
|
toAttributeValue
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-5EVG7CIY.mjs";
|
|
14
14
|
import {
|
|
15
15
|
COMBOS,
|
|
16
16
|
PRESETS,
|
|
17
17
|
PRIMITIVES,
|
|
18
18
|
createRegistry
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-WPU33HDL.mjs";
|
|
20
20
|
import {
|
|
21
21
|
CHANNEL,
|
|
22
22
|
Registry,
|