@octanejs/spring 0.0.28 → 0.0.29

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@octanejs/spring",
3
- "version": "0.0.28",
3
+ "version": "0.0.29",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "engines": {
@@ -43,7 +43,7 @@
43
43
  "@react-spring/rafz": "10.1.2"
44
44
  },
45
45
  "peerDependencies": {
46
- "octane": "^0.10.0"
46
+ "octane": "^0.11.0"
47
47
  },
48
48
  "devDependencies": {
49
49
  "@react-spring/animated": "10.1.2",
@@ -57,7 +57,7 @@
57
57
  "@types/react-dom": "^19.2.3",
58
58
  "@vitest/browser-playwright": "4.1.10",
59
59
  "flush-microtasks": "1.0.1",
60
- "octane": "0.10.2",
60
+ "octane": "0.11.0",
61
61
  "playwright": "^1.61.1",
62
62
  "react": "19.2.7",
63
63
  "react-dom": "19.2.7",
@@ -7,8 +7,9 @@ import {
7
7
  import { useSpring, useTrail, useTransition } from './hooks';
8
8
 
9
9
  function itemKey(item: any, index: number): string | number {
10
- return item?.key ?? item?.id ??
11
- (typeof item === 'string' || typeof item === 'number' ? item : index);
10
+ return (
11
+ item?.key ?? item?.id ?? (typeof item === 'string' || typeof item === 'number' ? item : index)
12
+ );
12
13
  }
13
14
 
14
15
  function keyed(value: unknown, key: string | number): unknown {
@@ -24,9 +25,7 @@ export function SpringContext(props: SpringContextValue & { children?: unknown }
24
25
  export function Spring(props: Record<string, unknown> & { children?: unknown }) @{
25
26
  const { children, ...update } = props;
26
27
  const styles = useSpring(update);
27
- <>
28
- {typeof children === 'function' && !isChildrenBlock(children) ? children(styles) : children}
29
- </>
28
+ <>{typeof children === 'function' && !isChildrenBlock(children) ? children(styles) : children}</>
30
29
  }
31
30
 
32
31
  export function Trail(props: any) @{
@@ -34,11 +33,8 @@ export function Trail(props: any) @{
34
33
  const styles = useTrail(items.length, update);
35
34
  <>
36
35
  {typeof children === 'function' && !isChildrenBlock(children)
37
- ? items.map(
38
- (item: any, index: number) => keyed(
39
- children(item, index)(styles[index]),
40
- itemKey(item, index),
41
- ),
36
+ ? items.map((item: any, index: number) =>
37
+ keyed(children(item, index)(styles[index]), itemKey(item, index)),
42
38
  )
43
39
  : children}
44
40
  </>
@@ -49,11 +45,8 @@ export function Transition(props: any) @{
49
45
  const transitions = useTransition(items, update);
50
46
  <>
51
47
  {typeof children === 'function' && !isChildrenBlock(children)
52
- ? transitions(
53
- (styles: any, item: any, transition: any, index: number) => keyed(
54
- children(item, index)(styles),
55
- transition.key,
56
- ),
48
+ ? transitions((styles: any, item: any, transition: any, index: number) =>
49
+ keyed(children(item, index)(styles), transition.key),
57
50
  )
58
51
  : children}
59
52
  </>
package/src/parallax.tsrx CHANGED
@@ -184,8 +184,7 @@ export function Parallax(props: any) @{
184
184
  const onResize = () => state.update();
185
185
  state.update();
186
186
  node.addEventListener('scroll', onScroll, { passive: true });
187
- const observer =
188
- typeof ResizeObserver === 'undefined' ? null : new ResizeObserver(onResize);
187
+ const observer = typeof ResizeObserver === 'undefined' ? null : new ResizeObserver(onResize);
189
188
  observer?.observe(node);
190
189
  return () => {
191
190
  live = false;
@@ -245,52 +244,52 @@ export function ParallaxLayer(props: any) @{
245
244
  const parent = useContext(ParallaxContext);
246
245
  if (parent === null) throw new Error('ParallaxLayer must be rendered inside Parallax');
247
246
  const [node] = useState<RefObject<HTMLDivElement>>(() => ({ current: null }));
248
- const [layer] = useState<ParallaxLayerState>(
249
- () => ({
250
- horizontal: layerHorizontal === undefined || sticky ? parent.horizontal : layerHorizontal,
251
- factor,
252
- offset,
253
- speed,
254
- sticky: sticky === undefined
247
+ const [layer] = useState<ParallaxLayerState>(() => ({
248
+ horizontal: layerHorizontal === undefined || sticky ? parent.horizontal : layerHorizontal,
249
+ factor,
250
+ offset,
251
+ speed,
252
+ sticky:
253
+ sticky === undefined
255
254
  ? undefined
256
255
  : { start: sticky.start ?? 0, end: sticky.end ?? (sticky.start ?? 0) + 1 },
257
- isSticky: false,
258
- setHeight(height) {
259
- if (node.current === null) return;
260
- const size = layer.sticky ? height : height * layer.factor;
261
- node.current.style[layer.horizontal ? 'width' : 'height'] = `${size}px`;
262
- },
263
- setPosition(height, scroll) {
264
- const element = node.current;
265
- if (element === null) return;
266
- let translate: number;
267
- if (layer.sticky) {
268
- const start = (layer.sticky.start ?? 0) * height;
269
- const end = (layer.sticky.end ?? layer.sticky.start ?? 0) * height;
270
- layer.isSticky = scroll >= start && scroll <= end;
271
- element.style.position = layer.isSticky ? 'sticky' : 'absolute';
272
- translate = layer.isSticky ? 0 : scroll < start ? start : end;
273
- } else {
274
- const targetScroll = Math.floor(layer.offset) * height;
275
- translate = -(scroll * layer.speed) + height * layer.offset + targetScroll * layer.speed;
276
- }
277
- updateLayerNode(
278
- element,
279
- layer.horizontal,
280
- layer.sticky ? height : height * layer.factor,
281
- translate,
282
- );
283
- },
284
- stop() {},
285
- }),
286
- );
256
+ isSticky: false,
257
+ setHeight(height) {
258
+ if (node.current === null) return;
259
+ const size = layer.sticky ? height : height * layer.factor;
260
+ node.current.style[layer.horizontal ? 'width' : 'height'] = `${size}px`;
261
+ },
262
+ setPosition(height, scroll) {
263
+ const element = node.current;
264
+ if (element === null) return;
265
+ let translate: number;
266
+ if (layer.sticky) {
267
+ const start = (layer.sticky.start ?? 0) * height;
268
+ const end = (layer.sticky.end ?? layer.sticky.start ?? 0) * height;
269
+ layer.isSticky = scroll >= start && scroll <= end;
270
+ element.style.position = layer.isSticky ? 'sticky' : 'absolute';
271
+ translate = layer.isSticky ? 0 : scroll < start ? start : end;
272
+ } else {
273
+ const targetScroll = Math.floor(layer.offset) * height;
274
+ translate = -(scroll * layer.speed) + height * layer.offset + targetScroll * layer.speed;
275
+ }
276
+ updateLayerNode(
277
+ element,
278
+ layer.horizontal,
279
+ layer.sticky ? height : height * layer.factor,
280
+ translate,
281
+ );
282
+ },
283
+ stop() {},
284
+ }));
287
285
  layer.horizontal = layerHorizontal === undefined || sticky ? parent.horizontal : layerHorizontal;
288
286
  layer.factor = factor;
289
287
  layer.offset = offset;
290
288
  layer.speed = speed;
291
- layer.sticky = sticky === undefined
292
- ? undefined
293
- : { start: sticky.start ?? 0, end: sticky.end ?? (sticky.start ?? 0) + 1 };
289
+ layer.sticky =
290
+ sticky === undefined
291
+ ? undefined
292
+ : { start: sticky.start ?? 0, end: sticky.end ?? (sticky.start ?? 0) + 1 };
294
293
  useImperativeHandle(givenRef, () => layer, []);
295
294
  useLayoutEffect(() => {
296
295
  parent.layers.add(layer);
@@ -317,5 +316,7 @@ export function ParallaxLayer(props: any) @{
317
316
  transform: START_TRANSLATE_3D,
318
317
  ...style,
319
318
  }}
320
- >{children}</div>
319
+ >
320
+ {children}
321
+ </div>
321
322
  }