kuinetic 0.1.0 → 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/dist/kuinetic.js CHANGED
@@ -1536,7 +1536,7 @@ var kuinetic = (() => {
1536
1536
  "animation-timeline": config.timeline === "scroll" ? "scroll()" : "view()"
1537
1537
  };
1538
1538
  if (capabilities.animationRange) {
1539
- properties["animation-range"] = config.range || "entry 0% cover 60%";
1539
+ properties["animation-range"] = config.range || (config.timeline === "scroll" ? "0% 100%" : "entry 0% cover 60%");
1540
1540
  }
1541
1541
  return properties;
1542
1542
  }
@@ -2028,7 +2028,8 @@ var kuinetic = (() => {
2028
2028
  };
2029
2029
  var pulse = {
2030
2030
  duration: { type: "time", default: "2.2s", cssProperty: "--kui-duration" },
2031
- ease: { type: "easing", default: "ease-in-out", cssProperty: "--kui-ease" }
2031
+ ease: { type: "easing", default: "ease-in-out", cssProperty: "--kui-ease" },
2032
+ scale: { type: "number", default: "1.15", cssProperty: "--kui-pulse-scale", finite: true, minimum: 1 }
2032
2033
  };
2033
2034
  var AMBIENT_PRIMITIVES = [
2034
2035
  cssPrimitive("ambient-gradient", [CHANNEL.background], {
@@ -2131,7 +2132,8 @@ var kuinetic = (() => {
2131
2132
  };
2132
2133
  var dotPulse = {
2133
2134
  duration: { type: "time", default: "1.2s", cssProperty: "--kui-duration" },
2134
- ease: { type: "easing", default: "ease-in-out", cssProperty: "--kui-ease" }
2135
+ ease: { type: "easing", default: "ease-in-out", cssProperty: "--kui-ease" },
2136
+ dotSize: { type: "length", default: "8px", cssProperty: "--kui-dot-size" }
2135
2137
  };
2136
2138
  var progressTrack = {
2137
2139
  duration: { type: "time", default: "1.4s", cssProperty: "--kui-duration" },
@@ -2148,7 +2150,8 @@ var kuinetic = (() => {
2148
2150
  };
2149
2151
  var pop = {
2150
2152
  duration: { type: "time", default: "420ms", cssProperty: "--kui-duration" },
2151
- ease: { type: "easing", default: "back-out", cssProperty: "--kui-ease" }
2153
+ ease: { type: "easing", default: "back-out", cssProperty: "--kui-ease" },
2154
+ scale: { type: "number", default: "1.18", cssProperty: "--kui-pop-scale", finite: true, minimum: 1 }
2152
2155
  };
2153
2156
  var ripple = {
2154
2157
  duration: { type: "time", default: "600ms", cssProperty: "--kui-duration" },
@@ -2159,6 +2162,9 @@ var kuinetic = (() => {
2159
2162
  duration: { type: "time", default: "1400ms", cssProperty: "--kui-duration" },
2160
2163
  ease: { type: "easing", default: "linear", cssProperty: "--kui-ease" }
2161
2164
  };
2165
+ var pull = {
2166
+ distance: { type: "length", default: "36px", cssProperty: "--kui-pull-distance" }
2167
+ };
2162
2168
  var FEEDBACK_PRIMITIVES = [
2163
2169
  cssPrimitive("feedback-shimmer", [CHANNEL.background], {
2164
2170
  parameters: loop,
@@ -2230,6 +2236,7 @@ var kuinetic = (() => {
2230
2236
  defaultActivation: "click"
2231
2237
  }),
2232
2238
  cssPrimitive("feedback-pull", [CHANNEL.translate], {
2239
+ parameters: pull,
2233
2240
  defaultActivation: "manual"
2234
2241
  })
2235
2242
  ];
@@ -2260,18 +2267,23 @@ var kuinetic = (() => {
2260
2267
  },
2261
2268
  { name: "ripple", primitive: "feedback-ripple", keyframes: "kui-ripple" },
2262
2269
  { name: "badge-pop", primitive: "feedback-pop", keyframes: "kui-badge-pop" },
2263
- { name: "count-bump", primitive: "feedback-pop", keyframes: "kui-count-bump", params: { duration: "280ms" } },
2270
+ {
2271
+ name: "count-bump",
2272
+ primitive: "feedback-pop",
2273
+ keyframes: "kui-count-bump",
2274
+ params: { duration: "280ms", scale: "1.3" }
2275
+ },
2264
2276
  {
2265
2277
  name: "heart-burst",
2266
2278
  primitive: "feedback-burst",
2267
2279
  keyframes: "kui-heart-burst",
2268
- params: { duration: "700ms" }
2280
+ params: { duration: "700ms", scale: "1.4" }
2269
2281
  },
2270
2282
  {
2271
2283
  name: "confetti-burst",
2272
2284
  primitive: "feedback-burst",
2273
2285
  keyframes: "kui-confetti-burst",
2274
- params: { duration: "900ms" }
2286
+ params: { duration: "900ms", scale: "1.15" }
2275
2287
  },
2276
2288
  { name: "copy-confirm", primitive: "feedback-confirm", keyframes: "kui-copy-confirm" },
2277
2289
  {
@@ -2416,12 +2428,15 @@ var kuinetic = (() => {
2416
2428
  duration: { type: "time", default: "220ms", cssProperty: "--kui-duration" },
2417
2429
  ease: { type: "easing", default: "ease-out", cssProperty: "--kui-ease" }
2418
2430
  };
2419
- function hoverPrimitive(id, channels) {
2431
+ var liftParams = {
2432
+ distance: { type: "length", default: "6px", cssProperty: "--kui-lift-distance" }
2433
+ };
2434
+ function hoverPrimitive(id, channels, extraParams = {}) {
2420
2435
  return {
2421
2436
  id,
2422
2437
  renderer: "javascript",
2423
2438
  channels,
2424
- parameters: hoverTiming,
2439
+ parameters: { ...hoverTiming, ...extraParams },
2425
2440
  supportedTimelines: ["time"],
2426
2441
  supportedActivations: ["load"],
2427
2442
  defaultActivation: "load",
@@ -2436,8 +2451,8 @@ var kuinetic = (() => {
2436
2451
  };
2437
2452
  }
2438
2453
  var HOVER_PRIMITIVES = [
2439
- hoverPrimitive("lift", ["translate"]),
2440
- hoverPrimitive("lift-shadow", ["translate", "shadow"]),
2454
+ hoverPrimitive("lift", ["translate"], liftParams),
2455
+ hoverPrimitive("lift-shadow", ["translate", "shadow"], liftParams),
2441
2456
  hoverPrimitive("shine-sweep", ["sweep"]),
2442
2457
  hoverPrimitive("split-flap", ["rotate"]),
2443
2458
  hoverPrimitive("border-draw", ["border"]),
@@ -2486,6 +2501,13 @@ var kuinetic = (() => {
2486
2501
  finite: true,
2487
2502
  minimum: 0.1,
2488
2503
  maximum: 1e3
2504
+ },
2505
+ mass: {
2506
+ type: "number",
2507
+ default: "1",
2508
+ cssProperty: "--kui-mass",
2509
+ finite: true,
2510
+ minimum: 0.1
2489
2511
  }
2490
2512
  };
2491
2513
  function pointerPrimitive(id, channels, parameters, prepare) {
@@ -2509,7 +2531,8 @@ var kuinetic = (() => {
2509
2531
  return {
2510
2532
  ...DEFAULT_SPRING,
2511
2533
  stiffness: params.num("stiffness", DEFAULT_SPRING.stiffness),
2512
- damping: params.num("damping", DEFAULT_SPRING.damping)
2534
+ damping: params.num("damping", DEFAULT_SPRING.damping),
2535
+ mass: params.num("mass", DEFAULT_SPRING.mass)
2513
2536
  };
2514
2537
  }
2515
2538
  function springDepsFor(ctx) {
@@ -2766,7 +2789,7 @@ var kuinetic = (() => {
2766
2789
  perfClass: "paint"
2767
2790
  }),
2768
2791
  cssPrimitive("media-blur-up", [CHANNEL.translate, CHANNEL.filter], {
2769
- parameters: geometry,
2792
+ parameters: { ...geometry, blur: { type: "length", default: "16px", cssProperty: "--kui-blur" } },
2770
2793
  perfClass: "paint"
2771
2794
  }),
2772
2795
  cssPrimitive("media-parallax-frame", [CHANNEL.translate], {
@@ -3329,11 +3352,18 @@ var kuinetic = (() => {
3329
3352
  };
3330
3353
  var fontSlantParams = {
3331
3354
  from: { type: "angle", default: "0deg", cssProperty: "--kui-from-slant" },
3332
- to: { type: "angle", default: "-10deg", cssProperty: "--kui-to-slant" }
3355
+ to: { type: "angle", default: "10deg", cssProperty: "--kui-to-slant" }
3356
+ };
3357
+ var textSweepParams = {
3358
+ color: { type: "color", default: "currentColor", cssProperty: "--kui-sweep-color" }
3359
+ };
3360
+ var extrudeParams = {
3361
+ angle: { type: "angle", default: "-20deg", cssProperty: "--kui-from-angle" },
3362
+ distance: { type: "length", default: "32px", cssProperty: "--kui-distance" }
3333
3363
  };
3334
3364
  var TEXT_CSS_PRIMITIVES = [
3335
3365
  cssPrimitive("text-shimmer", [CHANNEL.background], { reducedMotion: "disable" }),
3336
- cssPrimitive("text-sweep", [CHANNEL.background]),
3366
+ cssPrimitive("text-sweep", [CHANNEL.background], { parameters: textSweepParams }),
3337
3367
  cssPrimitive("text-outline-fill", [CHANNEL.stroke, CHANNEL.color]),
3338
3368
  cssPrimitive("var-weight", ["font"], { parameters: fontWeightParams }),
3339
3369
  cssPrimitive("var-width", ["font"], { parameters: fontWidthParams }),
@@ -3343,12 +3373,17 @@ var kuinetic = (() => {
3343
3373
  reducedMotion: "disable"
3344
3374
  }),
3345
3375
  cssPrimitive("redaction-reveal", [CHANNEL.clip]),
3346
- cssPrimitive("text-3d-extrude", [CHANNEL.rotate, CHANNEL.translate])
3376
+ cssPrimitive("text-3d-extrude", [CHANNEL.rotate, CHANNEL.translate], { parameters: extrudeParams })
3347
3377
  ];
3348
3378
  var TEXT_CSS_PRESETS = [
3349
3379
  { name: "gradient-shimmer", primitive: "text-shimmer", keyframes: "kui-gradient-shimmer" },
3350
3380
  { name: "gradient-sweep", primitive: "text-sweep", keyframes: "kui-gradient-sweep" },
3351
- { name: "highlight-sweep", primitive: "text-sweep", keyframes: "kui-highlight-sweep" },
3381
+ {
3382
+ name: "highlight-sweep",
3383
+ primitive: "text-sweep",
3384
+ keyframes: "kui-highlight-sweep",
3385
+ params: { color: "gold" }
3386
+ },
3352
3387
  { name: "underline-draw", primitive: "text-sweep", keyframes: "kui-underline-draw" },
3353
3388
  { name: "text-outline-fill", primitive: "text-outline-fill", keyframes: "kui-text-outline-fill" },
3354
3389
  { name: "var-weight", primitive: "var-weight", keyframes: "kui-var-weight" },
@@ -3822,6 +3857,29 @@ var kuinetic = (() => {
3822
3857
  reducedMotion: "disable",
3823
3858
  prepare: () => inertInstance()
3824
3859
  };
3860
+ function prepareSiblingScale(cssProperty) {
3861
+ return (el, params) => {
3862
+ const sibling = el.nextElementSibling;
3863
+ sibling?.style.setProperty(cssProperty, String(params.num("scale", 1)));
3864
+ return () => sibling?.style.removeProperty(cssProperty);
3865
+ };
3866
+ }
3867
+ function siblingScalePrimitive(id, cssProperty) {
3868
+ return {
3869
+ id,
3870
+ renderer: "javascript",
3871
+ channels: [CHANNEL.translate, CHANNEL.scale, CHANNEL.opacity, CHANNEL.stroke, CHANNEL.color],
3872
+ parameters: { scale: { type: "number", default: "1", cssProperty } },
3873
+ supportedTimelines: ["time"],
3874
+ supportedActivations: ["load"],
3875
+ defaultActivation: "load",
3876
+ perfClass: "compositor",
3877
+ reducedMotion: "disable",
3878
+ prepare: deferPrepare(prepareSiblingScale(cssProperty))
3879
+ };
3880
+ }
3881
+ var TOGGLE_MORPH_PRIMITIVE = siblingScalePrimitive("toggle-morph", "--kui-toggle-scale");
3882
+ var RADIO_FILL_PRIMITIVE = siblingScalePrimitive("radio-fill", "--kui-radio-scale");
3825
3883
  var FOCUS_RING_PRIMITIVE = cssPrimitive("focus-ring", ["shadow"], {
3826
3884
  activations: ["focus", "manual"],
3827
3885
  defaultActivation: "focus"
@@ -3914,7 +3972,7 @@ var kuinetic = (() => {
3914
3972
  var STEP_PROGRESS_PRIMITIVE = jsInputPrimitive(
3915
3973
  "step-progress",
3916
3974
  ["state"],
3917
- { steps: { type: "number", default: "4", cssProperty: "--kui-steps", minimum: 1, integer: true } },
3975
+ { steps: { type: "number", default: "4", cssProperty: "--kui-steps", minimum: 1, maximum: 20, integer: true } },
3918
3976
  deferPrepare(prepareStepProgress)
3919
3977
  );
3920
3978
  function nextSubmitStage(stage) {
@@ -3968,6 +4026,8 @@ var kuinetic = (() => {
3968
4026
  VALIDATE_SHAKE_PRIMITIVE,
3969
4027
  VALIDATE_CHECK_PRIMITIVE,
3970
4028
  STRENGTH_METER_PRIMITIVE,
4029
+ TOGGLE_MORPH_PRIMITIVE,
4030
+ RADIO_FILL_PRIMITIVE,
3971
4031
  RANGE_FILL_PRIMITIVE,
3972
4032
  STEP_PROGRESS_PRIMITIVE,
3973
4033
  SUBMIT_FLOW_PRIMITIVE
@@ -3979,9 +4039,9 @@ var kuinetic = (() => {
3979
4039
  { name: "validate-shake", primitive: "validate-shake", keyframes: "kui-validate-shake" },
3980
4040
  { name: "validate-check", primitive: "validate-check", keyframes: "kui-validate-check" },
3981
4041
  { name: "strength-meter", primitive: "strength-meter" },
3982
- { name: "toggle-morph", primitive: "native-state" },
4042
+ { name: "toggle-morph", primitive: "toggle-morph" },
3983
4043
  { name: "checkbox-draw", primitive: "native-state" },
3984
- { name: "radio-fill", primitive: "native-state" },
4044
+ { name: "radio-fill", primitive: "radio-fill" },
3985
4045
  { name: "range-fill", primitive: "range-fill" },
3986
4046
  { name: "submit-to-spinner-to-check", primitive: "submit-flow" },
3987
4047
  { name: "step-progress", primitive: "step-progress" }
@@ -4022,6 +4082,7 @@ var kuinetic = (() => {
4022
4082
  let origin = null;
4023
4083
  let active = false;
4024
4084
  let longPressTimer = null;
4085
+ let longPressFired = false;
4025
4086
  function sampleOf(event) {
4026
4087
  return { x: event.clientX, y: event.clientY, time: deps.now() };
4027
4088
  }
@@ -4038,9 +4099,13 @@ var kuinetic = (() => {
4038
4099
  origin = sampleOf(event);
4039
4100
  samples = [origin];
4040
4101
  active = false;
4102
+ longPressFired = false;
4041
4103
  el.setPointerCapture?.(event.pointerId);
4042
4104
  if (longPressMs > 0) {
4043
- longPressTimer = deps.setTimer(() => handlers.onLongPress?.(origin), longPressMs);
4105
+ longPressTimer = deps.setTimer(() => {
4106
+ longPressFired = true;
4107
+ handlers.onLongPress?.(origin);
4108
+ }, longPressMs);
4044
4109
  }
4045
4110
  }
4046
4111
  function onMove(event) {
@@ -4068,9 +4133,12 @@ var kuinetic = (() => {
4068
4133
  handlers.onEnd?.(vector, sample);
4069
4134
  const direction = swipeDirection(vector, swipeVelocity);
4070
4135
  if (direction) handlers.onSwipe?.(direction, vector);
4136
+ } else if (longPressFired) {
4137
+ handlers.onEnd?.(vector, sample);
4071
4138
  }
4072
4139
  origin = null;
4073
4140
  active = false;
4141
+ longPressFired = false;
4074
4142
  samples = [];
4075
4143
  }
4076
4144
  el.addEventListener("pointerdown", onDown);
@@ -4116,6 +4184,13 @@ var kuinetic = (() => {
4116
4184
  finite: true,
4117
4185
  minimum: 0.1,
4118
4186
  maximum: 1e3
4187
+ },
4188
+ mass: {
4189
+ type: "number",
4190
+ default: "1",
4191
+ cssProperty: "--kui-mass",
4192
+ finite: true,
4193
+ minimum: 0.1
4119
4194
  }
4120
4195
  };
4121
4196
  function gesturePrimitive(id, channels, parameters, prepare) {
@@ -4136,7 +4211,8 @@ var kuinetic = (() => {
4136
4211
  return {
4137
4212
  ...DEFAULT_SPRING,
4138
4213
  stiffness: params.num("stiffness", DEFAULT_SPRING.stiffness),
4139
- damping: params.num("damping", DEFAULT_SPRING.damping)
4214
+ damping: params.num("damping", DEFAULT_SPRING.damping),
4215
+ mass: params.num("mass", DEFAULT_SPRING.mass)
4140
4216
  };
4141
4217
  }
4142
4218
  function springDeps(ctx) {
@@ -4150,6 +4226,8 @@ var kuinetic = (() => {
4150
4226
  const bounds = params.num("bounds", 0);
4151
4227
  const returns = params.is("return");
4152
4228
  const inertia = params.is("inertia");
4229
+ const resistance = params.num("resistance", 0.55);
4230
+ const momentum = params.num("momentum", 0.2);
4153
4231
  const offset = { x: 0, y: 0 };
4154
4232
  const deps = springDeps(ctx);
4155
4233
  const runners = {
@@ -4170,11 +4248,11 @@ var kuinetic = (() => {
4170
4248
  el.setAttribute("data-kui-dragging", "true");
4171
4249
  },
4172
4250
  onMove(vector) {
4173
- write({ x: resist(vector.dx, bounds), y: resist(vector.dy, bounds) });
4251
+ write({ x: resist(vector.dx, bounds, resistance), y: resist(vector.dy, bounds, resistance) });
4174
4252
  },
4175
4253
  onEnd(vector) {
4176
4254
  el.setAttribute("data-kui-dragging", "false");
4177
- settle(runners, offset, vector, { returns, inertia });
4255
+ settle(runners, offset, vector, { returns, inertia, momentum });
4178
4256
  }
4179
4257
  },
4180
4258
  { axis: params.text("axis", "both") }
@@ -4187,8 +4265,8 @@ var kuinetic = (() => {
4187
4265
  el.removeAttribute("data-kui-dragging");
4188
4266
  };
4189
4267
  }
4190
- function resist(delta, bounds) {
4191
- return bounds > 0 ? rubberBand(delta, bounds) : delta;
4268
+ function resist(delta, bounds, tension) {
4269
+ return bounds > 0 ? rubberBand(delta, bounds, tension) : delta;
4192
4270
  }
4193
4271
  function settle(runners, offset, vector, mode) {
4194
4272
  runners.x.set(offset.x, mode.inertia ? vector.vx : 0);
@@ -4198,8 +4276,8 @@ var kuinetic = (() => {
4198
4276
  runners.y.to(0);
4199
4277
  return;
4200
4278
  }
4201
- runners.x.to(offset.x + vector.vx * 0.2);
4202
- runners.y.to(offset.y + vector.vy * 0.2);
4279
+ runners.x.to(offset.x + vector.vx * mode.momentum);
4280
+ runners.y.to(offset.y + vector.vy * mode.momentum);
4203
4281
  }
4204
4282
  function prepareSwipeable(el, params) {
4205
4283
  const stop = recognise(
@@ -4286,7 +4364,16 @@ var kuinetic = (() => {
4286
4364
  default: "false",
4287
4365
  cssProperty: "--kui-inertia",
4288
4366
  values: ["true", "false"]
4289
- }
4367
+ },
4368
+ resistance: {
4369
+ type: "number",
4370
+ default: "0.55",
4371
+ cssProperty: "--kui-resistance",
4372
+ finite: true,
4373
+ minimum: 0,
4374
+ maximum: 1
4375
+ },
4376
+ momentum: { type: "number", default: "0.2", cssProperty: "--kui-momentum", finite: true }
4290
4377
  },
4291
4378
  deferPrepare(prepareDraggable)
4292
4379
  ),
@@ -1,5 +1,7 @@
1
1
  import type { Primitive } from '../../core/types.js';
2
2
  export declare const NATIVE_STATE_PRIMITIVE: Primitive;
3
+ export declare const TOGGLE_MORPH_PRIMITIVE: Primitive;
4
+ export declare const RADIO_FILL_PRIMITIVE: Primitive;
3
5
  export declare const FOCUS_RING_PRIMITIVE: Primitive;
4
6
  export declare const VALIDATE_SHAKE_PRIMITIVE: Primitive;
5
7
  export declare const VALIDATE_CHECK_PRIMITIVE: Primitive;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kuinetic",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Declarative web animation from HTML attributes. Native CSS where possible, JS only where necessary.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -40,7 +40,7 @@
40
40
  "lint:deps": "depcruise src --config .dependency-cruiser.cjs",
41
41
  "lint:dead": "knip",
42
42
  "size": "npm run build:dist && size-limit",
43
- "build": "npm run generate:css && esbuild src/index.ts --bundle --format=iife --global-name=kuinetic --outfile=demo/kuinetic.js && esbuild src/css/index.css --bundle --outfile=demo/kuinetic.css && npx @tailwindcss/cli -i demo/tailwind-entry.css -o demo/tailwind.css",
43
+ "build": "npm run generate:css && esbuild src/index.ts --bundle --format=iife --global-name=kuinetic --outfile=demo/kuinetic.js && esbuild src/css/index.css --bundle --outfile=demo/kuinetic.css && npx @tailwindcss/cli -i demo/tailwind-entry.css -o demo/tailwind.css && node scripts/build-standalone.mjs demo",
44
44
  "build:dist": "npm run clean:dist && npm run generate:css && esbuild src/index.ts src/core/index.ts src/effects/index.ts --bundle --format=esm --splitting --outdir=dist/esm --out-extension:.js=.mjs && esbuild src/index.ts --bundle --format=iife --global-name=kuinetic --outfile=dist/kuinetic.js && esbuild src/css/index.css --bundle --outfile=dist/kuinetic.css && tsc -p tsconfig.build.json && node scripts/build-standalone.mjs",
45
45
  "verify:standalone": "npm run build:dist && node scripts/verify-standalone.mjs",
46
46
  "verify:pack": "npm run build:dist && node scripts/verify-pack.mjs",