@brandocms/jupiter 5.0.0-beta.5 → 5.0.0-beta.7

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": "@brandocms/jupiter",
3
- "version": "5.0.0-beta.5",
3
+ "version": "5.0.0-beta.7",
4
4
  "description": "Frontend helpers.",
5
5
  "author": "Univers/Twined",
6
6
  "license": "UNLICENSED",
@@ -42,16 +42,14 @@
42
42
  },
43
43
  "types": "types/index.d.ts",
44
44
  "dependencies": {
45
- "body-scroll-lock": "^4.0.0-beta.0",
46
45
  "lodash.defaultsdeep": "^4.6.1",
47
- "motion": "^12.23.24",
48
- "virtual-scroll": "^2.2.1"
46
+ "motion": "^12.23.26"
49
47
  },
50
48
  "devDependencies": {
51
- "@playwright/test": "^1.52.0",
52
- "@types/node": "^22.15.16",
53
- "typescript": "^5.8.3",
54
- "vite": "^6.3.5"
49
+ "@playwright/test": "^1.57.0",
50
+ "@types/node": "^22.19.3",
51
+ "typescript": "^5.9.3",
52
+ "vite": "^6.4.1"
55
53
  },
56
54
  "packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
57
55
  }
@@ -96,6 +96,7 @@ function horizontalLoop(app, items, config) {
96
96
 
97
97
  // Drag state and cleanup handlers
98
98
  let dragState = {}
99
+ let isDragging = false // Track if user is actively dragging (for wrap detection guard)
99
100
  let speedRampAnimation = null // Track speed ramp animation
100
101
  let inertiaAnimation = null // Track inertia animation
101
102
  let snapAnimation = null // Track snap animation
@@ -525,6 +526,31 @@ function horizontalLoop(app, items, config) {
525
526
  })
526
527
  }
527
528
 
529
+ /**
530
+ * Create and start the crawl animation loop
531
+ * Animates the position motionValue (frame.render loop applies to DOM)
532
+ */
533
+ function startLoopAnimation() {
534
+ if (!shouldLoop || !config.crawl) return null
535
+
536
+ const duration = originalItemsWidth / pixelsPerSecond
537
+ const currentPos = position.get()
538
+ // Reversed: crawl backwards (right-to-left), Normal: crawl forward (left-to-right)
539
+ const target = config.reversed
540
+ ? currentPos - originalItemsWidth
541
+ : currentPos + originalItemsWidth
542
+
543
+ // Animate the position motionValue
544
+ // frame.render loop will apply bounded position to DOM
545
+ animation = animate(position, target, {
546
+ duration,
547
+ repeat: Infinity,
548
+ ease: 'linear',
549
+ })
550
+
551
+ return animation
552
+ }
553
+
528
554
  /**
529
555
  * Initialize the loop animation
530
556
  */
@@ -579,28 +605,14 @@ function horizontalLoop(app, items, config) {
579
605
  const didWrap = delta > originalItemsWidth * 0.4
580
606
 
581
607
  if (didWrap) {
582
- const direction =
583
- latest > lastBoundedValue ? 'backward (drag right)' : 'forward (drag left)'
584
-
585
- // Count how many items have non-zero offset before reset
586
- const itemsWithOffset = items.filter(
587
- (item, i) => !isCloneCache[i] && itemWrapOffsets[i] !== 0
588
- ).length
589
-
590
- // Reset ALL original items to 0 (both positive and negative offsets)
591
- items.forEach((item, i) => {
592
- if (!isCloneCache[i] && itemWrapOffsets[i] !== 0) {
593
- item.style.transform = 'none'
594
- itemWrapOffsets[i] = 0
595
- }
596
- })
608
+ // NOTE: We intentionally do NOT reset item transforms here anymore.
609
+ // Resetting here caused flash because it happens between render frames.
610
+ // The updateItemPositions() in frame.render handles wrapping correctly
611
+ // when called with the new boundedPos.
597
612
 
598
- // CRITICAL: Sync unbounded position with bounded position to prevent
599
- // inertia calculation bugs when dragging RIGHT across boundaries
600
- // BUT only do this when NOT animating snap or nav, otherwise it interferes
601
- if (!snapAnimation && !navAnimation) {
613
+ // Sync position to bounded value (only when not dragging/animating)
614
+ if (!snapAnimation && !navAnimation && !isDragging) {
602
615
  position.set(latest)
603
- } else {
604
616
  }
605
617
  }
606
618
 
@@ -648,29 +660,6 @@ function horizontalLoop(app, items, config) {
648
660
  })
649
661
  }
650
662
 
651
- // Function to create and start the animation loop
652
- // Animates the position motionValue (frame.render loop applies to DOM)
653
- function startLoopAnimation() {
654
- if (!shouldLoop || !config.crawl) return null
655
-
656
- const duration = originalItemsWidth / pixelsPerSecond
657
- const currentPos = position.get()
658
- // Reversed: crawl backwards (right-to-left), Normal: crawl forward (left-to-right)
659
- const target = config.reversed
660
- ? currentPos - originalItemsWidth
661
- : currentPos + originalItemsWidth
662
-
663
- // Animate the position motionValue
664
- // frame.render loop will apply bounded position to DOM
665
- animation = animate(position, target, {
666
- duration,
667
- repeat: Infinity,
668
- ease: 'linear',
669
- })
670
-
671
- return animation
672
- }
673
-
674
663
  // Create animation by animating the position motionValue
675
664
  if (shouldLoop && config.crawl) {
676
665
  const duration = totalWidth / pixelsPerSecond
@@ -807,7 +796,7 @@ function horizontalLoop(app, items, config) {
807
796
  * Replaces GSAP Draggable with optimized pointer events
808
797
  */
809
798
  function setupDrag() {
810
- let isDragging = false
799
+ // isDragging is now module-level so wrap detection can see it
811
800
  let startX = 0
812
801
  let startPosition = 0
813
802
  let velocityTracker = [] // Track recent movements for velocity calculation
@@ -1169,7 +1158,7 @@ function horizontalLoop(app, items, config) {
1169
1158
  snapAnimation = null
1170
1159
  // Update display to reflect landed position
1171
1160
  updateIndexDisplay()
1172
- if (config.crawl && animation) {
1161
+ if (config.crawl) {
1173
1162
  resumeCrawl()
1174
1163
  }
1175
1164
  })