@tooark/motion 1.0.1 → 1.2.0

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 CHANGED
@@ -30,7 +30,7 @@ The `@tooark/motion` package provides:
30
30
  - `arkReveal(targets, options)`: enter animation when the elements scroll into view (`once`, `amount`, `margin`), returns a stop function;
31
31
  - `arkFlip(targets, mutate, options)`: measure, apply your DOM mutation (reorder, insert, filter) and animate each item to its new place with a spring (`stiffness`, `damping`);
32
32
  - `arkSwipe(element, options)`: pointer gesture on an axis with `threshold`, `velocityThreshold`, drag `feedback` and `resistance`, calling `onSwipe(direction, { delta, velocity })`;
33
- - every helper honors `prefers-reduced-motion` and the `--ark-duration-*`/`--ark-ease-*` tokens; the Motion primitives (`animate`, `spring`, `stagger`, `inView`, …) are re-exported;
33
+ - every helper honors `prefers-reduced-motion`; `arkStaggerEnter` and `arkReveal` also read the `--ark-duration-*`/`--ark-ease-*`/`--ark-motion-distance` tokens (`arkFlip` and `arkSwipe` animate with springs, not token durations or easings); the Motion primitives (`animate`, `spring`, `stagger`, `inView`, …) are re-exported;
34
34
  - nothing here is required by the components: `@tooark/core` already ships a dependency-free motion layer.
35
35
 
36
36
  ---
@@ -45,7 +45,7 @@ pnpm add @tooark/motion # brings motion, @tooark/core and @tooark/tokens
45
45
 
46
46
  ## ⚙️ Configuration
47
47
 
48
- No registration: import the helpers you use. The durations and easings come from the tokens on the page (`@tooark/web-components/styles.css` or `@tooark/core/styles.css`); without them the JS mirrors from `@tooark/tokens` apply.
48
+ No registration: import the helpers you use. The durations, easings and slide distance of `arkStaggerEnter`/`arkReveal` come from the tokens on the page (`@tooark/web-components/styles.css` or `@tooark/core/styles.css`); without them the JS mirrors apply (durations and distance from `@tooark/tokens`, curves from the package's own bezier table).
49
49
 
50
50
  ---
51
51
 
@@ -57,7 +57,7 @@ No registration: import the helpers you use. The durations and easings come from
57
57
  - `arkSwipe(element, { axis?, threshold?, velocityThreshold?, feedback?, resistance?, onSwipe })` → dispose function.
58
58
  - `targets`: a selector, an element, an array or a `NodeList` (`ArkMotionTargets`).
59
59
  - Re-exports from Motion: `animate`, `hover`, `inView`, `press`, `scroll`, `spring`, `stagger`.
60
- - Types: `ArkStaggerOptions`, `ArkRevealOptions`, `ArkFlipOptions`, `ArkSwipeOptions`, `ArkSwipeDirection`, `ArkSwipeInfo`, `ArkMotionPreset`.
60
+ - Types: `ArkMotionPlusOptions`, `ArkStaggerOptions`, `ArkRevealOptions`, `ArkFlipOptions`, `ArkSwipeOptions`, `ArkSwipeDirection`, `ArkSwipeInfo`, `ArkMotionPreset`, `ArkMotionTargets`.
61
61
 
62
62
  ---
63
63
 
@@ -80,7 +80,7 @@ const stop = arkReveal(".card", { preset: "fade", once: true, amount: 0.3 });
80
80
  import { arkFlip, arkSwipe } from "@tooark/motion";
81
81
 
82
82
  const list = document.querySelector("ul")!;
83
- await arkFlip(list.children, () => {
83
+ await arkFlip(Array.from(list.children), () => {
84
84
  list.prepend(list.lastElementChild!); // any DOM mutation: reorder, insert, filter
85
85
  });
86
86
 
@@ -101,9 +101,9 @@ Installed automatically unless marked as peer; peer dependencies are yours to in
101
101
 
102
102
  | Package | Version | Description |
103
103
  | ---------------------------------------------------------------- | ------- | ---------------------------------------------------------------- |
104
- | [`@tooark/core`](https://www.npmjs.com/package/@tooark/core) | ^1.0.0 | Types, i18n, toast/announce services, motion and overlay helpers |
105
- | [`@tooark/tokens`](https://www.npmjs.com/package/@tooark/tokens) | ^1.0.0 | Design tokens (colors, sizes, radii, motion) and primitive types |
106
- | [`motion`](https://www.npmjs.com/package/motion) | ^13.1.1 | Motion animation library (spring physics, scroll, gestures) |
104
+ | [`@tooark/core`](https://www.npmjs.com/package/@tooark/core) | ^1.2.0 | Types, i18n, toast/announce services, motion and overlay helpers |
105
+ | [`@tooark/tokens`](https://www.npmjs.com/package/@tooark/tokens) | ^1.2.0 | Design tokens (colors, sizes, motion) and primitive types |
106
+ | [`motion`](https://www.npmjs.com/package/motion) | ^13.4.0 | Motion animation library (spring physics, scroll, gestures) |
107
107
  | [`tslib`](https://www.npmjs.com/package/tslib) | ^2.8.1 | TypeScript runtime helpers |
108
108
 
109
109
  ---
package/README.pt-BR.md CHANGED
@@ -30,7 +30,7 @@ O pacote `@tooark/motion` fornece:
30
30
  - `arkReveal(targets, options)`: animação de entrada quando os elementos entram na viewport (`once`, `amount`, `margin`), devolve a função que para;
31
31
  - `arkFlip(targets, mutate, options)`: mede, aplica a sua mutação de DOM (reordenar, inserir, filtrar) e anima cada item até a nova posição com spring (`stiffness`, `damping`);
32
32
  - `arkSwipe(element, options)`: gesto de ponteiro num eixo com `threshold`, `velocityThreshold`, `feedback` de arrasto e `resistance`, chamando `onSwipe(direction, { delta, velocity })`;
33
- - todos respeitam `prefers-reduced-motion` e os tokens `--ark-duration-*`/`--ark-ease-*`; as primitivas da Motion (`animate`, `spring`, `stagger`, `inView`, …) são reexportadas;
33
+ - todos respeitam `prefers-reduced-motion`; `arkStaggerEnter` e `arkReveal` também leem os tokens `--ark-duration-*`/`--ark-ease-*`/`--ark-motion-distance` (`arkFlip` e `arkSwipe` animam com spring, sem duração nem curva de token); as primitivas da Motion (`animate`, `spring`, `stagger`, `inView`, …) são reexportadas;
34
34
  - nada aqui é exigido pelos componentes: o `@tooark/core` já traz uma camada de motion sem dependências.
35
35
 
36
36
  ---
@@ -45,7 +45,7 @@ pnpm add @tooark/motion # traz motion, @tooark/core e @tooark/tokens
45
45
 
46
46
  ## ⚙️ Configuração
47
47
 
48
- Sem registro: importe os helpers que usar. Durações e easings vêm dos tokens na página (`@tooark/web-components/styles.css` ou `@tooark/core/styles.css`); sem eles valem os espelhos JS do `@tooark/tokens`.
48
+ Sem registro: importe os helpers que usar. Durações, easings e distância de slide do `arkStaggerEnter`/`arkReveal` vêm dos tokens na página (`@tooark/web-components/styles.css` ou `@tooark/core/styles.css`); sem eles valem os espelhos JS (durações e distância do `@tooark/tokens`, curvas da tabela bezier do próprio pacote).
49
49
 
50
50
  ---
51
51
 
@@ -57,7 +57,7 @@ Sem registro: importe os helpers que usar. Durações e easings vêm dos tokens
57
57
  - `arkSwipe(element, { axis?, threshold?, velocityThreshold?, feedback?, resistance?, onSwipe })` → função de dispose.
58
58
  - `targets`: um seletor, um elemento, um array ou uma `NodeList` (`ArkMotionTargets`).
59
59
  - Reexportados da Motion: `animate`, `hover`, `inView`, `press`, `scroll`, `spring`, `stagger`.
60
- - Tipos: `ArkStaggerOptions`, `ArkRevealOptions`, `ArkFlipOptions`, `ArkSwipeOptions`, `ArkSwipeDirection`, `ArkSwipeInfo`, `ArkMotionPreset`.
60
+ - Tipos: `ArkMotionPlusOptions`, `ArkStaggerOptions`, `ArkRevealOptions`, `ArkFlipOptions`, `ArkSwipeOptions`, `ArkSwipeDirection`, `ArkSwipeInfo`, `ArkMotionPreset`, `ArkMotionTargets`.
61
61
 
62
62
  ---
63
63
 
@@ -80,7 +80,7 @@ const parar = arkReveal(".card", { preset: "fade", once: true, amount: 0.3 });
80
80
  import { arkFlip, arkSwipe } from "@tooark/motion";
81
81
 
82
82
  const lista = document.querySelector("ul")!;
83
- await arkFlip(lista.children, () => {
83
+ await arkFlip(Array.from(lista.children), () => {
84
84
  lista.prepend(lista.lastElementChild!); // qualquer mutação de DOM: reordenar, inserir, filtrar
85
85
  });
86
86
 
@@ -101,9 +101,9 @@ Instaladas automaticamente, salvo as marcadas como peer, que ficam por sua conta
101
101
 
102
102
  | Pacote | Versão | Descrição |
103
103
  | ---------------------------------------------------------------- | ------- | -------------------------------------------------------------------- |
104
- | [`@tooark/core`](https://www.npmjs.com/package/@tooark/core) | ^1.0.0 | Tipos, i18n, serviços de toast/announce, motion e helpers de overlay |
105
- | [`@tooark/tokens`](https://www.npmjs.com/package/@tooark/tokens) | ^1.0.0 | Design tokens (cores, tamanhos, raios, motion) e tipos primitivos |
106
- | [`motion`](https://www.npmjs.com/package/motion) | ^13.1.1 | Biblioteca de animação Motion (spring, scroll, gestos) |
104
+ | [`@tooark/core`](https://www.npmjs.com/package/@tooark/core) | ^1.2.0 | Tipos, i18n, serviços de toast/announce, motion e helpers de overlay |
105
+ | [`@tooark/tokens`](https://www.npmjs.com/package/@tooark/tokens) | ^1.2.0 | Design tokens (cores, tamanhos, motion) e tipos primitivos |
106
+ | [`motion`](https://www.npmjs.com/package/motion) | ^13.4.0 | Biblioteca de animação Motion (spring, scroll, gestos) |
107
107
  | [`tslib`](https://www.npmjs.com/package/tslib) | ^2.8.1 | Helpers de runtime do TypeScript |
108
108
 
109
109
  ---
package/dist/index.cjs CHANGED
@@ -3,11 +3,7 @@
3
3
  var motion = require('motion');
4
4
  var core = require('@tooark/core');
5
5
 
6
- /**
7
- * Curvas dos tokens --ark-ease-* no formato aceito pela lib Motion (linear = bezier identidade).
8
- * @remarks As curvas são definidas como arrays de quatro números representando os pontos de controle
9
- * da função bezier cúbica.
10
- */
6
+ /** Curvas dos tokens --ark-ease-* nos quatro pontos de cubic-bezier que a lib Motion aceita (linear = identidade). */
11
7
  const ARK_EASE_BEZIER = {
12
8
  linear: [0, 0, 1, 1],
13
9
  standard: [0.2, 0, 0, 1],
@@ -17,11 +13,31 @@ const ARK_EASE_BEZIER = {
17
13
  overshoot: [0.34, 1.56, 0.64, 1],
18
14
  sheet: [0.32, 0.72, 0, 1]
19
15
  };
20
- /**
21
- * Normaliza seletor, elemento, array ou NodeList numa lista de HTMLElement.
22
- * @param targets O(s) alvo(s) a serem normalizados.
23
- * @returns Uma lista de elementos HTML.
24
- */
16
+ /** Valor de uma custom property (token --ark-*) no elemento, ou "" sem elemento ou fora do navegador. */
17
+ function readToken(element, name) {
18
+ if (!element || typeof getComputedStyle !== "function")
19
+ return "";
20
+ return getComputedStyle(element).getPropertyValue(name).trim();
21
+ }
22
+ /** "250ms" ou "0.25s" em milissegundos; null para qualquer outra coisa. */
23
+ function parseCssDurationMs(value) {
24
+ const match = /^(-?\d*\.?\d+)(ms|s)$/.exec(value);
25
+ if (!match)
26
+ return null;
27
+ const amount = Number(match[1]);
28
+ return match[2] === "s" ? amount * 1000 : amount;
29
+ }
30
+ /** "cubic-bezier(a, b, c, d)" ou "linear" como os quatro pontos que a lib Motion aceita; null para o resto. */
31
+ function parseCubicBezier(value) {
32
+ if (value === "linear")
33
+ return [0, 0, 1, 1];
34
+ const match = /^cubic-bezier\(([^)]+)\)$/.exec(value);
35
+ if (!match)
36
+ return null;
37
+ const points = match[1].split(",").map((part) => Number(part.trim()));
38
+ return points.length === 4 && points.every(Number.isFinite) ? points : null;
39
+ }
40
+ /** Normaliza seletor, elemento, array ou NodeList numa lista de HTMLElement (vazia sem document, como no SSR). */
25
41
  function resolveTargets(targets) {
26
42
  // Verifica se o alvo é uma string (seletor CSS) e resolve os elementos correspondentes.
27
43
  if (typeof targets === "string") {
@@ -40,12 +56,11 @@ function resolveTargets(targets) {
40
56
  return Array.from(targets).filter((el) => el instanceof HTMLElement);
41
57
  }
42
58
  /**
43
- * Resolve a duração em segundos a partir de um valor em milissegundos ou token ArkDuration.
44
- * @param duration A duração desejada em milissegundos ou como token ArkDuration.
45
- * @param fallback O token ArkDuration a ser usado caso duration não seja fornecido.
46
- * @returns A duração em segundos, respeitando a preferência de redução de movimento.
59
+ * Resolve a duração em segundos a partir de um valor em milissegundos ou token ArkDuration (`fallback` quando
60
+ * `duration` falta); 0 com movimento reduzido. O token vem da página (--ark-duration-* no elemento) e cai no espelho
61
+ * JS quando o CSS da lib não está carregado.
47
62
  */
48
- function resolveDurationSec(duration, fallback) {
63
+ function resolveDurationSec(element, duration, fallback) {
49
64
  // Retorna 0 se o usuário preferir animações reduzidas.
50
65
  if (core.prefersReducedMotion()) {
51
66
  return 0;
@@ -54,35 +69,33 @@ function resolveDurationSec(duration, fallback) {
54
69
  if (typeof duration === "number") {
55
70
  return Math.max(0, duration) / 1000;
56
71
  }
57
- // Converte o token ArkDuration em milissegundos e depois para segundos.
58
- return core.ARK_DURATION_MS[duration ?? fallback] / 1000;
72
+ // Token: o valor da página, senão o espelho JS; depois para segundos.
73
+ const token = duration ?? fallback;
74
+ return (parseCssDurationMs(readToken(element, `--ark-duration-${token}`)) ?? core.ARK_DURATION_MS[token]) / 1000;
59
75
  }
60
76
  /**
61
- * Resolve a curva de animação a partir de um token ArkEasing, array bezier ou nome.
62
- * @param ease A curva desejada como token ArkEasing, array bezier ou nome.
63
- * @returns A curva de animação correspondente, padrão: token out.
77
+ * Resolve a curva de animação a partir de um token ArkEasing, array bezier ou nome; sem valor, o token out. O token
78
+ * vem da página (--ark-ease-* no elemento) e cai no espelho JS quando o CSS da lib não está carregado.
64
79
  */
65
- function resolveEase(ease) {
66
- // Retorna a curva de animação correspondente, padrão: token out.
80
+ function resolveEase(element, ease) {
67
81
  if (Array.isArray(ease)) {
68
82
  return ease;
69
83
  }
70
- // Verifica se o ease é uma string correspondente a um token ArkEasing.
71
- if (typeof ease === "string" && ease in ARK_EASE_BEZIER) {
72
- return ARK_EASE_BEZIER[ease];
84
+ // Token (ou nenhum valor, que é o token out): a curva da página, senão o espelho JS.
85
+ const token = ease === undefined ? "out" : ease in ARK_EASE_BEZIER ? ease : null;
86
+ if (token) {
87
+ return parseCubicBezier(readToken(element, `--ark-ease-${token}`)) ?? ARK_EASE_BEZIER[token];
73
88
  }
74
- // Retorna a curva de animação padrão caso nenhum valor válido seja fornecido.
75
- return ease ?? ARK_EASE_BEZIER.out;
89
+ // Nome próprio da lib Motion ("easeInOut"...), repassado como veio.
90
+ return ease;
76
91
  }
77
92
  /**
78
- * Converte a distância CSS ("0.75rem", "24px") para px.
79
- * @param element O elemento HTML de referência para unidades relativas (em).
80
- * @param distance A distância desejada como string CSS.
81
- * @returns A distância em pixels.
93
+ * Converte a distância CSS ("0.75rem", "24px") para px: a pedida, senão --ark-motion-distance da página, senão o
94
+ * espelho JS. rem segue a fonte da raiz, em a do elemento, e um valor não numérico vira 12.
82
95
  */
83
96
  function resolveDistancePx(element, distance) {
84
- // Usa a distância fornecida ou o valor padrão ARK_MOTION_DISTANCE.
85
- const value = distance || core.ARK_MOTION_DISTANCE;
97
+ // A distância pedida, senão o token da página (--ark-motion-distance), senão o espelho JS.
98
+ const value = distance || readToken(element, "--ark-motion-distance") || core.ARK_MOTION_DISTANCE;
86
99
  const amount = Number.parseFloat(value);
87
100
  // Retorna um valor padrão caso a distância não seja um número finito.
88
101
  if (!Number.isFinite(amount)) {
@@ -101,12 +114,7 @@ function resolveDistancePx(element, distance) {
101
114
  }
102
115
  return amount;
103
116
  }
104
- /**
105
- * Offset inicial (x/y/scale) do estado oculto de cada preset.
106
- * @param preset O preset de animação desejado.
107
- * @param distancePx A distância em pixels para o deslocamento.
108
- * @returns Um objeto contendo os offsets iniciais (x/y/scale) correspondentes.
109
- */
117
+ /** Offset inicial (x/y/scale) do estado oculto de cada preset, com a distância em px nos presets de slide. */
110
118
  function hiddenOffset(preset, distancePx) {
111
119
  // Determina o offset inicial com base no preset de animação.
112
120
  if (preset === "slide-up") {
@@ -128,13 +136,9 @@ function hiddenOffset(preset, distancePx) {
128
136
  }
129
137
 
130
138
  /**
131
- * Animação FLIP: mede a posição dos elementos, aplica a mutação de DOM
132
- * (reordenar, inserir, filtrar) e anima cada item da posição antiga para
133
- * a nova com física de spring.
134
- * @param targets Os elementos a serem animados.
135
- * @param mutate A função que aplica a mutação de DOM.
136
- * @param options As opções de animação FLIP.
137
- * @returns Uma Promise que resolve quando todas as animações terminarem.
139
+ * Animação FLIP: mede a posição dos elementos, aplica a mutação de DOM (reordenar, inserir, filtrar) e anima cada
140
+ * item da posição antiga para a nova com física de spring. Resolve quando todas as animações terminam; com movimento
141
+ * reduzido só aplica a mutação.
138
142
  */
139
143
  async function arkFlip(targets, mutate, options = {}) {
140
144
  // Resolve os elementos alvo da animação.
@@ -194,9 +198,6 @@ async function arkFlip(targets, mutate, options = {}) {
194
198
  /**
195
199
  * Entrada escalonada de uma lista de elementos usando os motion tokens.
196
200
  * Resolve quando todos os itens terminam (imediatamente com reduced motion).
197
- * @param targets Os elementos a serem animados.
198
- * @param options As opções de configuração do stagger.
199
- * @returns Uma Promise que resolve quando todos os itens terminam a animação.
200
201
  */
201
202
  async function arkStaggerEnter(targets, options = {}) {
202
203
  // Resolve os elementos de destino para garantir que estamos lidando com uma lista de elementos.
@@ -232,8 +233,8 @@ async function arkStaggerEnter(targets, options = {}) {
232
233
  }
233
234
  // Aplica a animação aos elementos com os keyframes e as opções de stagger.
234
235
  await motion.animate(elements, keyframes, {
235
- duration: resolveDurationSec(options.duration, "default"),
236
- ease: resolveEase(options.ease),
236
+ duration: resolveDurationSec(elements[0], options.duration, "default"),
237
+ ease: resolveEase(elements[0], options.ease),
237
238
  delay: motion.stagger((options.interval ?? 60) / 1000, { from: options.from ?? "first" })
238
239
  });
239
240
  }
@@ -241,9 +242,6 @@ async function arkStaggerEnter(targets, options = {}) {
241
242
  /**
242
243
  * Scroll reveal: esconde os alvos e anima a entrada quando cada um aparece
243
244
  * na viewport. Retorna uma função de cleanup que para a observação.
244
- * @param targets Os elementos a serem observados.
245
- * @param options As opções de configuração do reveal.
246
- * @returns Uma função de cleanup que para a observação dos elementos.
247
245
  */
248
246
  function arkReveal(targets, options = {}) {
249
247
  // Resolve os elementos de destino para garantir que estamos lidando com uma lista de elementos.
@@ -285,9 +283,6 @@ function arkReveal(targets, options = {}) {
285
283
  /**
286
284
  * Gesto de swipe com feedback visual e retorno com física de spring.
287
285
  * Retorna uma função de cleanup que remove os listeners.
288
- * @param element O elemento HTML que receberá o gesto de swipe.
289
- * @param options As opções de configuração do swipe, incluindo eixo, limiar, resistência e callback.
290
- * @returns Uma função de cleanup que remove os listeners.
291
286
  */
292
287
  function arkSwipe(element, options) {
293
288
  const axis = options.axis ?? "x";
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":["../src/internal.ts","../src/flip.ts","../src/stagger.ts","../src/reveal.ts","../src/swipe.ts"],"sourcesContent":["import type { ArkDuration, ArkEasing, ArkMotionPreset } from \"@tooark/core\";\nimport { ARK_DURATION_MS, ARK_MOTION_DISTANCE, prefersReducedMotion } from \"@tooark/core\";\nimport type { ArkMotionTargets } from \"./types\";\n\n/**\n * Curvas dos tokens --ark-ease-* no formato aceito pela lib Motion (linear = bezier identidade).\n * @remarks As curvas são definidas como arrays de quatro números representando os pontos de controle\n * da função bezier cúbica.\n */\nexport const ARK_EASE_BEZIER: Record<ArkEasing, [number, number, number, number]> = {\n linear: [0, 0, 1, 1],\n standard: [0.2, 0, 0, 1],\n in: [0.4, 0, 1, 1],\n out: [0, 0, 0.2, 1],\n \"in-out\": [0.4, 0, 0.2, 1],\n overshoot: [0.34, 1.56, 0.64, 1],\n sheet: [0.32, 0.72, 0, 1]\n};\n\n/**\n * Normaliza seletor, elemento, array ou NodeList numa lista de HTMLElement.\n * @param targets O(s) alvo(s) a serem normalizados.\n * @returns Uma lista de elementos HTML.\n */\nexport function resolveTargets(targets: ArkMotionTargets): HTMLElement[] {\n // Verifica se o alvo é uma string (seletor CSS) e resolve os elementos correspondentes.\n if (typeof targets === \"string\") {\n // Se o documento não estiver disponível (ex: SSR), retorna uma lista vazia.\n if (typeof document === \"undefined\") {\n return [];\n }\n\n // Seleciona todos os elementos correspondentes ao seletor CSS.\n return Array.from(document.querySelectorAll<HTMLElement>(targets));\n }\n\n // Verifica se o alvo é um único elemento e o encapsula em um array.\n if (targets instanceof Element) {\n return targets instanceof HTMLElement ? [targets] : [];\n }\n\n // Assume que o alvo é um array ou NodeList e filtra apenas os elementos HTML.\n return Array.from(targets).filter((el): el is HTMLElement => el instanceof HTMLElement);\n}\n\n/**\n * Resolve a duração em segundos a partir de um valor em milissegundos ou token ArkDuration.\n * @param duration A duração desejada em milissegundos ou como token ArkDuration.\n * @param fallback O token ArkDuration a ser usado caso duration não seja fornecido.\n * @returns A duração em segundos, respeitando a preferência de redução de movimento.\n */\nexport function resolveDurationSec(duration: ArkDuration | number | undefined, fallback: ArkDuration): number {\n // Retorna 0 se o usuário preferir animações reduzidas.\n if (prefersReducedMotion()) {\n return 0;\n }\n\n // Garante que a duração seja um número válido em segundos.\n if (typeof duration === \"number\") {\n return Math.max(0, duration) / 1000;\n }\n\n // Converte o token ArkDuration em milissegundos e depois para segundos.\n return ARK_DURATION_MS[duration ?? fallback] / 1000;\n}\n\n/**\n * Resolve a curva de animação a partir de um token ArkEasing, array bezier ou nome.\n * @param ease A curva desejada como token ArkEasing, array bezier ou nome.\n * @returns A curva de animação correspondente, padrão: token out.\n */\nexport function resolveEase(ease: ArkEasing | number[] | string | undefined): number[] | string {\n // Retorna a curva de animação correspondente, padrão: token out.\n if (Array.isArray(ease)) {\n return ease;\n }\n\n // Verifica se o ease é uma string correspondente a um token ArkEasing.\n if (typeof ease === \"string\" && ease in ARK_EASE_BEZIER) {\n return ARK_EASE_BEZIER[ease as ArkEasing];\n }\n\n // Retorna a curva de animação padrão caso nenhum valor válido seja fornecido.\n return ease ?? ARK_EASE_BEZIER.out;\n}\n\n/**\n * Converte a distância CSS (\"0.75rem\", \"24px\") para px.\n * @param element O elemento HTML de referência para unidades relativas (em).\n * @param distance A distância desejada como string CSS.\n * @returns A distância em pixels.\n */\nexport function resolveDistancePx(element: HTMLElement | undefined, distance?: string): number {\n // Usa a distância fornecida ou o valor padrão ARK_MOTION_DISTANCE.\n const value = distance || ARK_MOTION_DISTANCE;\n const amount = Number.parseFloat(value);\n\n // Retorna um valor padrão caso a distância não seja um número finito.\n if (!Number.isFinite(amount)) {\n return 12;\n }\n\n // Converte a distância para pixels com base na unidade CSS.\n if (value.endsWith(\"rem\")) {\n // Obtém o tamanho da fonte raiz (root) para conversão de rem para px.\n const rootSize =\n typeof document !== \"undefined\" ? Number.parseFloat(getComputedStyle(document.documentElement).fontSize) : 16;\n\n return amount * (rootSize || 16);\n }\n\n // Converte a distância para pixels caso a unidade seja px (padrão) ou não especificada.\n if (value.endsWith(\"em\") && element) {\n // Obtém o tamanho da fonte do elemento para conversão de em para px.\n return amount * (Number.parseFloat(getComputedStyle(element).fontSize) || 16);\n }\n\n return amount;\n}\n\n/**\n * Offset inicial (x/y/scale) do estado oculto de cada preset.\n * @param preset O preset de animação desejado.\n * @param distancePx A distância em pixels para o deslocamento.\n * @returns Um objeto contendo os offsets iniciais (x/y/scale) correspondentes.\n */\nexport function hiddenOffset(preset: ArkMotionPreset, distancePx: number): { x?: number; y?: number; scale?: number } {\n // Determina o offset inicial com base no preset de animação.\n if (preset === \"slide-up\") {\n return { y: distancePx };\n }\n if (preset === \"slide-down\") {\n return { y: -distancePx };\n }\n if (preset === \"slide-left\") {\n return { x: -distancePx };\n }\n if (preset === \"slide-right\") {\n return { x: distancePx };\n }\n if (preset === \"scale\") {\n return { scale: 0.95 };\n }\n\n return {};\n}\n","import { prefersReducedMotion } from \"@tooark/core\";\nimport { animate } from \"motion\";\nimport { resolveTargets } from \"./internal\";\nimport type { ArkFlipOptions, ArkMotionTargets } from \"./types\";\n\n/**\n * Animação FLIP: mede a posição dos elementos, aplica a mutação de DOM\n * (reordenar, inserir, filtrar) e anima cada item da posição antiga para\n * a nova com física de spring.\n * @param targets Os elementos a serem animados.\n * @param mutate A função que aplica a mutação de DOM.\n * @param options As opções de animação FLIP.\n * @returns Uma Promise que resolve quando todas as animações terminarem.\n */\nexport async function arkFlip(\n targets: ArkMotionTargets,\n mutate: () => void,\n options: ArkFlipOptions = {}\n): Promise<void> {\n // Resolve os elementos alvo da animação.\n const elements = resolveTargets(targets);\n\n // Se não houver elementos ou se o usuário preferir animações reduzidas, aplica a mutação e retorna.\n if (elements.length === 0 || prefersReducedMotion()) {\n mutate();\n return;\n }\n\n // Mapa para armazenar a posição inicial de cada elemento.\n const first = new Map<HTMLElement, DOMRect>();\n\n // Captura a posição inicial de cada elemento.\n for (const el of elements) {\n first.set(el, el.getBoundingClientRect());\n }\n\n // Aplica a mutação de DOM para que possamos medir a nova posição dos elementos.\n mutate();\n\n // Captura a posição final de cada elemento após a mutação.\n const animations: Array<Promise<unknown>> = [];\n\n // Itera sobre cada elemento para calcular a diferença de posição e criar as animações.\n for (const el of elements) {\n // Pega a posição inicial do elemento antes da mutação.\n const before = first.get(el);\n\n // Se não houver posição inicial ou o elemento não estiver mais conectado ao DOM, pula a animação.\n if (!before || !el.isConnected) {\n continue;\n }\n\n // Captura a posição final do elemento após a mutação.\n const after = el.getBoundingClientRect();\n\n // Calcula a diferença de posição entre a posição inicial e final.\n const dx = before.left - after.left;\n const dy = before.top - after.top;\n\n // Se não houver diferença de posição, pula a animação.\n if (dx === 0 && dy === 0) {\n continue;\n }\n\n // Cria os keyframes para a animação com base na diferença de posição.\n const keyframes: Record<string, [number, number]> = {};\n\n // Adiciona os keyframes apenas se houver diferença de posição em x ou y.\n if (dx !== 0) {\n keyframes.x = [dx, 0];\n }\n if (dy !== 0) {\n keyframes.y = [dy, 0];\n }\n\n // Adiciona a animação à lista de animações a serem aguardadas.\n animations.push(\n Promise.resolve(\n animate(el, keyframes, {\n type: \"spring\",\n stiffness: options.stiffness ?? 350,\n damping: options.damping ?? 32\n })\n )\n );\n }\n\n // Aguarda todas as animações terminarem antes de continuar.\n await Promise.all(animations);\n}\n","import { prefersReducedMotion } from \"@tooark/core\";\nimport { animate, stagger } from \"motion\";\nimport { hiddenOffset, resolveDistancePx, resolveDurationSec, resolveEase, resolveTargets } from \"./internal\";\nimport type { ArkMotionTargets, ArkStaggerOptions } from \"./types\";\n\n/**\n * Entrada escalonada de uma lista de elementos usando os motion tokens.\n * Resolve quando todos os itens terminam (imediatamente com reduced motion).\n * @param targets Os elementos a serem animados.\n * @param options As opções de configuração do stagger.\n * @returns Uma Promise que resolve quando todos os itens terminam a animação.\n */\nexport async function arkStaggerEnter(targets: ArkMotionTargets, options: ArkStaggerOptions = {}): Promise<void> {\n // Resolve os elementos de destino para garantir que estamos lidando com uma lista de elementos.\n const elements = resolveTargets(targets);\n\n // Retorna imediatamente se não houver elementos para animar.\n if (elements.length === 0) {\n return;\n }\n\n // Retorna imediatamente se o usuário preferir animações reduzidas.\n if (prefersReducedMotion()) {\n // Remove qualquer estilo de opacidade e transformação aplicado anteriormente.\n for (const el of elements) {\n el.style.opacity = \"\";\n el.style.transform = \"\";\n }\n\n return;\n }\n\n // Determina o preset de animação, a distância em pixels e o deslocamento inicial com base no preset.\n const preset = options.preset ?? \"slide-up\";\n const distancePx = resolveDistancePx(elements[0], options.distance);\n const offset = hiddenOffset(preset, distancePx);\n\n // Cria os keyframes iniciais para a animação com base no deslocamento calculado.\n const keyframes: Record<string, [number, number]> = { opacity: [0, 1] };\n\n // Adiciona os keyframes de transformação com base no deslocamento calculado.\n if (offset.x !== undefined) {\n keyframes.x = [offset.x, 0];\n }\n if (offset.y !== undefined) {\n keyframes.y = [offset.y, 0];\n }\n if (offset.scale !== undefined) {\n keyframes.scale = [offset.scale, 1];\n }\n\n // Aplica a animação aos elementos com os keyframes e as opções de stagger.\n await animate(elements, keyframes, {\n duration: resolveDurationSec(options.duration, \"default\"),\n ease: resolveEase(options.ease) as never,\n delay: stagger((options.interval ?? 60) / 1000, { from: options.from ?? \"first\" })\n });\n}\n","import { prefersReducedMotion } from \"@tooark/core\";\nimport { inView } from \"motion\";\nimport { resolveTargets } from \"./internal\";\nimport { arkStaggerEnter } from \"./stagger\";\nimport type { ArkMotionTargets, ArkRevealOptions } from \"./types\";\n\n/**\n * Scroll reveal: esconde os alvos e anima a entrada quando cada um aparece\n * na viewport. Retorna uma função de cleanup que para a observação.\n * @param targets Os elementos a serem observados.\n * @param options As opções de configuração do reveal.\n * @returns Uma função de cleanup que para a observação dos elementos.\n */\nexport function arkReveal(targets: ArkMotionTargets, options: ArkRevealOptions = {}): () => void {\n // Resolve os elementos de destino para garantir que estamos lidando com uma lista de elementos.\n const elements = resolveTargets(targets);\n\n // Retorna imediatamente se não houver elementos para observar ou se o usuário preferir animações reduzidas.\n if (elements.length === 0 || prefersReducedMotion()) {\n return () => undefined;\n }\n\n // Define se a animação deve ocorrer apenas uma vez.\n const once = options.once ?? true;\n const stops: Array<() => void> = [];\n\n // Inicializa a lista de funções de cleanup para cada elemento observado.\n for (const el of elements) {\n el.style.opacity = \"0\";\n el.style.willChange = \"opacity, transform\";\n\n // Configura a observação do elemento usando a função inView. O `once` é do próprio inView: sem cleanup\n // devolvido ele para de observar o elemento depois da primeira entrada, então o callback não roda de novo.\n const stop = inView(\n el,\n () => {\n el.style.opacity = \"\";\n void arkStaggerEnter([el], { ...options, interval: 0 });\n\n if (!once) {\n // Cleanup ao sair da viewport: re-esconde para animar de novo\n return () => {\n el.style.opacity = \"0\";\n };\n }\n return undefined;\n },\n { amount: options.amount ?? 0.25, margin: options.margin as never }\n );\n\n // Adiciona a função de cleanup do elemento à lista de stops.\n stops.push(stop);\n }\n\n // Retorna uma função de cleanup que chama todas as funções de stop armazenadas.\n return () => {\n for (const stop of stops) stop();\n };\n}\n","import { prefersReducedMotion } from \"@tooark/core\";\nimport { animate } from \"motion\";\nimport type { ArkSwipeDirection, ArkSwipeOptions } from \"./types\";\n\n/**\n * Gesto de swipe com feedback visual e retorno com física de spring.\n * Retorna uma função de cleanup que remove os listeners.\n * @param element O elemento HTML que receberá o gesto de swipe.\n * @param options As opções de configuração do swipe, incluindo eixo, limiar, resistência e callback.\n * @returns Uma função de cleanup que remove os listeners.\n */\nexport function arkSwipe(element: HTMLElement, options: ArkSwipeOptions): () => void {\n const axis = options.axis ?? \"x\";\n const threshold = options.threshold ?? 48;\n const velocityThreshold = options.velocityThreshold ?? 500;\n const feedback = options.feedback ?? true;\n const resistance = Math.min(1, Math.max(0, options.resistance ?? 0.4));\n\n let pointerId: number | null = null;\n let startPos = 0;\n let delta = 0;\n let lastPos = 0;\n let lastTime = 0;\n let velocity = 0;\n\n // Lê a posição atual do ponteiro com base no eixo configurado.\n const readPos = (event: PointerEvent): number => (axis === \"x\" ? event.clientX : event.clientY);\n\n // Aplica o feedback visual de swipe enquanto o usuário arrasta o elemento.\n const applyFeedback = (value: number): void => {\n // Se o feedback visual estiver desativado, não aplica a transformação.\n if (!feedback) {\n return;\n }\n\n // Aplica a resistência ao valor do swipe.\n const damped = value * (1 - resistance);\n\n // Atualiza a transformação do elemento com base no valor amortecido.\n element.style.transform = axis === \"x\" ? `translateX(${damped}px)` : `translateY(${damped}px)`;\n };\n\n // Anima o elemento de volta à posição original com física de spring.\n const springBack = (): void => {\n // Se o feedback visual estiver desativado, não aplica a animação de retorno.\n if (!feedback) {\n return;\n }\n\n // Remove a transformação do elemento antes de aplicar a animação de retorno.\n element.style.transform = \"\";\n\n // Se o usuário preferir animações reduzidas, não aplica a animação de retorno.\n if (prefersReducedMotion()) {\n return;\n }\n\n // Calcula o valor amortecido com base na resistência configurada.\n const damped = delta * (1 - resistance);\n\n // Cria os keyframes para a animação de retorno com base no valor amortecido.\n const keyframes = axis === \"x\" ? { x: [damped, 0] } : { y: [damped, 0] };\n\n // Aplica a animação de retorno usando a biblioteca de animação.\n animate(element, keyframes as never, {\n type: \"spring\",\n stiffness: 420,\n damping: 34,\n velocity: -velocity * (1 - resistance)\n });\n };\n\n // Manipulador de evento para quando o ponteiro é pressionado.\n const onPointerDown = (event: PointerEvent): void => {\n // Ignora o evento se já houver um ponteiro ativo ou se o ponteiro não for primário.\n if (pointerId !== null || !event.isPrimary) {\n return;\n }\n\n pointerId = event.pointerId;\n startPos = lastPos = readPos(event);\n lastTime = event.timeStamp;\n delta = 0;\n velocity = 0;\n element.setPointerCapture(event.pointerId);\n };\n\n // Manipulador de evento para quando o ponteiro é movido.\n const onPointerMove = (event: PointerEvent): void => {\n // Ignora o evento se o ponteiro não for o ativo.\n if (event.pointerId !== pointerId) {\n return;\n }\n\n // Calcula a posição atual do ponteiro e o tempo decorrido desde o último evento.\n const pos = readPos(event);\n const elapsed = event.timeStamp - lastTime;\n\n // Calcula a velocidade do ponteiro com base na mudança de posição e no tempo decorrido.\n if (elapsed > 0) {\n velocity = ((pos - lastPos) / elapsed) * 1000;\n }\n\n // Atualiza a posição e o tempo do último evento para o próximo cálculo de velocidade.\n lastPos = pos;\n lastTime = event.timeStamp;\n delta = pos - startPos;\n\n // Aplica o feedback visual com base no deslocamento atual.\n applyFeedback(delta);\n };\n\n // Manipulador de evento para quando o ponteiro é liberado ou cancelado.\n const finish = (event: PointerEvent): void => {\n // Ignora o evento se o ponteiro não for o ativo.\n if (event.pointerId !== pointerId) {\n return;\n }\n\n // Libera o ponteiro e redefine o estado interno.\n pointerId = null;\n element.releasePointerCapture(event.pointerId);\n\n // Determina se o gesto de swipe foi acionado com base no deslocamento e na velocidade.\n const triggered = Math.abs(delta) >= threshold || Math.abs(velocity) >= velocityThreshold;\n\n // Aciona o callback de swipe se o gesto foi detectado e o deslocamento não for zero.\n if (triggered && delta !== 0) {\n const direction: ArkSwipeDirection = axis === \"x\" ? (delta < 0 ? \"left\" : \"right\") : delta < 0 ? \"up\" : \"down\";\n options.onSwipe(direction, { delta, velocity });\n }\n\n // Restaura o elemento à sua posição original usando a animação de spring back.\n springBack();\n delta = 0;\n };\n\n // Armazena a ação de toque anterior e define a ação de toque apropriada para o eixo do swipe.\n const previousTouchAction = element.style.touchAction;\n element.style.touchAction = axis === \"x\" ? \"pan-y\" : \"pan-x\";\n\n // Adiciona os manipuladores de eventos para o ponteiro.\n element.addEventListener(\"pointerdown\", onPointerDown);\n element.addEventListener(\"pointermove\", onPointerMove);\n element.addEventListener(\"pointerup\", finish);\n element.addEventListener(\"pointercancel\", finish);\n\n // Retorna uma função de limpeza que remove os manipuladores de eventos e restaura a ação de toque original.\n return () => {\n element.style.touchAction = previousTouchAction;\n element.removeEventListener(\"pointerdown\", onPointerDown);\n element.removeEventListener(\"pointermove\", onPointerMove);\n element.removeEventListener(\"pointerup\", finish);\n element.removeEventListener(\"pointercancel\", finish);\n };\n}\n"],"names":["prefersReducedMotion","ARK_DURATION_MS","ARK_MOTION_DISTANCE","animate","stagger","inView"],"mappings":";;;;;AAIA;;;;AAIG;AACI,MAAM,eAAe,GAAwD;IAClF,MAAM,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;IACpB,QAAQ,EAAE,CAAC,GAAG,EAAE,CAAC,EAAE,CAA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AAmB,CAAC,WAAW,EAAE,MAAM,CAAC;AAChD,QAAA,OAAO,CAAC,mBAAmB,CAAC,eAAe,EAAE,MAAM,CAAC;AACtD,IAAA,CAAC;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.cjs","sources":["../src/internal.ts","../src/flip.ts","../src/stagger.ts","../src/reveal.ts","../src/swipe.ts"],"sourcesContent":["import type { ArkDuration, ArkEasing, ArkMotionPreset } from \"@tooark/core\";\nimport { ARK_DURATION_MS, ARK_MOTION_DISTANCE, prefersReducedMotion } from \"@tooark/core\";\nimport type { ArkMotionTargets } from \"./types\";\n\n/** Curvas dos tokens --ark-ease-* nos quatro pontos de cubic-bezier que a lib Motion aceita (linear = identidade). */\nexport const ARK_EASE_BEZIER: Record<ArkEasing, [number, number, number, number]> = {\n linear: [0, 0, 1, 1],\n standard: [0.2, 0, 0, 1],\n in: [0.4, 0, 1, 1],\n out: [0, 0, 0.2, 1],\n \"in-out\": [0.4, 0, 0.2, 1],\n overshoot: [0.34, 1.56, 0.64, 1],\n sheet: [0.32, 0.72, 0, 1]\n};\n\n/** Valor de uma custom property (token --ark-*) no elemento, ou \"\" sem elemento ou fora do navegador. */\nfunction readToken(element: Element | undefined, name: string): string {\n if (!element || typeof getComputedStyle !== \"function\") return \"\";\n return getComputedStyle(element).getPropertyValue(name).trim();\n}\n\n/** \"250ms\" ou \"0.25s\" em milissegundos; null para qualquer outra coisa. */\nfunction parseCssDurationMs(value: string): number | null {\n const match = /^(-?\\d*\\.?\\d+)(ms|s)$/.exec(value);\n if (!match) return null;\n const amount = Number(match[1]);\n return match[2] === \"s\" ? amount * 1000 : amount;\n}\n\n/** \"cubic-bezier(a, b, c, d)\" ou \"linear\" como os quatro pontos que a lib Motion aceita; null para o resto. */\nfunction parseCubicBezier(value: string): [number, number, number, number] | null {\n if (value === \"linear\") return [0, 0, 1, 1];\n const match = /^cubic-bezier\\(([^)]+)\\)$/.exec(value);\n if (!match) return null;\n const points = match[1].split(\",\").map((part) => Number(part.trim()));\n return points.length === 4 && points.every(Number.isFinite) ? (points as [number, number, number, number]) : null;\n}\n\n/** Normaliza seletor, elemento, array ou NodeList numa lista de HTMLElement (vazia sem document, como no SSR). */\nexport function resolveTargets(targets: ArkMotionTargets): HTMLElement[] {\n // Verifica se o alvo é uma string (seletor CSS) e resolve os elementos correspondentes.\n if (typeof targets === \"string\") {\n // Se o documento não estiver disponível (ex: SSR), retorna uma lista vazia.\n if (typeof document === \"undefined\") {\n return [];\n }\n\n // Seleciona todos os elementos correspondentes ao seletor CSS.\n return Array.from(document.querySelectorAll<HTMLElement>(targets));\n }\n\n // Verifica se o alvo é um único elemento e o encapsula em um array.\n if (targets instanceof Element) {\n return targets instanceof HTMLElement ? [targets] : [];\n }\n\n // Assume que o alvo é um array ou NodeList e filtra apenas os elementos HTML.\n return Array.from(targets).filter((el): el is HTMLElement => el instanceof HTMLElement);\n}\n\n/**\n * Resolve a duração em segundos a partir de um valor em milissegundos ou token ArkDuration (`fallback` quando\n * `duration` falta); 0 com movimento reduzido. O token vem da página (--ark-duration-* no elemento) e cai no espelho\n * JS quando o CSS da lib não está carregado.\n */\nexport function resolveDurationSec(\n element: Element | undefined,\n duration: ArkDuration | number | undefined,\n fallback: ArkDuration\n): number {\n // Retorna 0 se o usuário preferir animações reduzidas.\n if (prefersReducedMotion()) {\n return 0;\n }\n\n // Garante que a duração seja um número válido em segundos.\n if (typeof duration === \"number\") {\n return Math.max(0, duration) / 1000;\n }\n\n // Token: o valor da página, senão o espelho JS; depois para segundos.\n const token = duration ?? fallback;\n return (parseCssDurationMs(readToken(element, `--ark-duration-${token}`)) ?? ARK_DURATION_MS[token]) / 1000;\n}\n\n/**\n * Resolve a curva de animação a partir de um token ArkEasing, array bezier ou nome; sem valor, o token out. O token\n * vem da página (--ark-ease-* no elemento) e cai no espelho JS quando o CSS da lib não está carregado.\n */\nexport function resolveEase(\n element: Element | undefined,\n ease: ArkEasing | number[] | string | undefined\n): number[] | string {\n if (Array.isArray(ease)) {\n return ease;\n }\n\n // Token (ou nenhum valor, que é o token out): a curva da página, senão o espelho JS.\n const token = ease === undefined ? \"out\" : ease in ARK_EASE_BEZIER ? (ease as ArkEasing) : null;\n if (token) {\n return parseCubicBezier(readToken(element, `--ark-ease-${token}`)) ?? ARK_EASE_BEZIER[token];\n }\n\n // Nome próprio da lib Motion (\"easeInOut\"...), repassado como veio.\n return ease as string;\n}\n\n/**\n * Converte a distância CSS (\"0.75rem\", \"24px\") para px: a pedida, senão --ark-motion-distance da página, senão o\n * espelho JS. rem segue a fonte da raiz, em a do elemento, e um valor não numérico vira 12.\n */\nexport function resolveDistancePx(element: HTMLElement | undefined, distance?: string): number {\n // A distância pedida, senão o token da página (--ark-motion-distance), senão o espelho JS.\n const value = distance || readToken(element, \"--ark-motion-distance\") || ARK_MOTION_DISTANCE;\n const amount = Number.parseFloat(value);\n\n // Retorna um valor padrão caso a distância não seja um número finito.\n if (!Number.isFinite(amount)) {\n return 12;\n }\n\n // Converte a distância para pixels com base na unidade CSS.\n if (value.endsWith(\"rem\")) {\n // Obtém o tamanho da fonte raiz (root) para conversão de rem para px.\n const rootSize =\n typeof document !== \"undefined\" ? Number.parseFloat(getComputedStyle(document.documentElement).fontSize) : 16;\n\n return amount * (rootSize || 16);\n }\n\n // Converte a distância para pixels caso a unidade seja px (padrão) ou não especificada.\n if (value.endsWith(\"em\") && element) {\n // Obtém o tamanho da fonte do elemento para conversão de em para px.\n return amount * (Number.parseFloat(getComputedStyle(element).fontSize) || 16);\n }\n\n return amount;\n}\n\n/** Offset inicial (x/y/scale) do estado oculto de cada preset, com a distância em px nos presets de slide. */\nexport function hiddenOffset(preset: ArkMotionPreset, distancePx: number): { x?: number; y?: number; scale?: number } {\n // Determina o offset inicial com base no preset de animação.\n if (preset === \"slide-up\") {\n return { y: distancePx };\n }\n if (preset === \"slide-down\") {\n return { y: -distancePx };\n }\n if (preset === \"slide-left\") {\n return { x: -distancePx };\n }\n if (preset === \"slide-right\") {\n return { x: distancePx };\n }\n if (preset === \"scale\") {\n return { scale: 0.95 };\n }\n\n return {};\n}\n","import { prefersReducedMotion } from \"@tooark/core\";\nimport { animate } from \"motion\";\nimport { resolveTargets } from \"./internal\";\nimport type { ArkFlipOptions, ArkMotionTargets } from \"./types\";\n\n/**\n * Animação FLIP: mede a posição dos elementos, aplica a mutação de DOM (reordenar, inserir, filtrar) e anima cada\n * item da posição antiga para a nova com física de spring. Resolve quando todas as animações terminam; com movimento\n * reduzido só aplica a mutação.\n */\nexport async function arkFlip(\n targets: ArkMotionTargets,\n mutate: () => void,\n options: ArkFlipOptions = {}\n): Promise<void> {\n // Resolve os elementos alvo da animação.\n const elements = resolveTargets(targets);\n\n // Se não houver elementos ou se o usuário preferir animações reduzidas, aplica a mutação e retorna.\n if (elements.length === 0 || prefersReducedMotion()) {\n mutate();\n return;\n }\n\n // Mapa para armazenar a posição inicial de cada elemento.\n const first = new Map<HTMLElement, DOMRect>();\n\n // Captura a posição inicial de cada elemento.\n for (const el of elements) {\n first.set(el, el.getBoundingClientRect());\n }\n\n // Aplica a mutação de DOM para que possamos medir a nova posição dos elementos.\n mutate();\n\n // Captura a posição final de cada elemento após a mutação.\n const animations: Array<Promise<unknown>> = [];\n\n // Itera sobre cada elemento para calcular a diferença de posição e criar as animações.\n for (const el of elements) {\n // Pega a posição inicial do elemento antes da mutação.\n const before = first.get(el);\n\n // Se não houver posição inicial ou o elemento não estiver mais conectado ao DOM, pula a animação.\n if (!before || !el.isConnected) {\n continue;\n }\n\n // Captura a posição final do elemento após a mutação.\n const after = el.getBoundingClientRect();\n\n // Calcula a diferença de posição entre a posição inicial e final.\n const dx = before.left - after.left;\n const dy = before.top - after.top;\n\n // Se não houver diferença de posição, pula a animação.\n if (dx === 0 && dy === 0) {\n continue;\n }\n\n // Cria os keyframes para a animação com base na diferença de posição.\n const keyframes: Record<string, [number, number]> = {};\n\n // Adiciona os keyframes apenas se houver diferença de posição em x ou y.\n if (dx !== 0) {\n keyframes.x = [dx, 0];\n }\n if (dy !== 0) {\n keyframes.y = [dy, 0];\n }\n\n // Adiciona a animação à lista de animações a serem aguardadas.\n animations.push(\n Promise.resolve(\n animate(el, keyframes, {\n type: \"spring\",\n stiffness: options.stiffness ?? 350,\n damping: options.damping ?? 32\n })\n )\n );\n }\n\n // Aguarda todas as animações terminarem antes de continuar.\n await Promise.all(animations);\n}\n","import { prefersReducedMotion } from \"@tooark/core\";\nimport { animate, stagger } from \"motion\";\nimport { hiddenOffset, resolveDistancePx, resolveDurationSec, resolveEase, resolveTargets } from \"./internal\";\nimport type { ArkMotionTargets, ArkStaggerOptions } from \"./types\";\n\n/**\n * Entrada escalonada de uma lista de elementos usando os motion tokens.\n * Resolve quando todos os itens terminam (imediatamente com reduced motion).\n */\nexport async function arkStaggerEnter(targets: ArkMotionTargets, options: ArkStaggerOptions = {}): Promise<void> {\n // Resolve os elementos de destino para garantir que estamos lidando com uma lista de elementos.\n const elements = resolveTargets(targets);\n\n // Retorna imediatamente se não houver elementos para animar.\n if (elements.length === 0) {\n return;\n }\n\n // Retorna imediatamente se o usuário preferir animações reduzidas.\n if (prefersReducedMotion()) {\n // Remove qualquer estilo de opacidade e transformação aplicado anteriormente.\n for (const el of elements) {\n el.style.opacity = \"\";\n el.style.transform = \"\";\n }\n\n return;\n }\n\n // Determina o preset de animação, a distância em pixels e o deslocamento inicial com base no preset.\n const preset = options.preset ?? \"slide-up\";\n const distancePx = resolveDistancePx(elements[0], options.distance);\n const offset = hiddenOffset(preset, distancePx);\n\n // Cria os keyframes iniciais para a animação com base no deslocamento calculado.\n const keyframes: Record<string, [number, number]> = { opacity: [0, 1] };\n\n // Adiciona os keyframes de transformação com base no deslocamento calculado.\n if (offset.x !== undefined) {\n keyframes.x = [offset.x, 0];\n }\n if (offset.y !== undefined) {\n keyframes.y = [offset.y, 0];\n }\n if (offset.scale !== undefined) {\n keyframes.scale = [offset.scale, 1];\n }\n\n // Aplica a animação aos elementos com os keyframes e as opções de stagger.\n await animate(elements, keyframes, {\n duration: resolveDurationSec(elements[0], options.duration, \"default\"),\n ease: resolveEase(elements[0], options.ease) as never,\n delay: stagger((options.interval ?? 60) / 1000, { from: options.from ?? \"first\" })\n });\n}\n","import { prefersReducedMotion } from \"@tooark/core\";\nimport { inView } from \"motion\";\nimport { resolveTargets } from \"./internal\";\nimport { arkStaggerEnter } from \"./stagger\";\nimport type { ArkMotionTargets, ArkRevealOptions } from \"./types\";\n\n/**\n * Scroll reveal: esconde os alvos e anima a entrada quando cada um aparece\n * na viewport. Retorna uma função de cleanup que para a observação.\n */\nexport function arkReveal(targets: ArkMotionTargets, options: ArkRevealOptions = {}): () => void {\n // Resolve os elementos de destino para garantir que estamos lidando com uma lista de elementos.\n const elements = resolveTargets(targets);\n\n // Retorna imediatamente se não houver elementos para observar ou se o usuário preferir animações reduzidas.\n if (elements.length === 0 || prefersReducedMotion()) {\n return () => undefined;\n }\n\n // Define se a animação deve ocorrer apenas uma vez.\n const once = options.once ?? true;\n const stops: Array<() => void> = [];\n\n // Inicializa a lista de funções de cleanup para cada elemento observado.\n for (const el of elements) {\n el.style.opacity = \"0\";\n el.style.willChange = \"opacity, transform\";\n\n // Configura a observação do elemento usando a função inView. O `once` é do próprio inView: sem cleanup\n // devolvido ele para de observar o elemento depois da primeira entrada, então o callback não roda de novo.\n const stop = inView(\n el,\n () => {\n el.style.opacity = \"\";\n void arkStaggerEnter([el], { ...options, interval: 0 });\n\n if (!once) {\n // Cleanup ao sair da viewport: re-esconde para animar de novo\n return () => {\n el.style.opacity = \"0\";\n };\n }\n return undefined;\n },\n { amount: options.amount ?? 0.25, margin: options.margin as never }\n );\n\n // Adiciona a função de cleanup do elemento à lista de stops.\n stops.push(stop);\n }\n\n // Retorna uma função de cleanup que chama todas as funções de stop armazenadas.\n return () => {\n for (const stop of stops) stop();\n };\n}\n","import { prefersReducedMotion } from \"@tooark/core\";\nimport { animate } from \"motion\";\nimport type { ArkSwipeDirection, ArkSwipeOptions } from \"./types\";\n\n/**\n * Gesto de swipe com feedback visual e retorno com física de spring.\n * Retorna uma função de cleanup que remove os listeners.\n */\nexport function arkSwipe(element: HTMLElement, options: ArkSwipeOptions): () => void {\n const axis = options.axis ?? \"x\";\n const threshold = options.threshold ?? 48;\n const velocityThreshold = options.velocityThreshold ?? 500;\n const feedback = options.feedback ?? true;\n const resistance = Math.min(1, Math.max(0, options.resistance ?? 0.4));\n\n let pointerId: number | null = null;\n let startPos = 0;\n let delta = 0;\n let lastPos = 0;\n let lastTime = 0;\n let velocity = 0;\n\n // Lê a posição atual do ponteiro com base no eixo configurado.\n const readPos = (event: PointerEvent): number => (axis === \"x\" ? event.clientX : event.clientY);\n\n // Aplica o feedback visual de swipe enquanto o usuário arrasta o elemento.\n const applyFeedback = (value: number): void => {\n // Se o feedback visual estiver desativado, não aplica a transformação.\n if (!feedback) {\n return;\n }\n\n // Aplica a resistência ao valor do swipe.\n const damped = value * (1 - resistance);\n\n // Atualiza a transformação do elemento com base no valor amortecido.\n element.style.transform = axis === \"x\" ? `translateX(${damped}px)` : `translateY(${damped}px)`;\n };\n\n // Anima o elemento de volta à posição original com física de spring.\n const springBack = (): void => {\n // Se o feedback visual estiver desativado, não aplica a animação de retorno.\n if (!feedback) {\n return;\n }\n\n // Remove a transformação do elemento antes de aplicar a animação de retorno.\n element.style.transform = \"\";\n\n // Se o usuário preferir animações reduzidas, não aplica a animação de retorno.\n if (prefersReducedMotion()) {\n return;\n }\n\n // Calcula o valor amortecido com base na resistência configurada.\n const damped = delta * (1 - resistance);\n\n // Cria os keyframes para a animação de retorno com base no valor amortecido.\n const keyframes = axis === \"x\" ? { x: [damped, 0] } : { y: [damped, 0] };\n\n // Aplica a animação de retorno usando a biblioteca de animação.\n animate(element, keyframes as never, {\n type: \"spring\",\n stiffness: 420,\n damping: 34,\n velocity: -velocity * (1 - resistance)\n });\n };\n\n // Manipulador de evento para quando o ponteiro é pressionado.\n const onPointerDown = (event: PointerEvent): void => {\n // Ignora o evento se já houver um ponteiro ativo ou se o ponteiro não for primário.\n if (pointerId !== null || !event.isPrimary) {\n return;\n }\n\n pointerId = event.pointerId;\n startPos = lastPos = readPos(event);\n lastTime = event.timeStamp;\n delta = 0;\n velocity = 0;\n element.setPointerCapture(event.pointerId);\n };\n\n // Manipulador de evento para quando o ponteiro é movido.\n const onPointerMove = (event: PointerEvent): void => {\n // Ignora o evento se o ponteiro não for o ativo.\n if (event.pointerId !== pointerId) {\n return;\n }\n\n // Calcula a posição atual do ponteiro e o tempo decorrido desde o último evento.\n const pos = readPos(event);\n const elapsed = event.timeStamp - lastTime;\n\n // Calcula a velocidade do ponteiro com base na mudança de posição e no tempo decorrido.\n if (elapsed > 0) {\n velocity = ((pos - lastPos) / elapsed) * 1000;\n }\n\n // Atualiza a posição e o tempo do último evento para o próximo cálculo de velocidade.\n lastPos = pos;\n lastTime = event.timeStamp;\n delta = pos - startPos;\n\n // Aplica o feedback visual com base no deslocamento atual.\n applyFeedback(delta);\n };\n\n // Manipulador de evento para quando o ponteiro é liberado ou cancelado.\n const finish = (event: PointerEvent): void => {\n // Ignora o evento se o ponteiro não for o ativo.\n if (event.pointerId !== pointerId) {\n return;\n }\n\n // Libera o ponteiro e redefine o estado interno.\n pointerId = null;\n element.releasePointerCapture(event.pointerId);\n\n // Determina se o gesto de swipe foi acionado com base no deslocamento e na velocidade.\n const triggered = Math.abs(delta) >= threshold || Math.abs(velocity) >= velocityThreshold;\n\n // Aciona o callback de swipe se o gesto foi detectado e o deslocamento não for zero.\n if (triggered && delta !== 0) {\n const direction: ArkSwipeDirection = axis === \"x\" ? (delta < 0 ? \"left\" : \"right\") : delta < 0 ? \"up\" : \"down\";\n options.onSwipe(direction, { delta, velocity });\n }\n\n // Restaura o elemento à sua posição original usando a animação de spring back.\n springBack();\n delta = 0;\n };\n\n // Armazena a ação de toque anterior e define a ação de toque apropriada para o eixo do swipe.\n const previousTouchAction = element.style.touchAction;\n element.style.touchAction = axis === \"x\" ? \"pan-y\" : \"pan-x\";\n\n // Adiciona os manipuladores de eventos para o ponteiro.\n element.addEventListener(\"pointerdown\", onPointerDown);\n element.addEventListener(\"pointermove\", onPointerMove);\n element.addEventListener(\"pointerup\", finish);\n element.addEventListener(\"pointercancel\", finish);\n\n // Retorna uma função de limpeza que remove os manipuladores de eventos e restaura a ação de toque original.\n return () => {\n element.style.touchAction = previousTouchAction;\n element.removeEventListener(\"pointerdown\", onPointerDown);\n element.removeEventListener(\"pointermove\", onPointerMove);\n element.removeEventListener(\"pointerup\", finish);\n element.removeEventListener(\"pointercancel\", finish);\n };\n}\n"],"names":["prefersReducedMotion","ARK_DURATION_MS","ARK_MOTION_DISTANCE","animate","stagger","inView"],"mappings":";;;;;AAIA;AACO,MAAM,eAAe,GAAwD;IAClF,MAAM,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;IACpB,QAAQ,EAAE,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;IACxB,EAAE,EAAE,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;IAClB,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC;IACnB,QAAQ,EAAE,CAAC,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC;IAC1B,SAAS,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;IAChC,KAAK,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;CACzB;AAED;AACA,SAAS,SAAS,CAAC,OAA4B,EAAE,IAAY,EAAA;AAC3D,IAAA,IAAI,CAAC,OAAO,IAAI,OAAO,gBAAgB,KAAK,UAAU;AAAE,QAAA,OAAO,EAAE;AACjE,IAAA,OAAO,gBAAgB,CAAC,OAAO,CAAC,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE;AAChE;AAEA;AACA,SA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GAAG,IAAI,GAAG,MAAM;YAC9G,OAAO,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC;QACjD;;AAGA,QAAA,UAAU,EAAE;QACZ,KAAK,GAAG,CAAC;AACX,IAAA,CAAC;;AAGD,IAAA,MAAM,mBAAmB,GAAG,OAAO,CAAC,KAAK,CAAC,WAAW;AACrD,IAAA,OAAO,CAAC,KAAK,CAAC,WAAW,GAAG,IAAI,KAAK,GAAG,GAAG,OAAO,GAAG,OAAO;;AAG5D,IAAA,OAAO,CAAC,gBAAgB,CAAC,aAAa,EAAE,aAAa,CAAC;AACtD,IAAA,OAAO,CAAC,gBAAgB,CAAC,aAAa,EAAE,aAAa,CAAC;AACtD,IAAA,OAAO,CAAC,gBAAgB,CAAC,WAAW,EAAE,MAAM,CAAC;AAC7C,IAAA,OAAO,CAAC,gBAAgB,CAAC,eAAe,EAAE,MAAM,CAAC;;AAGjD,IAAA,OAAO,MAAK;AACV,QAAA,OAAO,CAAC,KAAK,CAAC,WAAW,GAAG,mBAAmB;AAC/C,QAAA,OAAO,CAAC,mBAAmB,CAAC,aAAa,EAAE,aAAa,CAAC;AACzD,QAAA,OAAO,CAAC,mBAAmB,CAAC,aAAa,EAAE,aAAa,CAAC;AACzD,QAAA,OAAO,CAAC,mBAAmB,CAAC,WAAW,EAAE,MAAM,CAAC;AAChD,QAAA,OAAO,CAAC,mBAAmB,CAAC,eAAe,EAAE,MAAM,CAAC;AACtD,IAAA,CAAC;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
package/dist/index.d.cts CHANGED
@@ -64,40 +64,27 @@ type ArkSwipeOptions = {
64
64
  };
65
65
 
66
66
  /**
67
- * Animação FLIP: mede a posição dos elementos, aplica a mutação de DOM
68
- * (reordenar, inserir, filtrar) e anima cada item da posição antiga para
69
- * a nova com física de spring.
70
- * @param targets Os elementos a serem animados.
71
- * @param mutate A função que aplica a mutação de DOM.
72
- * @param options As opções de animação FLIP.
73
- * @returns Uma Promise que resolve quando todas as animações terminarem.
67
+ * Animação FLIP: mede a posição dos elementos, aplica a mutação de DOM (reordenar, inserir, filtrar) e anima cada
68
+ * item da posição antiga para a nova com física de spring. Resolve quando todas as animações terminam; com movimento
69
+ * reduzido só aplica a mutação.
74
70
  */
75
71
  declare function arkFlip(targets: ArkMotionTargets, mutate: () => void, options?: ArkFlipOptions): Promise<void>;
76
72
 
77
73
  /**
78
74
  * Scroll reveal: esconde os alvos e anima a entrada quando cada um aparece
79
75
  * na viewport. Retorna uma função de cleanup que para a observação.
80
- * @param targets Os elementos a serem observados.
81
- * @param options As opções de configuração do reveal.
82
- * @returns Uma função de cleanup que para a observação dos elementos.
83
76
  */
84
77
  declare function arkReveal(targets: ArkMotionTargets, options?: ArkRevealOptions): () => void;
85
78
 
86
79
  /**
87
80
  * Entrada escalonada de uma lista de elementos usando os motion tokens.
88
81
  * Resolve quando todos os itens terminam (imediatamente com reduced motion).
89
- * @param targets Os elementos a serem animados.
90
- * @param options As opções de configuração do stagger.
91
- * @returns Uma Promise que resolve quando todos os itens terminam a animação.
92
82
  */
93
83
  declare function arkStaggerEnter(targets: ArkMotionTargets, options?: ArkStaggerOptions): Promise<void>;
94
84
 
95
85
  /**
96
86
  * Gesto de swipe com feedback visual e retorno com física de spring.
97
87
  * Retorna uma função de cleanup que remove os listeners.
98
- * @param element O elemento HTML que receberá o gesto de swipe.
99
- * @param options As opções de configuração do swipe, incluindo eixo, limiar, resistência e callback.
100
- * @returns Uma função de cleanup que remove os listeners.
101
88
  */
102
89
  declare function arkSwipe(element: HTMLElement, options: ArkSwipeOptions): () => void;
103
90
 
package/dist/index.d.ts CHANGED
@@ -64,40 +64,27 @@ type ArkSwipeOptions = {
64
64
  };
65
65
 
66
66
  /**
67
- * Animação FLIP: mede a posição dos elementos, aplica a mutação de DOM
68
- * (reordenar, inserir, filtrar) e anima cada item da posição antiga para
69
- * a nova com física de spring.
70
- * @param targets Os elementos a serem animados.
71
- * @param mutate A função que aplica a mutação de DOM.
72
- * @param options As opções de animação FLIP.
73
- * @returns Uma Promise que resolve quando todas as animações terminarem.
67
+ * Animação FLIP: mede a posição dos elementos, aplica a mutação de DOM (reordenar, inserir, filtrar) e anima cada
68
+ * item da posição antiga para a nova com física de spring. Resolve quando todas as animações terminam; com movimento
69
+ * reduzido só aplica a mutação.
74
70
  */
75
71
  declare function arkFlip(targets: ArkMotionTargets, mutate: () => void, options?: ArkFlipOptions): Promise<void>;
76
72
 
77
73
  /**
78
74
  * Scroll reveal: esconde os alvos e anima a entrada quando cada um aparece
79
75
  * na viewport. Retorna uma função de cleanup que para a observação.
80
- * @param targets Os elementos a serem observados.
81
- * @param options As opções de configuração do reveal.
82
- * @returns Uma função de cleanup que para a observação dos elementos.
83
76
  */
84
77
  declare function arkReveal(targets: ArkMotionTargets, options?: ArkRevealOptions): () => void;
85
78
 
86
79
  /**
87
80
  * Entrada escalonada de uma lista de elementos usando os motion tokens.
88
81
  * Resolve quando todos os itens terminam (imediatamente com reduced motion).
89
- * @param targets Os elementos a serem animados.
90
- * @param options As opções de configuração do stagger.
91
- * @returns Uma Promise que resolve quando todos os itens terminam a animação.
92
82
  */
93
83
  declare function arkStaggerEnter(targets: ArkMotionTargets, options?: ArkStaggerOptions): Promise<void>;
94
84
 
95
85
  /**
96
86
  * Gesto de swipe com feedback visual e retorno com física de spring.
97
87
  * Retorna uma função de cleanup que remove os listeners.
98
- * @param element O elemento HTML que receberá o gesto de swipe.
99
- * @param options As opções de configuração do swipe, incluindo eixo, limiar, resistência e callback.
100
- * @returns Uma função de cleanup que remove os listeners.
101
88
  */
102
89
  declare function arkSwipe(element: HTMLElement, options: ArkSwipeOptions): () => void;
103
90
 
package/dist/index.js CHANGED
@@ -2,11 +2,7 @@ import { animate, stagger, inView } from 'motion';
2
2
  export { animate, hover, inView, press, scroll, spring, stagger } from 'motion';
3
3
  import { ARK_MOTION_DISTANCE, prefersReducedMotion, ARK_DURATION_MS } from '@tooark/core';
4
4
 
5
- /**
6
- * Curvas dos tokens --ark-ease-* no formato aceito pela lib Motion (linear = bezier identidade).
7
- * @remarks As curvas são definidas como arrays de quatro números representando os pontos de controle
8
- * da função bezier cúbica.
9
- */
5
+ /** Curvas dos tokens --ark-ease-* nos quatro pontos de cubic-bezier que a lib Motion aceita (linear = identidade). */
10
6
  const ARK_EASE_BEZIER = {
11
7
  linear: [0, 0, 1, 1],
12
8
  standard: [0.2, 0, 0, 1],
@@ -16,11 +12,31 @@ const ARK_EASE_BEZIER = {
16
12
  overshoot: [0.34, 1.56, 0.64, 1],
17
13
  sheet: [0.32, 0.72, 0, 1]
18
14
  };
19
- /**
20
- * Normaliza seletor, elemento, array ou NodeList numa lista de HTMLElement.
21
- * @param targets O(s) alvo(s) a serem normalizados.
22
- * @returns Uma lista de elementos HTML.
23
- */
15
+ /** Valor de uma custom property (token --ark-*) no elemento, ou "" sem elemento ou fora do navegador. */
16
+ function readToken(element, name) {
17
+ if (!element || typeof getComputedStyle !== "function")
18
+ return "";
19
+ return getComputedStyle(element).getPropertyValue(name).trim();
20
+ }
21
+ /** "250ms" ou "0.25s" em milissegundos; null para qualquer outra coisa. */
22
+ function parseCssDurationMs(value) {
23
+ const match = /^(-?\d*\.?\d+)(ms|s)$/.exec(value);
24
+ if (!match)
25
+ return null;
26
+ const amount = Number(match[1]);
27
+ return match[2] === "s" ? amount * 1000 : amount;
28
+ }
29
+ /** "cubic-bezier(a, b, c, d)" ou "linear" como os quatro pontos que a lib Motion aceita; null para o resto. */
30
+ function parseCubicBezier(value) {
31
+ if (value === "linear")
32
+ return [0, 0, 1, 1];
33
+ const match = /^cubic-bezier\(([^)]+)\)$/.exec(value);
34
+ if (!match)
35
+ return null;
36
+ const points = match[1].split(",").map((part) => Number(part.trim()));
37
+ return points.length === 4 && points.every(Number.isFinite) ? points : null;
38
+ }
39
+ /** Normaliza seletor, elemento, array ou NodeList numa lista de HTMLElement (vazia sem document, como no SSR). */
24
40
  function resolveTargets(targets) {
25
41
  // Verifica se o alvo é uma string (seletor CSS) e resolve os elementos correspondentes.
26
42
  if (typeof targets === "string") {
@@ -39,12 +55,11 @@ function resolveTargets(targets) {
39
55
  return Array.from(targets).filter((el) => el instanceof HTMLElement);
40
56
  }
41
57
  /**
42
- * Resolve a duração em segundos a partir de um valor em milissegundos ou token ArkDuration.
43
- * @param duration A duração desejada em milissegundos ou como token ArkDuration.
44
- * @param fallback O token ArkDuration a ser usado caso duration não seja fornecido.
45
- * @returns A duração em segundos, respeitando a preferência de redução de movimento.
58
+ * Resolve a duração em segundos a partir de um valor em milissegundos ou token ArkDuration (`fallback` quando
59
+ * `duration` falta); 0 com movimento reduzido. O token vem da página (--ark-duration-* no elemento) e cai no espelho
60
+ * JS quando o CSS da lib não está carregado.
46
61
  */
47
- function resolveDurationSec(duration, fallback) {
62
+ function resolveDurationSec(element, duration, fallback) {
48
63
  // Retorna 0 se o usuário preferir animações reduzidas.
49
64
  if (prefersReducedMotion()) {
50
65
  return 0;
@@ -53,35 +68,33 @@ function resolveDurationSec(duration, fallback) {
53
68
  if (typeof duration === "number") {
54
69
  return Math.max(0, duration) / 1000;
55
70
  }
56
- // Converte o token ArkDuration em milissegundos e depois para segundos.
57
- return ARK_DURATION_MS[duration ?? fallback] / 1000;
71
+ // Token: o valor da página, senão o espelho JS; depois para segundos.
72
+ const token = duration ?? fallback;
73
+ return (parseCssDurationMs(readToken(element, `--ark-duration-${token}`)) ?? ARK_DURATION_MS[token]) / 1000;
58
74
  }
59
75
  /**
60
- * Resolve a curva de animação a partir de um token ArkEasing, array bezier ou nome.
61
- * @param ease A curva desejada como token ArkEasing, array bezier ou nome.
62
- * @returns A curva de animação correspondente, padrão: token out.
76
+ * Resolve a curva de animação a partir de um token ArkEasing, array bezier ou nome; sem valor, o token out. O token
77
+ * vem da página (--ark-ease-* no elemento) e cai no espelho JS quando o CSS da lib não está carregado.
63
78
  */
64
- function resolveEase(ease) {
65
- // Retorna a curva de animação correspondente, padrão: token out.
79
+ function resolveEase(element, ease) {
66
80
  if (Array.isArray(ease)) {
67
81
  return ease;
68
82
  }
69
- // Verifica se o ease é uma string correspondente a um token ArkEasing.
70
- if (typeof ease === "string" && ease in ARK_EASE_BEZIER) {
71
- return ARK_EASE_BEZIER[ease];
83
+ // Token (ou nenhum valor, que é o token out): a curva da página, senão o espelho JS.
84
+ const token = ease === undefined ? "out" : ease in ARK_EASE_BEZIER ? ease : null;
85
+ if (token) {
86
+ return parseCubicBezier(readToken(element, `--ark-ease-${token}`)) ?? ARK_EASE_BEZIER[token];
72
87
  }
73
- // Retorna a curva de animação padrão caso nenhum valor válido seja fornecido.
74
- return ease ?? ARK_EASE_BEZIER.out;
88
+ // Nome próprio da lib Motion ("easeInOut"...), repassado como veio.
89
+ return ease;
75
90
  }
76
91
  /**
77
- * Converte a distância CSS ("0.75rem", "24px") para px.
78
- * @param element O elemento HTML de referência para unidades relativas (em).
79
- * @param distance A distância desejada como string CSS.
80
- * @returns A distância em pixels.
92
+ * Converte a distância CSS ("0.75rem", "24px") para px: a pedida, senão --ark-motion-distance da página, senão o
93
+ * espelho JS. rem segue a fonte da raiz, em a do elemento, e um valor não numérico vira 12.
81
94
  */
82
95
  function resolveDistancePx(element, distance) {
83
- // Usa a distância fornecida ou o valor padrão ARK_MOTION_DISTANCE.
84
- const value = distance || ARK_MOTION_DISTANCE;
96
+ // A distância pedida, senão o token da página (--ark-motion-distance), senão o espelho JS.
97
+ const value = distance || readToken(element, "--ark-motion-distance") || ARK_MOTION_DISTANCE;
85
98
  const amount = Number.parseFloat(value);
86
99
  // Retorna um valor padrão caso a distância não seja um número finito.
87
100
  if (!Number.isFinite(amount)) {
@@ -100,12 +113,7 @@ function resolveDistancePx(element, distance) {
100
113
  }
101
114
  return amount;
102
115
  }
103
- /**
104
- * Offset inicial (x/y/scale) do estado oculto de cada preset.
105
- * @param preset O preset de animação desejado.
106
- * @param distancePx A distância em pixels para o deslocamento.
107
- * @returns Um objeto contendo os offsets iniciais (x/y/scale) correspondentes.
108
- */
116
+ /** Offset inicial (x/y/scale) do estado oculto de cada preset, com a distância em px nos presets de slide. */
109
117
  function hiddenOffset(preset, distancePx) {
110
118
  // Determina o offset inicial com base no preset de animação.
111
119
  if (preset === "slide-up") {
@@ -127,13 +135,9 @@ function hiddenOffset(preset, distancePx) {
127
135
  }
128
136
 
129
137
  /**
130
- * Animação FLIP: mede a posição dos elementos, aplica a mutação de DOM
131
- * (reordenar, inserir, filtrar) e anima cada item da posição antiga para
132
- * a nova com física de spring.
133
- * @param targets Os elementos a serem animados.
134
- * @param mutate A função que aplica a mutação de DOM.
135
- * @param options As opções de animação FLIP.
136
- * @returns Uma Promise que resolve quando todas as animações terminarem.
138
+ * Animação FLIP: mede a posição dos elementos, aplica a mutação de DOM (reordenar, inserir, filtrar) e anima cada
139
+ * item da posição antiga para a nova com física de spring. Resolve quando todas as animações terminam; com movimento
140
+ * reduzido só aplica a mutação.
137
141
  */
138
142
  async function arkFlip(targets, mutate, options = {}) {
139
143
  // Resolve os elementos alvo da animação.
@@ -193,9 +197,6 @@ async function arkFlip(targets, mutate, options = {}) {
193
197
  /**
194
198
  * Entrada escalonada de uma lista de elementos usando os motion tokens.
195
199
  * Resolve quando todos os itens terminam (imediatamente com reduced motion).
196
- * @param targets Os elementos a serem animados.
197
- * @param options As opções de configuração do stagger.
198
- * @returns Uma Promise que resolve quando todos os itens terminam a animação.
199
200
  */
200
201
  async function arkStaggerEnter(targets, options = {}) {
201
202
  // Resolve os elementos de destino para garantir que estamos lidando com uma lista de elementos.
@@ -231,8 +232,8 @@ async function arkStaggerEnter(targets, options = {}) {
231
232
  }
232
233
  // Aplica a animação aos elementos com os keyframes e as opções de stagger.
233
234
  await animate(elements, keyframes, {
234
- duration: resolveDurationSec(options.duration, "default"),
235
- ease: resolveEase(options.ease),
235
+ duration: resolveDurationSec(elements[0], options.duration, "default"),
236
+ ease: resolveEase(elements[0], options.ease),
236
237
  delay: stagger((options.interval ?? 60) / 1000, { from: options.from ?? "first" })
237
238
  });
238
239
  }
@@ -240,9 +241,6 @@ async function arkStaggerEnter(targets, options = {}) {
240
241
  /**
241
242
  * Scroll reveal: esconde os alvos e anima a entrada quando cada um aparece
242
243
  * na viewport. Retorna uma função de cleanup que para a observação.
243
- * @param targets Os elementos a serem observados.
244
- * @param options As opções de configuração do reveal.
245
- * @returns Uma função de cleanup que para a observação dos elementos.
246
244
  */
247
245
  function arkReveal(targets, options = {}) {
248
246
  // Resolve os elementos de destino para garantir que estamos lidando com uma lista de elementos.
@@ -284,9 +282,6 @@ function arkReveal(targets, options = {}) {
284
282
  /**
285
283
  * Gesto de swipe com feedback visual e retorno com física de spring.
286
284
  * Retorna uma função de cleanup que remove os listeners.
287
- * @param element O elemento HTML que receberá o gesto de swipe.
288
- * @param options As opções de configuração do swipe, incluindo eixo, limiar, resistência e callback.
289
- * @returns Uma função de cleanup que remove os listeners.
290
285
  */
291
286
  function arkSwipe(element, options) {
292
287
  const axis = options.axis ?? "x";
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../src/internal.ts","../src/flip.ts","../src/stagger.ts","../src/reveal.ts","../src/swipe.ts"],"sourcesContent":["import type { ArkDuration, ArkEasing, ArkMotionPreset } from \"@tooark/core\";\nimport { ARK_DURATION_MS, ARK_MOTION_DISTANCE, prefersReducedMotion } from \"@tooark/core\";\nimport type { ArkMotionTargets } from \"./types\";\n\n/**\n * Curvas dos tokens --ark-ease-* no formato aceito pela lib Motion (linear = bezier identidade).\n * @remarks As curvas são definidas como arrays de quatro números representando os pontos de controle\n * da função bezier cúbica.\n */\nexport const ARK_EASE_BEZIER: Record<ArkEasing, [number, number, number, number]> = {\n linear: [0, 0, 1, 1],\n standard: [0.2, 0, 0, 1],\n in: [0.4, 0, 1, 1],\n out: [0, 0, 0.2, 1],\n \"in-out\": [0.4, 0, 0.2, 1],\n overshoot: [0.34, 1.56, 0.64, 1],\n sheet: [0.32, 0.72, 0, 1]\n};\n\n/**\n * Normaliza seletor, elemento, array ou NodeList numa lista de HTMLElement.\n * @param targets O(s) alvo(s) a serem normalizados.\n * @returns Uma lista de elementos HTML.\n */\nexport function resolveTargets(targets: ArkMotionTargets): HTMLElement[] {\n // Verifica se o alvo é uma string (seletor CSS) e resolve os elementos correspondentes.\n if (typeof targets === \"string\") {\n // Se o documento não estiver disponível (ex: SSR), retorna uma lista vazia.\n if (typeof document === \"undefined\") {\n return [];\n }\n\n // Seleciona todos os elementos correspondentes ao seletor CSS.\n return Array.from(document.querySelectorAll<HTMLElement>(targets));\n }\n\n // Verifica se o alvo é um único elemento e o encapsula em um array.\n if (targets instanceof Element) {\n return targets instanceof HTMLElement ? [targets] : [];\n }\n\n // Assume que o alvo é um array ou NodeList e filtra apenas os elementos HTML.\n return Array.from(targets).filter((el): el is HTMLElement => el instanceof HTMLElement);\n}\n\n/**\n * Resolve a duração em segundos a partir de um valor em milissegundos ou token ArkDuration.\n * @param duration A duração desejada em milissegundos ou como token ArkDuration.\n * @param fallback O token ArkDuration a ser usado caso duration não seja fornecido.\n * @returns A duração em segundos, respeitando a preferência de redução de movimento.\n */\nexport function resolveDurationSec(duration: ArkDuration | number | undefined, fallback: ArkDuration): number {\n // Retorna 0 se o usuário preferir animações reduzidas.\n if (prefersReducedMotion()) {\n return 0;\n }\n\n // Garante que a duração seja um número válido em segundos.\n if (typeof duration === \"number\") {\n return Math.max(0, duration) / 1000;\n }\n\n // Converte o token ArkDuration em milissegundos e depois para segundos.\n return ARK_DURATION_MS[duration ?? fallback] / 1000;\n}\n\n/**\n * Resolve a curva de animação a partir de um token ArkEasing, array bezier ou nome.\n * @param ease A curva desejada como token ArkEasing, array bezier ou nome.\n * @returns A curva de animação correspondente, padrão: token out.\n */\nexport function resolveEase(ease: ArkEasing | number[] | string | undefined): number[] | string {\n // Retorna a curva de animação correspondente, padrão: token out.\n if (Array.isArray(ease)) {\n return ease;\n }\n\n // Verifica se o ease é uma string correspondente a um token ArkEasing.\n if (typeof ease === \"string\" && ease in ARK_EASE_BEZIER) {\n return ARK_EASE_BEZIER[ease as ArkEasing];\n }\n\n // Retorna a curva de animação padrão caso nenhum valor válido seja fornecido.\n return ease ?? ARK_EASE_BEZIER.out;\n}\n\n/**\n * Converte a distância CSS (\"0.75rem\", \"24px\") para px.\n * @param element O elemento HTML de referência para unidades relativas (em).\n * @param distance A distância desejada como string CSS.\n * @returns A distância em pixels.\n */\nexport function resolveDistancePx(element: HTMLElement | undefined, distance?: string): number {\n // Usa a distância fornecida ou o valor padrão ARK_MOTION_DISTANCE.\n const value = distance || ARK_MOTION_DISTANCE;\n const amount = Number.parseFloat(value);\n\n // Retorna um valor padrão caso a distância não seja um número finito.\n if (!Number.isFinite(amount)) {\n return 12;\n }\n\n // Converte a distância para pixels com base na unidade CSS.\n if (value.endsWith(\"rem\")) {\n // Obtém o tamanho da fonte raiz (root) para conversão de rem para px.\n const rootSize =\n typeof document !== \"undefined\" ? Number.parseFloat(getComputedStyle(document.documentElement).fontSize) : 16;\n\n return amount * (rootSize || 16);\n }\n\n // Converte a distância para pixels caso a unidade seja px (padrão) ou não especificada.\n if (value.endsWith(\"em\") && element) {\n // Obtém o tamanho da fonte do elemento para conversão de em para px.\n return amount * (Number.parseFloat(getComputedStyle(element).fontSize) || 16);\n }\n\n return amount;\n}\n\n/**\n * Offset inicial (x/y/scale) do estado oculto de cada preset.\n * @param preset O preset de animação desejado.\n * @param distancePx A distância em pixels para o deslocamento.\n * @returns Um objeto contendo os offsets iniciais (x/y/scale) correspondentes.\n */\nexport function hiddenOffset(preset: ArkMotionPreset, distancePx: number): { x?: number; y?: number; scale?: number } {\n // Determina o offset inicial com base no preset de animação.\n if (preset === \"slide-up\") {\n return { y: distancePx };\n }\n if (preset === \"slide-down\") {\n return { y: -distancePx };\n }\n if (preset === \"slide-left\") {\n return { x: -distancePx };\n }\n if (preset === \"slide-right\") {\n return { x: distancePx };\n }\n if (preset === \"scale\") {\n return { scale: 0.95 };\n }\n\n return {};\n}\n","import { prefersReducedMotion } from \"@tooark/core\";\nimport { animate } from \"motion\";\nimport { resolveTargets } from \"./internal\";\nimport type { ArkFlipOptions, ArkMotionTargets } from \"./types\";\n\n/**\n * Animação FLIP: mede a posição dos elementos, aplica a mutação de DOM\n * (reordenar, inserir, filtrar) e anima cada item da posição antiga para\n * a nova com física de spring.\n * @param targets Os elementos a serem animados.\n * @param mutate A função que aplica a mutação de DOM.\n * @param options As opções de animação FLIP.\n * @returns Uma Promise que resolve quando todas as animações terminarem.\n */\nexport async function arkFlip(\n targets: ArkMotionTargets,\n mutate: () => void,\n options: ArkFlipOptions = {}\n): Promise<void> {\n // Resolve os elementos alvo da animação.\n const elements = resolveTargets(targets);\n\n // Se não houver elementos ou se o usuário preferir animações reduzidas, aplica a mutação e retorna.\n if (elements.length === 0 || prefersReducedMotion()) {\n mutate();\n return;\n }\n\n // Mapa para armazenar a posição inicial de cada elemento.\n const first = new Map<HTMLElement, DOMRect>();\n\n // Captura a posição inicial de cada elemento.\n for (const el of elements) {\n first.set(el, el.getBoundingClientRect());\n }\n\n // Aplica a mutação de DOM para que possamos medir a nova posição dos elementos.\n mutate();\n\n // Captura a posição final de cada elemento após a mutação.\n const animations: Array<Promise<unknown>> = [];\n\n // Itera sobre cada elemento para calcular a diferença de posição e criar as animações.\n for (const el of elements) {\n // Pega a posição inicial do elemento antes da mutação.\n const before = first.get(el);\n\n // Se não houver posição inicial ou o elemento não estiver mais conectado ao DOM, pula a animação.\n if (!before || !el.isConnected) {\n continue;\n }\n\n // Captura a posição final do elemento após a mutação.\n const after = el.getBoundingClientRect();\n\n // Calcula a diferença de posição entre a posição inicial e final.\n const dx = before.left - after.left;\n const dy = before.top - after.top;\n\n // Se não houver diferença de posição, pula a animação.\n if (dx === 0 && dy === 0) {\n continue;\n }\n\n // Cria os keyframes para a animação com base na diferença de posição.\n const keyframes: Record<string, [number, number]> = {};\n\n // Adiciona os keyframes apenas se houver diferença de posição em x ou y.\n if (dx !== 0) {\n keyframes.x = [dx, 0];\n }\n if (dy !== 0) {\n keyframes.y = [dy, 0];\n }\n\n // Adiciona a animação à lista de animações a serem aguardadas.\n animations.push(\n Promise.resolve(\n animate(el, keyframes, {\n type: \"spring\",\n stiffness: options.stiffness ?? 350,\n damping: options.damping ?? 32\n })\n )\n );\n }\n\n // Aguarda todas as animações terminarem antes de continuar.\n await Promise.all(animations);\n}\n","import { prefersReducedMotion } from \"@tooark/core\";\nimport { animate, stagger } from \"motion\";\nimport { hiddenOffset, resolveDistancePx, resolveDurationSec, resolveEase, resolveTargets } from \"./internal\";\nimport type { ArkMotionTargets, ArkStaggerOptions } from \"./types\";\n\n/**\n * Entrada escalonada de uma lista de elementos usando os motion tokens.\n * Resolve quando todos os itens terminam (imediatamente com reduced motion).\n * @param targets Os elementos a serem animados.\n * @param options As opções de configuração do stagger.\n * @returns Uma Promise que resolve quando todos os itens terminam a animação.\n */\nexport async function arkStaggerEnter(targets: ArkMotionTargets, options: ArkStaggerOptions = {}): Promise<void> {\n // Resolve os elementos de destino para garantir que estamos lidando com uma lista de elementos.\n const elements = resolveTargets(targets);\n\n // Retorna imediatamente se não houver elementos para animar.\n if (elements.length === 0) {\n return;\n }\n\n // Retorna imediatamente se o usuário preferir animações reduzidas.\n if (prefersReducedMotion()) {\n // Remove qualquer estilo de opacidade e transformação aplicado anteriormente.\n for (const el of elements) {\n el.style.opacity = \"\";\n el.style.transform = \"\";\n }\n\n return;\n }\n\n // Determina o preset de animação, a distância em pixels e o deslocamento inicial com base no preset.\n const preset = options.preset ?? \"slide-up\";\n const distancePx = resolveDistancePx(elements[0], options.distance);\n const offset = hiddenOffset(preset, distancePx);\n\n // Cria os keyframes iniciais para a animação com base no deslocamento calculado.\n const keyframes: Record<string, [number, number]> = { opacity: [0, 1] };\n\n // Adiciona os keyframes de transformação com base no deslocamento calculado.\n if (offset.x !== undefined) {\n keyframes.x = [offset.x, 0];\n }\n if (offset.y !== undefined) {\n keyframes.y = [offset.y, 0];\n }\n if (offset.scale !== undefined) {\n keyframes.scale = [offset.scale, 1];\n }\n\n // Aplica a animação aos elementos com os keyframes e as opções de stagger.\n await animate(elements, keyframes, {\n duration: resolveDurationSec(options.duration, \"default\"),\n ease: resolveEase(options.ease) as never,\n delay: stagger((options.interval ?? 60) / 1000, { from: options.from ?? \"first\" })\n });\n}\n","import { prefersReducedMotion } from \"@tooark/core\";\nimport { inView } from \"motion\";\nimport { resolveTargets } from \"./internal\";\nimport { arkStaggerEnter } from \"./stagger\";\nimport type { ArkMotionTargets, ArkRevealOptions } from \"./types\";\n\n/**\n * Scroll reveal: esconde os alvos e anima a entrada quando cada um aparece\n * na viewport. Retorna uma função de cleanup que para a observação.\n * @param targets Os elementos a serem observados.\n * @param options As opções de configuração do reveal.\n * @returns Uma função de cleanup que para a observação dos elementos.\n */\nexport function arkReveal(targets: ArkMotionTargets, options: ArkRevealOptions = {}): () => void {\n // Resolve os elementos de destino para garantir que estamos lidando com uma lista de elementos.\n const elements = resolveTargets(targets);\n\n // Retorna imediatamente se não houver elementos para observar ou se o usuário preferir animações reduzidas.\n if (elements.length === 0 || prefersReducedMotion()) {\n return () => undefined;\n }\n\n // Define se a animação deve ocorrer apenas uma vez.\n const once = options.once ?? true;\n const stops: Array<() => void> = [];\n\n // Inicializa a lista de funções de cleanup para cada elemento observado.\n for (const el of elements) {\n el.style.opacity = \"0\";\n el.style.willChange = \"opacity, transform\";\n\n // Configura a observação do elemento usando a função inView. O `once` é do próprio inView: sem cleanup\n // devolvido ele para de observar o elemento depois da primeira entrada, então o callback não roda de novo.\n const stop = inView(\n el,\n () => {\n el.style.opacity = \"\";\n void arkStaggerEnter([el], { ...options, interval: 0 });\n\n if (!once) {\n // Cleanup ao sair da viewport: re-esconde para animar de novo\n return () => {\n el.style.opacity = \"0\";\n };\n }\n return undefined;\n },\n { amount: options.amount ?? 0.25, margin: options.margin as never }\n );\n\n // Adiciona a função de cleanup do elemento à lista de stops.\n stops.push(stop);\n }\n\n // Retorna uma função de cleanup que chama todas as funções de stop armazenadas.\n return () => {\n for (const stop of stops) stop();\n };\n}\n","import { prefersReducedMotion } from \"@tooark/core\";\nimport { animate } from \"motion\";\nimport type { ArkSwipeDirection, ArkSwipeOptions } from \"./types\";\n\n/**\n * Gesto de swipe com feedback visual e retorno com física de spring.\n * Retorna uma função de cleanup que remove os listeners.\n * @param element O elemento HTML que receberá o gesto de swipe.\n * @param options As opções de configuração do swipe, incluindo eixo, limiar, resistência e callback.\n * @returns Uma função de cleanup que remove os listeners.\n */\nexport function arkSwipe(element: HTMLElement, options: ArkSwipeOptions): () => void {\n const axis = options.axis ?? \"x\";\n const threshold = options.threshold ?? 48;\n const velocityThreshold = options.velocityThreshold ?? 500;\n const feedback = options.feedback ?? true;\n const resistance = Math.min(1, Math.max(0, options.resistance ?? 0.4));\n\n let pointerId: number | null = null;\n let startPos = 0;\n let delta = 0;\n let lastPos = 0;\n let lastTime = 0;\n let velocity = 0;\n\n // Lê a posição atual do ponteiro com base no eixo configurado.\n const readPos = (event: PointerEvent): number => (axis === \"x\" ? event.clientX : event.clientY);\n\n // Aplica o feedback visual de swipe enquanto o usuário arrasta o elemento.\n const applyFeedback = (value: number): void => {\n // Se o feedback visual estiver desativado, não aplica a transformação.\n if (!feedback) {\n return;\n }\n\n // Aplica a resistência ao valor do swipe.\n const damped = value * (1 - resistance);\n\n // Atualiza a transformação do elemento com base no valor amortecido.\n element.style.transform = axis === \"x\" ? `translateX(${damped}px)` : `translateY(${damped}px)`;\n };\n\n // Anima o elemento de volta à posição original com física de spring.\n const springBack = (): void => {\n // Se o feedback visual estiver desativado, não aplica a animação de retorno.\n if (!feedback) {\n return;\n }\n\n // Remove a transformação do elemento antes de aplicar a animação de retorno.\n element.style.transform = \"\";\n\n // Se o usuário preferir animações reduzidas, não aplica a animação de retorno.\n if (prefersReducedMotion()) {\n return;\n }\n\n // Calcula o valor amortecido com base na resistência configurada.\n const damped = delta * (1 - resistance);\n\n // Cria os keyframes para a animação de retorno com base no valor amortecido.\n const keyframes = axis === \"x\" ? { x: [damped, 0] } : { y: [damped, 0] };\n\n // Aplica a animação de retorno usando a biblioteca de animação.\n animate(element, keyframes as never, {\n type: \"spring\",\n stiffness: 420,\n damping: 34,\n velocity: -velocity * (1 - resistance)\n });\n };\n\n // Manipulador de evento para quando o ponteiro é pressionado.\n const onPointerDown = (event: PointerEvent): void => {\n // Ignora o evento se já houver um ponteiro ativo ou se o ponteiro não for primário.\n if (pointerId !== null || !event.isPrimary) {\n return;\n }\n\n pointerId = event.pointerId;\n startPos = lastPos = readPos(event);\n lastTime = event.timeStamp;\n delta = 0;\n velocity = 0;\n element.setPointerCapture(event.pointerId);\n };\n\n // Manipulador de evento para quando o ponteiro é movido.\n const onPointerMove = (event: PointerEvent): void => {\n // Ignora o evento se o ponteiro não for o ativo.\n if (event.pointerId !== pointerId) {\n return;\n }\n\n // Calcula a posição atual do ponteiro e o tempo decorrido desde o último evento.\n const pos = readPos(event);\n const elapsed = event.timeStamp - lastTime;\n\n // Calcula a velocidade do ponteiro com base na mudança de posição e no tempo decorrido.\n if (elapsed > 0) {\n velocity = ((pos - lastPos) / elapsed) * 1000;\n }\n\n // Atualiza a posição e o tempo do último evento para o próximo cálculo de velocidade.\n lastPos = pos;\n lastTime = event.timeStamp;\n delta = pos - startPos;\n\n // Aplica o feedback visual com base no deslocamento atual.\n applyFeedback(delta);\n };\n\n // Manipulador de evento para quando o ponteiro é liberado ou cancelado.\n const finish = (event: PointerEvent): void => {\n // Ignora o evento se o ponteiro não for o ativo.\n if (event.pointerId !== pointerId) {\n return;\n }\n\n // Libera o ponteiro e redefine o estado interno.\n pointerId = null;\n element.releasePointerCapture(event.pointerId);\n\n // Determina se o gesto de swipe foi acionado com base no deslocamento e na velocidade.\n const triggered = Math.abs(delta) >= threshold || Math.abs(velocity) >= velocityThreshold;\n\n // Aciona o callback de swipe se o gesto foi detectado e o deslocamento não for zero.\n if (triggered && delta !== 0) {\n const direction: ArkSwipeDirection = axis === \"x\" ? (delta < 0 ? \"left\" : \"right\") : delta < 0 ? \"up\" : \"down\";\n options.onSwipe(direction, { delta, velocity });\n }\n\n // Restaura o elemento à sua posição original usando a animação de spring back.\n springBack();\n delta = 0;\n };\n\n // Armazena a ação de toque anterior e define a ação de toque apropriada para o eixo do swipe.\n const previousTouchAction = element.style.touchAction;\n element.style.touchAction = axis === \"x\" ? \"pan-y\" : \"pan-x\";\n\n // Adiciona os manipuladores de eventos para o ponteiro.\n element.addEventListener(\"pointerdown\", onPointerDown);\n element.addEventListener(\"pointermove\", onPointerMove);\n element.addEventListener(\"pointerup\", finish);\n element.addEventListener(\"pointercancel\", finish);\n\n // Retorna uma função de limpeza que remove os manipuladores de eventos e restaura a ação de toque original.\n return () => {\n element.style.touchAction = previousTouchAction;\n element.removeEventListener(\"pointerdown\", onPointerDown);\n element.removeEventListener(\"pointermove\", onPointerMove);\n element.removeEventListener(\"pointerup\", finish);\n element.removeEventListener(\"pointercancel\", finish);\n };\n}\n"],"names":[],"mappings":";;;;AAIA;;;;AAIG;AACI,MAAM,eAAe,GAAwD;IAClF,MAAM,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;IACpB,QAAQ,EAAE,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;IACxB,EAAE,EAAE,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;IAClB,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC;IACnB,QAAQ,EAAE,CAAC,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC;IAC1B,SAAS,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;IAChC,KAAK,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;CACzB;AAED;;;;AAIG;AACG,SAAU,cAAc,CAAC,OAAyB,EAAA;;AAEtD,IAAA,IAAI,OAAO,OAAO,KAAK,QAAQ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E,QAAQ,EAAE,CAAC;QACjD;;AAGA,QAAA,UAAU,EAAE;QACZ,KAAK,GAAG,CAAC;AACX,IAAA,CAAC;;AAGD,IAAA,MAAM,mBAAmB,GAAG,OAAO,CAAC,KAAK,CAAC,WAAW;AACrD,IAAA,OAAO,CAAC,KAAK,CAAC,WAAW,GAAG,IAAI,KAAK,GAAG,GAAG,OAAO,GAAG,OAAO;;AAG5D,IAAA,OAAO,CAAC,gBAAgB,CAAC,aAAa,EAAE,aAAa,CAAC;AACtD,IAAA,OAAO,CAAC,gBAAgB,CAAC,aAAa,EAAE,aAAa,CAAC;AACtD,IAAA,OAAO,CAAC,gBAAgB,CAAC,WAAW,EAAE,MAAM,CAAC;AAC7C,IAAA,OAAO,CAAC,gBAAgB,CAAC,eAAe,EAAE,MAAM,CAAC;;AAGjD,IAAA,OAAO,MAAK;AACV,QAAA,OAAO,CAAC,KAAK,CAAC,WAAW,GAAG,mBAAmB;AAC/C,QAAA,OAAO,CAAC,mBAAmB,CAAC,aAAa,EAAE,aAAa,CAAC;AACzD,QAAA,OAAO,CAAC,mBAAmB,CAAC,aAAa,EAAE,aAAa,CAAC;AACzD,QAAA,OAAO,CAAC,mBAAmB,CAAC,WAAW,EAAE,MAAM,CAAC;AAChD,QAAA,OAAO,CAAC,mBAAmB,CAAC,eAAe,EAAE,MAAM,CAAC;AACtD,IAAA,CAAC;AACH;;"}
1
+ {"version":3,"file":"index.js","sources":["../src/internal.ts","../src/flip.ts","../src/stagger.ts","../src/reveal.ts","../src/swipe.ts"],"sourcesContent":["import type { ArkDuration, ArkEasing, ArkMotionPreset } from \"@tooark/core\";\nimport { ARK_DURATION_MS, ARK_MOTION_DISTANCE, prefersReducedMotion } from \"@tooark/core\";\nimport type { ArkMotionTargets } from \"./types\";\n\n/** Curvas dos tokens --ark-ease-* nos quatro pontos de cubic-bezier que a lib Motion aceita (linear = identidade). */\nexport const ARK_EASE_BEZIER: Record<ArkEasing, [number, number, number, number]> = {\n linear: [0, 0, 1, 1],\n standard: [0.2, 0, 0, 1],\n in: [0.4, 0, 1, 1],\n out: [0, 0, 0.2, 1],\n \"in-out\": [0.4, 0, 0.2, 1],\n overshoot: [0.34, 1.56, 0.64, 1],\n sheet: [0.32, 0.72, 0, 1]\n};\n\n/** Valor de uma custom property (token --ark-*) no elemento, ou \"\" sem elemento ou fora do navegador. */\nfunction readToken(element: Element | undefined, name: string): string {\n if (!element || typeof getComputedStyle !== \"function\") return \"\";\n return getComputedStyle(element).getPropertyValue(name).trim();\n}\n\n/** \"250ms\" ou \"0.25s\" em milissegundos; null para qualquer outra coisa. */\nfunction parseCssDurationMs(value: string): number | null {\n const match = /^(-?\\d*\\.?\\d+)(ms|s)$/.exec(value);\n if (!match) return null;\n const amount = Number(match[1]);\n return match[2] === \"s\" ? amount * 1000 : amount;\n}\n\n/** \"cubic-bezier(a, b, c, d)\" ou \"linear\" como os quatro pontos que a lib Motion aceita; null para o resto. */\nfunction parseCubicBezier(value: string): [number, number, number, number] | null {\n if (value === \"linear\") return [0, 0, 1, 1];\n const match = /^cubic-bezier\\(([^)]+)\\)$/.exec(value);\n if (!match) return null;\n const points = match[1].split(\",\").map((part) => Number(part.trim()));\n return points.length === 4 && points.every(Number.isFinite) ? (points as [number, number, number, number]) : null;\n}\n\n/** Normaliza seletor, elemento, array ou NodeList numa lista de HTMLElement (vazia sem document, como no SSR). */\nexport function resolveTargets(targets: ArkMotionTargets): HTMLElement[] {\n // Verifica se o alvo é uma string (seletor CSS) e resolve os elementos correspondentes.\n if (typeof targets === \"string\") {\n // Se o documento não estiver disponível (ex: SSR), retorna uma lista vazia.\n if (typeof document === \"undefined\") {\n return [];\n }\n\n // Seleciona todos os elementos correspondentes ao seletor CSS.\n return Array.from(document.querySelectorAll<HTMLElement>(targets));\n }\n\n // Verifica se o alvo é um único elemento e o encapsula em um array.\n if (targets instanceof Element) {\n return targets instanceof HTMLElement ? [targets] : [];\n }\n\n // Assume que o alvo é um array ou NodeList e filtra apenas os elementos HTML.\n return Array.from(targets).filter((el): el is HTMLElement => el instanceof HTMLElement);\n}\n\n/**\n * Resolve a duração em segundos a partir de um valor em milissegundos ou token ArkDuration (`fallback` quando\n * `duration` falta); 0 com movimento reduzido. O token vem da página (--ark-duration-* no elemento) e cai no espelho\n * JS quando o CSS da lib não está carregado.\n */\nexport function resolveDurationSec(\n element: Element | undefined,\n duration: ArkDuration | number | undefined,\n fallback: ArkDuration\n): number {\n // Retorna 0 se o usuário preferir animações reduzidas.\n if (prefersReducedMotion()) {\n return 0;\n }\n\n // Garante que a duração seja um número válido em segundos.\n if (typeof duration === \"number\") {\n return Math.max(0, duration) / 1000;\n }\n\n // Token: o valor da página, senão o espelho JS; depois para segundos.\n const token = duration ?? fallback;\n return (parseCssDurationMs(readToken(element, `--ark-duration-${token}`)) ?? ARK_DURATION_MS[token]) / 1000;\n}\n\n/**\n * Resolve a curva de animação a partir de um token ArkEasing, array bezier ou nome; sem valor, o token out. O token\n * vem da página (--ark-ease-* no elemento) e cai no espelho JS quando o CSS da lib não está carregado.\n */\nexport function resolveEase(\n element: Element | undefined,\n ease: ArkEasing | number[] | string | undefined\n): number[] | string {\n if (Array.isArray(ease)) {\n return ease;\n }\n\n // Token (ou nenhum valor, que é o token out): a curva da página, senão o espelho JS.\n const token = ease === undefined ? \"out\" : ease in ARK_EASE_BEZIER ? (ease as ArkEasing) : null;\n if (token) {\n return parseCubicBezier(readToken(element, `--ark-ease-${token}`)) ?? ARK_EASE_BEZIER[token];\n }\n\n // Nome próprio da lib Motion (\"easeInOut\"...), repassado como veio.\n return ease as string;\n}\n\n/**\n * Converte a distância CSS (\"0.75rem\", \"24px\") para px: a pedida, senão --ark-motion-distance da página, senão o\n * espelho JS. rem segue a fonte da raiz, em a do elemento, e um valor não numérico vira 12.\n */\nexport function resolveDistancePx(element: HTMLElement | undefined, distance?: string): number {\n // A distância pedida, senão o token da página (--ark-motion-distance), senão o espelho JS.\n const value = distance || readToken(element, \"--ark-motion-distance\") || ARK_MOTION_DISTANCE;\n const amount = Number.parseFloat(value);\n\n // Retorna um valor padrão caso a distância não seja um número finito.\n if (!Number.isFinite(amount)) {\n return 12;\n }\n\n // Converte a distância para pixels com base na unidade CSS.\n if (value.endsWith(\"rem\")) {\n // Obtém o tamanho da fonte raiz (root) para conversão de rem para px.\n const rootSize =\n typeof document !== \"undefined\" ? Number.parseFloat(getComputedStyle(document.documentElement).fontSize) : 16;\n\n return amount * (rootSize || 16);\n }\n\n // Converte a distância para pixels caso a unidade seja px (padrão) ou não especificada.\n if (value.endsWith(\"em\") && element) {\n // Obtém o tamanho da fonte do elemento para conversão de em para px.\n return amount * (Number.parseFloat(getComputedStyle(element).fontSize) || 16);\n }\n\n return amount;\n}\n\n/** Offset inicial (x/y/scale) do estado oculto de cada preset, com a distância em px nos presets de slide. */\nexport function hiddenOffset(preset: ArkMotionPreset, distancePx: number): { x?: number; y?: number; scale?: number } {\n // Determina o offset inicial com base no preset de animação.\n if (preset === \"slide-up\") {\n return { y: distancePx };\n }\n if (preset === \"slide-down\") {\n return { y: -distancePx };\n }\n if (preset === \"slide-left\") {\n return { x: -distancePx };\n }\n if (preset === \"slide-right\") {\n return { x: distancePx };\n }\n if (preset === \"scale\") {\n return { scale: 0.95 };\n }\n\n return {};\n}\n","import { prefersReducedMotion } from \"@tooark/core\";\nimport { animate } from \"motion\";\nimport { resolveTargets } from \"./internal\";\nimport type { ArkFlipOptions, ArkMotionTargets } from \"./types\";\n\n/**\n * Animação FLIP: mede a posição dos elementos, aplica a mutação de DOM (reordenar, inserir, filtrar) e anima cada\n * item da posição antiga para a nova com física de spring. Resolve quando todas as animações terminam; com movimento\n * reduzido só aplica a mutação.\n */\nexport async function arkFlip(\n targets: ArkMotionTargets,\n mutate: () => void,\n options: ArkFlipOptions = {}\n): Promise<void> {\n // Resolve os elementos alvo da animação.\n const elements = resolveTargets(targets);\n\n // Se não houver elementos ou se o usuário preferir animações reduzidas, aplica a mutação e retorna.\n if (elements.length === 0 || prefersReducedMotion()) {\n mutate();\n return;\n }\n\n // Mapa para armazenar a posição inicial de cada elemento.\n const first = new Map<HTMLElement, DOMRect>();\n\n // Captura a posição inicial de cada elemento.\n for (const el of elements) {\n first.set(el, el.getBoundingClientRect());\n }\n\n // Aplica a mutação de DOM para que possamos medir a nova posição dos elementos.\n mutate();\n\n // Captura a posição final de cada elemento após a mutação.\n const animations: Array<Promise<unknown>> = [];\n\n // Itera sobre cada elemento para calcular a diferença de posição e criar as animações.\n for (const el of elements) {\n // Pega a posição inicial do elemento antes da mutação.\n const before = first.get(el);\n\n // Se não houver posição inicial ou o elemento não estiver mais conectado ao DOM, pula a animação.\n if (!before || !el.isConnected) {\n continue;\n }\n\n // Captura a posição final do elemento após a mutação.\n const after = el.getBoundingClientRect();\n\n // Calcula a diferença de posição entre a posição inicial e final.\n const dx = before.left - after.left;\n const dy = before.top - after.top;\n\n // Se não houver diferença de posição, pula a animação.\n if (dx === 0 && dy === 0) {\n continue;\n }\n\n // Cria os keyframes para a animação com base na diferença de posição.\n const keyframes: Record<string, [number, number]> = {};\n\n // Adiciona os keyframes apenas se houver diferença de posição em x ou y.\n if (dx !== 0) {\n keyframes.x = [dx, 0];\n }\n if (dy !== 0) {\n keyframes.y = [dy, 0];\n }\n\n // Adiciona a animação à lista de animações a serem aguardadas.\n animations.push(\n Promise.resolve(\n animate(el, keyframes, {\n type: \"spring\",\n stiffness: options.stiffness ?? 350,\n damping: options.damping ?? 32\n })\n )\n );\n }\n\n // Aguarda todas as animações terminarem antes de continuar.\n await Promise.all(animations);\n}\n","import { prefersReducedMotion } from \"@tooark/core\";\nimport { animate, stagger } from \"motion\";\nimport { hiddenOffset, resolveDistancePx, resolveDurationSec, resolveEase, resolveTargets } from \"./internal\";\nimport type { ArkMotionTargets, ArkStaggerOptions } from \"./types\";\n\n/**\n * Entrada escalonada de uma lista de elementos usando os motion tokens.\n * Resolve quando todos os itens terminam (imediatamente com reduced motion).\n */\nexport async function arkStaggerEnter(targets: ArkMotionTargets, options: ArkStaggerOptions = {}): Promise<void> {\n // Resolve os elementos de destino para garantir que estamos lidando com uma lista de elementos.\n const elements = resolveTargets(targets);\n\n // Retorna imediatamente se não houver elementos para animar.\n if (elements.length === 0) {\n return;\n }\n\n // Retorna imediatamente se o usuário preferir animações reduzidas.\n if (prefersReducedMotion()) {\n // Remove qualquer estilo de opacidade e transformação aplicado anteriormente.\n for (const el of elements) {\n el.style.opacity = \"\";\n el.style.transform = \"\";\n }\n\n return;\n }\n\n // Determina o preset de animação, a distância em pixels e o deslocamento inicial com base no preset.\n const preset = options.preset ?? \"slide-up\";\n const distancePx = resolveDistancePx(elements[0], options.distance);\n const offset = hiddenOffset(preset, distancePx);\n\n // Cria os keyframes iniciais para a animação com base no deslocamento calculado.\n const keyframes: Record<string, [number, number]> = { opacity: [0, 1] };\n\n // Adiciona os keyframes de transformação com base no deslocamento calculado.\n if (offset.x !== undefined) {\n keyframes.x = [offset.x, 0];\n }\n if (offset.y !== undefined) {\n keyframes.y = [offset.y, 0];\n }\n if (offset.scale !== undefined) {\n keyframes.scale = [offset.scale, 1];\n }\n\n // Aplica a animação aos elementos com os keyframes e as opções de stagger.\n await animate(elements, keyframes, {\n duration: resolveDurationSec(elements[0], options.duration, \"default\"),\n ease: resolveEase(elements[0], options.ease) as never,\n delay: stagger((options.interval ?? 60) / 1000, { from: options.from ?? \"first\" })\n });\n}\n","import { prefersReducedMotion } from \"@tooark/core\";\nimport { inView } from \"motion\";\nimport { resolveTargets } from \"./internal\";\nimport { arkStaggerEnter } from \"./stagger\";\nimport type { ArkMotionTargets, ArkRevealOptions } from \"./types\";\n\n/**\n * Scroll reveal: esconde os alvos e anima a entrada quando cada um aparece\n * na viewport. Retorna uma função de cleanup que para a observação.\n */\nexport function arkReveal(targets: ArkMotionTargets, options: ArkRevealOptions = {}): () => void {\n // Resolve os elementos de destino para garantir que estamos lidando com uma lista de elementos.\n const elements = resolveTargets(targets);\n\n // Retorna imediatamente se não houver elementos para observar ou se o usuário preferir animações reduzidas.\n if (elements.length === 0 || prefersReducedMotion()) {\n return () => undefined;\n }\n\n // Define se a animação deve ocorrer apenas uma vez.\n const once = options.once ?? true;\n const stops: Array<() => void> = [];\n\n // Inicializa a lista de funções de cleanup para cada elemento observado.\n for (const el of elements) {\n el.style.opacity = \"0\";\n el.style.willChange = \"opacity, transform\";\n\n // Configura a observação do elemento usando a função inView. O `once` é do próprio inView: sem cleanup\n // devolvido ele para de observar o elemento depois da primeira entrada, então o callback não roda de novo.\n const stop = inView(\n el,\n () => {\n el.style.opacity = \"\";\n void arkStaggerEnter([el], { ...options, interval: 0 });\n\n if (!once) {\n // Cleanup ao sair da viewport: re-esconde para animar de novo\n return () => {\n el.style.opacity = \"0\";\n };\n }\n return undefined;\n },\n { amount: options.amount ?? 0.25, margin: options.margin as never }\n );\n\n // Adiciona a função de cleanup do elemento à lista de stops.\n stops.push(stop);\n }\n\n // Retorna uma função de cleanup que chama todas as funções de stop armazenadas.\n return () => {\n for (const stop of stops) stop();\n };\n}\n","import { prefersReducedMotion } from \"@tooark/core\";\nimport { animate } from \"motion\";\nimport type { ArkSwipeDirection, ArkSwipeOptions } from \"./types\";\n\n/**\n * Gesto de swipe com feedback visual e retorno com física de spring.\n * Retorna uma função de cleanup que remove os listeners.\n */\nexport function arkSwipe(element: HTMLElement, options: ArkSwipeOptions): () => void {\n const axis = options.axis ?? \"x\";\n const threshold = options.threshold ?? 48;\n const velocityThreshold = options.velocityThreshold ?? 500;\n const feedback = options.feedback ?? true;\n const resistance = Math.min(1, Math.max(0, options.resistance ?? 0.4));\n\n let pointerId: number | null = null;\n let startPos = 0;\n let delta = 0;\n let lastPos = 0;\n let lastTime = 0;\n let velocity = 0;\n\n // Lê a posição atual do ponteiro com base no eixo configurado.\n const readPos = (event: PointerEvent): number => (axis === \"x\" ? event.clientX : event.clientY);\n\n // Aplica o feedback visual de swipe enquanto o usuário arrasta o elemento.\n const applyFeedback = (value: number): void => {\n // Se o feedback visual estiver desativado, não aplica a transformação.\n if (!feedback) {\n return;\n }\n\n // Aplica a resistência ao valor do swipe.\n const damped = value * (1 - resistance);\n\n // Atualiza a transformação do elemento com base no valor amortecido.\n element.style.transform = axis === \"x\" ? `translateX(${damped}px)` : `translateY(${damped}px)`;\n };\n\n // Anima o elemento de volta à posição original com física de spring.\n const springBack = (): void => {\n // Se o feedback visual estiver desativado, não aplica a animação de retorno.\n if (!feedback) {\n return;\n }\n\n // Remove a transformação do elemento antes de aplicar a animação de retorno.\n element.style.transform = \"\";\n\n // Se o usuário preferir animações reduzidas, não aplica a animação de retorno.\n if (prefersReducedMotion()) {\n return;\n }\n\n // Calcula o valor amortecido com base na resistência configurada.\n const damped = delta * (1 - resistance);\n\n // Cria os keyframes para a animação de retorno com base no valor amortecido.\n const keyframes = axis === \"x\" ? { x: [damped, 0] } : { y: [damped, 0] };\n\n // Aplica a animação de retorno usando a biblioteca de animação.\n animate(element, keyframes as never, {\n type: \"spring\",\n stiffness: 420,\n damping: 34,\n velocity: -velocity * (1 - resistance)\n });\n };\n\n // Manipulador de evento para quando o ponteiro é pressionado.\n const onPointerDown = (event: PointerEvent): void => {\n // Ignora o evento se já houver um ponteiro ativo ou se o ponteiro não for primário.\n if (pointerId !== null || !event.isPrimary) {\n return;\n }\n\n pointerId = event.pointerId;\n startPos = lastPos = readPos(event);\n lastTime = event.timeStamp;\n delta = 0;\n velocity = 0;\n element.setPointerCapture(event.pointerId);\n };\n\n // Manipulador de evento para quando o ponteiro é movido.\n const onPointerMove = (event: PointerEvent): void => {\n // Ignora o evento se o ponteiro não for o ativo.\n if (event.pointerId !== pointerId) {\n return;\n }\n\n // Calcula a posição atual do ponteiro e o tempo decorrido desde o último evento.\n const pos = readPos(event);\n const elapsed = event.timeStamp - lastTime;\n\n // Calcula a velocidade do ponteiro com base na mudança de posição e no tempo decorrido.\n if (elapsed > 0) {\n velocity = ((pos - lastPos) / elapsed) * 1000;\n }\n\n // Atualiza a posição e o tempo do último evento para o próximo cálculo de velocidade.\n lastPos = pos;\n lastTime = event.timeStamp;\n delta = pos - startPos;\n\n // Aplica o feedback visual com base no deslocamento atual.\n applyFeedback(delta);\n };\n\n // Manipulador de evento para quando o ponteiro é liberado ou cancelado.\n const finish = (event: PointerEvent): void => {\n // Ignora o evento se o ponteiro não for o ativo.\n if (event.pointerId !== pointerId) {\n return;\n }\n\n // Libera o ponteiro e redefine o estado interno.\n pointerId = null;\n element.releasePointerCapture(event.pointerId);\n\n // Determina se o gesto de swipe foi acionado com base no deslocamento e na velocidade.\n const triggered = Math.abs(delta) >= threshold || Math.abs(velocity) >= velocityThreshold;\n\n // Aciona o callback de swipe se o gesto foi detectado e o deslocamento não for zero.\n if (triggered && delta !== 0) {\n const direction: ArkSwipeDirection = axis === \"x\" ? (delta < 0 ? \"left\" : \"right\") : delta < 0 ? \"up\" : \"down\";\n options.onSwipe(direction, { delta, velocity });\n }\n\n // Restaura o elemento à sua posição original usando a animação de spring back.\n springBack();\n delta = 0;\n };\n\n // Armazena a ação de toque anterior e define a ação de toque apropriada para o eixo do swipe.\n const previousTouchAction = element.style.touchAction;\n element.style.touchAction = axis === \"x\" ? \"pan-y\" : \"pan-x\";\n\n // Adiciona os manipuladores de eventos para o ponteiro.\n element.addEventListener(\"pointerdown\", onPointerDown);\n element.addEventListener(\"pointermove\", onPointerMove);\n element.addEventListener(\"pointerup\", finish);\n element.addEventListener(\"pointercancel\", finish);\n\n // Retorna uma função de limpeza que remove os manipuladores de eventos e restaura a ação de toque original.\n return () => {\n element.style.touchAction = previousTouchAction;\n element.removeEventListener(\"pointerdown\", onPointerDown);\n element.removeEventListener(\"pointermove\", onPointerMove);\n element.removeEventListener(\"pointerup\", finish);\n element.removeEventListener(\"pointercancel\", finish);\n };\n}\n"],"names":[],"mappings":";;;;AAIA;AACO,MAAM,eAAe,GAAwD;IAClF,MAAM,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;IACpB,QAAQ,EAAE,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC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AACV,QAAA,OAAO,CAAC,KAAK,CAAC,WAAW,GAAG,mBAAmB;AAC/C,QAAA,OAAO,CAAC,mBAAmB,CAAC,aAAa,EAAE,aAAa,CAAC;AACzD,QAAA,OAAO,CAAC,mBAAmB,CAAC,aAAa,EAAE,aAAa,CAAC;AACzD,QAAA,OAAO,CAAC,mBAAmB,CAAC,WAAW,EAAE,MAAM,CAAC;AAChD,QAAA,OAAO,CAAC,mBAAmB,CAAC,eAAe,EAAE,MAAM,CAAC;AACtD,IAAA,CAAC;AACH;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tooark/motion",
3
- "version": "1.0.1",
3
+ "version": "1.2.0",
4
4
  "description": "Tooark Motion — opt-in animation helpers (stagger, scroll reveal, FLIP, swipe) on top of the Motion lib, with design system tokens",
5
5
  "keywords": [
6
6
  "tooark",
@@ -66,8 +66,8 @@
66
66
  "registry": "https://registry.npmjs.org/"
67
67
  },
68
68
  "dependencies": {
69
- "@tooark/core": "^1.0.1",
70
- "@tooark/tokens": "^1.0.1",
69
+ "@tooark/core": "^1.2.0",
70
+ "@tooark/tokens": "^1.2.0",
71
71
  "motion": "^13.4.0",
72
72
  "tslib": "^2.8.1"
73
73
  },