react-native-marquee-animation 0.1.3 → 0.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.
Files changed (33) hide show
  1. package/README.md +57 -6
  2. package/android/src/main/java/com/marquee/MarqueeEvent.kt +17 -0
  3. package/android/src/main/java/com/marquee/MarqueeModels.kt +1 -0
  4. package/android/src/main/java/com/marquee/MarqueeMotion.kt +18 -0
  5. package/android/src/main/java/com/marquee/MarqueeView.kt +45 -13
  6. package/android/src/main/java/com/marquee/MarqueeViewManager.kt +12 -0
  7. package/ios/MarqueeRenderer.swift +70 -0
  8. package/ios/RNMarqueeView.mm +10 -0
  9. package/lib/module/RNMarqueeViewNativeComponent.ts +6 -0
  10. package/lib/module/marquee.js +6 -1
  11. package/lib/module/marquee.js.map +1 -1
  12. package/lib/module/marquee.native.js +8 -0
  13. package/lib/module/marquee.native.js.map +1 -1
  14. package/lib/module/view-props.js +1 -1
  15. package/lib/module/view-props.js.map +1 -1
  16. package/lib/typescript/src/RNMarqueeViewNativeComponent.d.ts +5 -0
  17. package/lib/typescript/src/RNMarqueeViewNativeComponent.d.ts.map +1 -1
  18. package/lib/typescript/src/index.d.ts +1 -1
  19. package/lib/typescript/src/index.d.ts.map +1 -1
  20. package/lib/typescript/src/marquee.d.ts +1 -0
  21. package/lib/typescript/src/marquee.d.ts.map +1 -1
  22. package/lib/typescript/src/marquee.native.d.ts +1 -0
  23. package/lib/typescript/src/marquee.native.d.ts.map +1 -1
  24. package/lib/typescript/src/types.d.ts +7 -1
  25. package/lib/typescript/src/types.d.ts.map +1 -1
  26. package/lib/typescript/src/view-props.d.ts.map +1 -1
  27. package/package.json +3 -3
  28. package/src/RNMarqueeViewNativeComponent.ts +6 -0
  29. package/src/index.ts +1 -0
  30. package/src/marquee.native.tsx +11 -0
  31. package/src/marquee.tsx +12 -3
  32. package/src/types.ts +8 -1
  33. package/src/view-props.ts +1 -0
package/README.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # React Native Marquee
2
2
 
3
+ [![npm version](https://img.shields.io/npm/v/react-native-marquee-animation.svg)](https://www.npmjs.com/package/react-native-marquee-animation)
4
+ [![npm downloads](https://img.shields.io/npm/dm/react-native-marquee-animation.svg)](https://www.npmjs.com/package/react-native-marquee-animation)
5
+ [![CI](https://github.com/invivek26/react-native-marquee-animation/actions/workflows/ci.yml/badge.svg)](https://github.com/invivek26/react-native-marquee-animation/actions/workflows/ci.yml)
6
+ [![license](https://img.shields.io/npm/l/react-native-marquee-animation.svg)](LICENSE)
7
+
3
8
  A production-grade generic marquee for React Native's New Architecture. Render
4
9
  ordinary React Native text, images, icons, badges, charts, and composed views
5
10
  once; native iOS and Android code repeats the visual strip and owns all motion.
@@ -7,6 +12,8 @@ once; native iOS and Android code repeats the visual strip and owns all motion.
7
12
  There is no per-frame JavaScript, duplicated React state, or list
8
13
  virtualization.
9
14
 
15
+ Explore the interactive web interpretation at [viveks.app/open-source](https://viveks.app/open-source).
16
+
10
17
  ## Demo
11
18
 
12
19
  https://github.com/user-attachments/assets/9f4e1655-0f2c-468f-b0e4-25af40de5631
@@ -108,12 +115,53 @@ Supported content includes normal layer/display-list-backed React Native views:
108
115
  - custom charts that render into the ordinary React Native view hierarchy;
109
116
  - child state, asynchronous image loading, and dynamic value changes.
110
117
 
111
- Marquee children are deliberately noninteractive. The host owns horizontal
112
- pan, hold, and fling gestures, and repeated pixels are not additional React
113
- views. Nested `Pressable`, `TextInput`, map, video, camera, `SurfaceView`,
114
- `TextureView`, Metal, and other external rendering surfaces are outside the
115
- contract. Use a separate typed interaction layer when individual repeated
116
- items must be clickable.
118
+ Marquee children receive no touches. The host owns horizontal pan, hold, and
119
+ fling gestures, and repeated pixels are not additional React views. Nested
120
+ `Pressable`, `TextInput`, map, video, camera, `SurfaceView`, `TextureView`,
121
+ Metal, and other external rendering surfaces are outside the contract.
122
+
123
+ To make items tappable, pass `onContentPress`. Native code maps a tap on any
124
+ visual copy back to `x` in the content container's own coordinates,
125
+ `[0, contentWidth)`, so the same pixel reports the same `x` on both platforms
126
+ regardless of copy, direction, phase, drag offset, or static alignment. Taps in
127
+ the `spacing` gap or outside static content report nothing. Hit-test your own
128
+ items with their `onLayout` ranges:
129
+
130
+ ```tsx
131
+ const ranges = useRef(new Map<string, { start: number; end: number }>());
132
+
133
+ <Marquee
134
+ accessibilityLabel="Watchlist"
135
+ onContentPress={({ x }) => {
136
+ for (const [id, range] of ranges.current) {
137
+ if (x >= range.start && x < range.end) return openChart(id);
138
+ }
139
+ }}
140
+ >
141
+ {stocks.map((stock) => (
142
+ <StockPill
143
+ key={stock.id}
144
+ onLayout={({ nativeEvent: { layout } }) =>
145
+ ranges.current.set(stock.id, {
146
+ start: layout.x,
147
+ end: layout.x + layout.width,
148
+ })
149
+ }
150
+ stock={stock}
151
+ />
152
+ ))}
153
+ </Marquee>;
154
+ ```
155
+
156
+ A tap is a touch down and up that moves less than the platform touch slop
157
+ without starting a drag; drags, flings, cancellations, and parent scrolls never
158
+ fire. The position is sampled at touch-down, so moving content
159
+ (`pauseOnPress: false`) reports what was under the finger when it landed.
160
+ Tapping does not interrupt automatic motion. Without `onContentPress`, native
161
+ touch handling is unchanged and touches outside the drag area still reach
162
+ native parents. The strip remains one accessible
163
+ element; provide an accessible alternative if individual items matter to
164
+ assistive technology users.
117
165
 
118
166
  ## Main props
119
167
 
@@ -127,6 +175,7 @@ items must be clickable.
127
175
  | `shortContentMode` | `static` | Static content or repeated short content |
128
176
  | `contentAlignment` | `start` | Alignment while short content is stationary |
129
177
  | `contentContainerStyle` | — | Style for the one horizontal content wrapper |
178
+ | `onContentPress` | — | Tap position `{ x }` in content coordinates |
130
179
  | `reduceMotion` | `system` | `system`, `always`, or `never` |
131
180
 
132
181
  ## Native architecture
@@ -178,3 +227,5 @@ Release presentation captures. See [example/CAPTURE.md](example/CAPTURE.md).
178
227
  ## License
179
228
 
180
229
  [MIT](LICENSE)
230
+
231
+ Maintained by [Vivek Indlebele Narasimha Prasad](https://viveks.app).
@@ -38,7 +38,24 @@ internal class ContentLayoutEvent(
38
38
  }
39
39
  }
40
40
 
41
+ internal class ContentPressEvent(
42
+ surfaceId: Int,
43
+ viewId: Int,
44
+ private val x: Float,
45
+ ) : Event<ContentPressEvent>(surfaceId, viewId) {
46
+ override fun getEventName(): String = EVENT_NAME
47
+
48
+ override fun getEventData(): WritableMap = Arguments.createMap().apply {
49
+ putDouble("x", x.toDouble())
50
+ }
51
+
52
+ companion object {
53
+ const val EVENT_NAME = "topContentPress"
54
+ }
55
+ }
56
+
41
57
  internal interface MarqueeEventListener {
42
58
  fun onAnimationStateChange(state: MotionState)
43
59
  fun onContentLayout(contentWidth: Float, containerWidth: Float)
60
+ fun onContentPress(xPx: Float)
44
61
  }
@@ -23,6 +23,7 @@ internal data class MarqueeProps(
23
23
  var maxFlingVelocity: Float = 3200f,
24
24
  var deceleration: Float = 0.9985f,
25
25
  var pauseOnPress: Boolean = true,
26
+ var contentPressEnabled: Boolean = false,
26
27
  var resumeDelayMs: Double = 0.0,
27
28
  )
28
29
 
@@ -3,6 +3,24 @@ package com.marquee
3
3
  import kotlin.math.abs
4
4
  import kotlin.math.pow
5
5
 
6
+ /**
7
+ * Maps a viewport x to one copy's content coordinates. Repeated copies sit at whole
8
+ * periods from [contentLeft]; null means the spacing gap or outside static content.
9
+ */
10
+ internal fun contentPressX(
11
+ touchX: Double,
12
+ contentLeft: Double,
13
+ contentWidth: Double,
14
+ period: Double,
15
+ repeats: Boolean,
16
+ ): Double? {
17
+ if (!touchX.isFinite() || !contentLeft.isFinite() || contentWidth <= 0.0) return null
18
+ if (repeats && period <= 0.0) return null
19
+ val offset = touchX - contentLeft
20
+ val x = if (repeats) ((offset % period) + period) % period else offset
21
+ return x.takeIf { it >= 0.0 && it < contentWidth }
22
+ }
23
+
6
24
  internal class MarqueeMotion {
7
25
  var phasePx: Double = 0.0
8
26
  private set
@@ -13,6 +13,7 @@ import android.view.ViewConfiguration
13
13
  import android.view.ViewGroup
14
14
  import com.facebook.react.uimanager.PixelUtil
15
15
  import kotlin.math.abs
16
+ import kotlin.math.hypot
16
17
 
17
18
  class MarqueeView : ViewGroup, Choreographer.FrameCallback {
18
19
  constructor(context: Context) : super(context)
@@ -34,6 +35,8 @@ class MarqueeView : ViewGroup, Choreographer.FrameCallback {
34
35
  private var pointerDownY = 0f
35
36
  private var previousPointerX = 0f
36
37
  private var didPan = false
38
+ private var tracksMotionGesture = false
39
+ private var pressContentX: Double? = null
37
40
  private val resumeRunnable = Runnable { reconcileMotionState() }
38
41
 
39
42
  init {
@@ -63,6 +66,7 @@ class MarqueeView : ViewGroup, Choreographer.FrameCallback {
63
66
  stopFrames()
64
67
  velocityTracker?.recycle()
65
68
  velocityTracker = null
69
+ pressContentX = null
66
70
  pendingProps.copyFrom(MarqueeProps())
67
71
  committedProps = MarqueeProps()
68
72
  motion.configure(0.0, 0.0, preservePhase = false)
@@ -144,27 +148,35 @@ class MarqueeView : ViewGroup, Choreographer.FrameCallback {
144
148
  if (motion.isFrameDriven() && shouldScheduleMotion()) postFrame()
145
149
  }
146
150
 
151
+ // With onContentPress, taps are tracked everywhere content is drawn; drag, hold, and fling
152
+ // only inside the edge insets of moving content. The tap position is sampled at touch-down.
147
153
  override fun onTouchEvent(event: MotionEvent): Boolean {
148
- if (!committedProps.active || committedProps.reduceMotion || !shouldRepeat()) return false
154
+ val tapsEnabled = committedProps.contentPressEnabled
155
+ if (!tapsEnabled && (!committedProps.active || committedProps.reduceMotion || !shouldRepeat())) return false
149
156
  when (event.actionMasked) {
150
157
  MotionEvent.ACTION_DOWN -> {
151
- val edgeInset = PixelUtil.toPixelFromDIP(EDGE_GESTURE_INSET_DP)
152
- if (event.x <= edgeInset || event.x >= width - edgeInset) return false
153
- removeCallbacks(resumeRunnable)
154
- velocityTracker?.recycle()
155
- velocityTracker = VelocityTracker.obtain().also { it.addMovement(event) }
158
+ pressContentX = if (tapsEnabled) contentPressXAt(event.x) else null
156
159
  pointerDownX = event.x
157
160
  pointerDownY = event.y
158
161
  previousPointerX = event.x
159
162
  didPan = false
163
+ val edgeInset = PixelUtil.toPixelFromDIP(EDGE_GESTURE_INSET_DP)
164
+ tracksMotionGesture = committedProps.active && !committedProps.reduceMotion && shouldRepeat() &&
165
+ event.x > edgeInset && event.x < width - edgeInset
166
+ if (!tracksMotionGesture) return pressContentX != null
167
+ removeCallbacks(resumeRunnable)
168
+ velocityTracker?.recycle()
169
+ velocityTracker = VelocityTracker.obtain().also { it.addMovement(event) }
160
170
  if (committedProps.pauseOnPress) motion.beginHold()
161
171
  reportMotionState()
162
172
  return true
163
173
  }
164
174
  MotionEvent.ACTION_MOVE -> {
165
- velocityTracker?.addMovement(event)
166
175
  val totalDeltaX = event.x - pointerDownX
167
176
  val totalDeltaY = event.y - pointerDownY
177
+ if (hypot(totalDeltaX, totalDeltaY) >= touchSlop) pressContentX = null
178
+ if (!tracksMotionGesture) return pressContentX != null
179
+ velocityTracker?.addMovement(event)
168
180
  if (!didPan && abs(totalDeltaY) >= touchSlop &&
169
181
  abs(totalDeltaY) * PAN_DOMINANCE_RATIO > abs(totalDeltaX)) {
170
182
  finishGesture(0.0, canceled = true)
@@ -184,19 +196,26 @@ class MarqueeView : ViewGroup, Choreographer.FrameCallback {
184
196
  return true
185
197
  }
186
198
  MotionEvent.ACTION_UP -> {
187
- velocityTracker?.addMovement(event)
188
- velocityTracker?.computeCurrentVelocity(1000)
189
- val velocity = if (didPan) velocityTracker?.xVelocity?.toDouble() ?: 0.0 else 0.0
190
- finishGesture(velocity, canceled = false)
199
+ if (tracksMotionGesture) {
200
+ velocityTracker?.addMovement(event)
201
+ velocityTracker?.computeCurrentVelocity(1000)
202
+ val velocity = if (didPan) velocityTracker?.xVelocity?.toDouble() ?: 0.0 else 0.0
203
+ finishGesture(velocity, canceled = false)
204
+ }
205
+ val pressX = pressContentX.takeUnless { didPan }
206
+ pressContentX = null
207
+ if (pressX != null) eventListener?.onContentPress(pressX.toFloat())
191
208
  performClick()
192
209
  return true
193
210
  }
194
211
  MotionEvent.ACTION_CANCEL -> {
195
- finishGesture(0.0, canceled = true)
212
+ pressContentX = null
213
+ if (tracksMotionGesture) finishGesture(0.0, canceled = true)
196
214
  return true
197
215
  }
198
216
  MotionEvent.ACTION_POINTER_DOWN -> {
199
- finishGesture(0.0, canceled = true)
217
+ pressContentX = null
218
+ if (tracksMotionGesture) finishGesture(0.0, canceled = true)
200
219
  return false
201
220
  }
202
221
  }
@@ -279,6 +298,18 @@ class MarqueeView : ViewGroup, Choreographer.FrameCallback {
279
298
  reportMotionState()
280
299
  }
281
300
 
301
+ private fun contentPressXAt(touchX: Float): Double? {
302
+ val contentWidth = contentWidthPx()
303
+ val repeats = shouldRepeat()
304
+ return contentPressX(
305
+ touchX = touchX.toDouble(),
306
+ contentLeft = if (repeats) paddingLeft - motion.phasePx else staticContentX(contentWidth).toDouble(),
307
+ contentWidth = contentWidth.toDouble(),
308
+ period = periodPx(),
309
+ repeats = repeats,
310
+ )
311
+ }
312
+
282
313
  private fun contentWidthPx(): Float = PixelUtil.toPixelFromDIP(committedProps.contentWidth)
283
314
 
284
315
  private fun synchronizeContentWidthFromChild() {
@@ -398,5 +429,6 @@ private fun MarqueeProps.copyFrom(other: MarqueeProps) {
398
429
  maxFlingVelocity = other.maxFlingVelocity
399
430
  deceleration = other.deceleration
400
431
  pauseOnPress = other.pauseOnPress
432
+ contentPressEnabled = other.contentPressEnabled
401
433
  resumeDelayMs = other.resumeDelayMs
402
434
  }
@@ -40,6 +40,12 @@ class MarqueeViewManager : ViewGroupManager<MarqueeView>(),
40
40
  ),
41
41
  )
42
42
  }
43
+
44
+ override fun onContentPress(xPx: Float) {
45
+ dispatcher?.dispatchEvent(
46
+ ContentPressEvent(surfaceId, view.id, PixelUtil.toDIPFromPixel(xPx)),
47
+ )
48
+ }
43
49
  })
44
50
  }
45
51
 
@@ -47,6 +53,7 @@ class MarqueeViewManager : ViewGroupManager<MarqueeView>(),
47
53
  (super.getExportedCustomDirectEventTypeConstants() ?: mutableMapOf()).apply {
48
54
  put(AnimationStateChangeEvent.EVENT_NAME, mapOf("registrationName" to "onAnimationStateChange"))
49
55
  put(ContentLayoutEvent.EVENT_NAME, mapOf("registrationName" to "onContentLayout"))
56
+ put(ContentPressEvent.EVENT_NAME, mapOf("registrationName" to "onContentPress"))
50
57
  }
51
58
 
52
59
  override fun onAfterUpdateTransaction(view: MarqueeView) {
@@ -114,6 +121,11 @@ class MarqueeViewManager : ViewGroupManager<MarqueeView>(),
114
121
  view.pendingProps.pauseOnPress = value
115
122
  }
116
123
 
124
+ @ReactProp(name = "contentPressEnabled")
125
+ override fun setContentPressEnabled(view: MarqueeView, value: Boolean) {
126
+ view.pendingProps.contentPressEnabled = value
127
+ }
128
+
117
129
  @ReactProp(name = "resumeDelayMs")
118
130
  override fun setResumeDelayMs(view: MarqueeView, value: Double) {
119
131
  view.pendingProps.resumeDelayMs = value.finiteOr(0.0).coerceAtLeast(0.0)
@@ -8,6 +8,7 @@ import UIKit
8
8
  didLayoutContentWidth contentWidth: CGFloat,
9
9
  containerWidth: CGFloat
10
10
  )
11
+ func marqueeRenderer(_ renderer: MarqueeRenderer, didPressContentAt x: CGFloat)
11
12
  }
12
13
 
13
14
  @objcMembers public final class MarqueeConfiguration: NSObject {
@@ -22,6 +23,7 @@ import UIKit
22
23
  public var maxFlingVelocity: CGFloat = 3_200
23
24
  public var deceleration: CGFloat = 0.9985
24
25
  public var pauseOnPress = true
26
+ public var contentPressEnabled = false
25
27
  public var resumeDelay: TimeInterval = 0
26
28
  }
27
29
 
@@ -61,6 +63,25 @@ enum MarqueeMath {
61
63
  }
62
64
  return abs(velocity.x) >= 20 && abs(velocity.x) > abs(velocity.y) * 1.15
63
65
  }
66
+
67
+ /// Maps a viewport x to one copy's content coordinates. Replicas sit at whole
68
+ /// periods from `contentLeft`; `nil` means the spacing gap or outside static content.
69
+ static func contentPressX(
70
+ touchX: CGFloat,
71
+ contentLeft: CGFloat,
72
+ contentWidth: CGFloat,
73
+ period: CGFloat,
74
+ repeats: Bool
75
+ ) -> CGFloat? {
76
+ guard touchX.isFinite, contentLeft.isFinite, contentWidth > 0,
77
+ !repeats || period > 0 else {
78
+ return nil
79
+ }
80
+ let x = repeats
81
+ ? positiveModulo(touchX - contentLeft, modulus: period)
82
+ : touchX - contentLeft
83
+ return x >= 0 && x < contentWidth ? x : nil
84
+ }
64
85
  }
65
86
 
66
87
  private enum MarqueeState: String {
@@ -89,6 +110,8 @@ private enum InteractiveDisplayMode {
89
110
  private var isHolding = false
90
111
  private var isDragging = false
91
112
  private var panStartOffset: CGFloat = 0
113
+ private var pressDownLocation: CGPoint = .zero
114
+ private var pressContentX: CGFloat?
92
115
  private var pendingDragOffset: CGFloat?
93
116
  private var displayLink: CADisplayLink?
94
117
  private var interactiveDisplayMode: InteractiveDisplayMode?
@@ -113,6 +136,7 @@ private enum InteractiveDisplayMode {
113
136
  target: self,
114
137
  action: #selector(handleHold(_:))
115
138
  )
139
+ private lazy var tapGesture = UITapGestureRecognizer(target: self, action: #selector(handleTap(_:)))
116
140
 
117
141
  public override init(frame: CGRect) {
118
142
  super.init(frame: frame)
@@ -147,6 +171,7 @@ private enum InteractiveDisplayMode {
147
171
 
148
172
  configuration = value
149
173
  holdGesture.isEnabled = value.pauseOnPress
174
+ tapGesture.isEnabled = value.contentPressEnabled
150
175
  if geometryChanged {
151
176
  freezeMotion()
152
177
  configureReplication(preservingOffset: oldOffset)
@@ -170,6 +195,8 @@ private enum InteractiveDisplayMode {
170
195
  sourceBaseX = 0
171
196
  isHolding = false
172
197
  isDragging = false
198
+ pressContentX = nil
199
+ tapGesture.isEnabled = false
173
200
  lastState = nil
174
201
  lastLayoutWidth = -1
175
202
  lastContainerWidth = -1
@@ -247,6 +274,17 @@ private enum InteractiveDisplayMode {
247
274
  gestureRecognizer === holdGesture || otherGestureRecognizer === holdGesture
248
275
  }
249
276
 
277
+ public func gestureRecognizer(
278
+ _ gestureRecognizer: UIGestureRecognizer,
279
+ shouldReceive touch: UITouch
280
+ ) -> Bool {
281
+ if gestureRecognizer === tapGesture {
282
+ pressDownLocation = touch.location(in: self)
283
+ pressContentX = contentPressX(atViewportX: pressDownLocation.x)
284
+ }
285
+ return true
286
+ }
287
+
250
288
  public override func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool {
251
289
  guard gestureRecognizer === panGesture else { return true }
252
290
  let velocity = panGesture.velocity(in: self)
@@ -291,8 +329,13 @@ private enum InteractiveDisplayMode {
291
329
  holdGesture.delegate = self
292
330
  holdGesture.minimumPressDuration = 0
293
331
  holdGesture.cancelsTouchesInView = false
332
+ tapGesture.delegate = self
333
+ tapGesture.cancelsTouchesInView = false
334
+ tapGesture.isEnabled = false
335
+ tapGesture.require(toFail: panGesture)
294
336
  addGestureRecognizer(panGesture)
295
337
  addGestureRecognizer(holdGesture)
338
+ addGestureRecognizer(tapGesture)
296
339
  registerNotifications()
297
340
  }
298
341
 
@@ -383,6 +426,18 @@ private enum InteractiveDisplayMode {
383
426
  )
384
427
  }
385
428
 
429
+ private func contentPressX(atViewportX x: CGFloat) -> CGFloat? {
430
+ guard let layer = contentView?.layer else { return nil }
431
+ let layoutLeft = layer.position.x - layer.bounds.width * layer.anchorPoint.x
432
+ return MarqueeMath.contentPressX(
433
+ touchX: x,
434
+ contentLeft: layoutLeft + sourceBaseX + currentPhysicalOffset(),
435
+ contentWidth: configuration.contentWidth,
436
+ period: period,
437
+ repeats: canScrollGeometry
438
+ )
439
+ }
440
+
386
441
  private func setContentOffset(_ offset: CGFloat) {
387
442
  guard let contentView else { return }
388
443
  let normalized = canScrollGeometry && period > 0
@@ -473,6 +528,17 @@ private enum InteractiveDisplayMode {
473
528
  }
474
529
  }
475
530
 
531
+ // Sampled at touch-down so content that keeps moving (pauseOnPress false) reports what was touched.
532
+ @objc private func handleTap(_ gesture: UITapGestureRecognizer) {
533
+ let location = gesture.location(in: self)
534
+ guard gesture.state == .ended, !isDragging,
535
+ hypot(location.x - pressDownLocation.x, location.y - pressDownLocation.y) < tapSlop,
536
+ let x = pressContentX else {
537
+ return
538
+ }
539
+ delegate?.marqueeRenderer(self, didPressContentAt: x)
540
+ }
541
+
476
542
  @objc private func handlePan(_ gesture: UIPanGestureRecognizer) {
477
543
  guard canScrollGeometry, !effectiveReduceMotion else { return }
478
544
  switch gesture.state {
@@ -701,6 +767,9 @@ private enum InteractiveDisplayMode {
701
767
  var testingHoldEnabled: Bool { holdGesture.isEnabled }
702
768
  var testingHoldMinimumPressDuration: TimeInterval { holdGesture.minimumPressDuration }
703
769
  var testingHoldCancelsTouchesInView: Bool { holdGesture.cancelsTouchesInView }
770
+ var testingTapCancelsTouchesInView: Bool { tapGesture.cancelsTouchesInView }
771
+ var testingTapEnabled: Bool { tapGesture.isEnabled }
772
+ func testingContentPressX(atViewportX x: CGFloat) -> CGFloat? { contentPressX(atViewportX: x) }
704
773
  var testingDisplayLinkPreferredFrameRate: Float? {
705
774
  displayLink?.preferredFrameRateRange.preferred
706
775
  }
@@ -732,5 +801,6 @@ private enum InteractiveDisplayMode {
732
801
  }
733
802
 
734
803
  private let autoBlendDuration: CFTimeInterval = 0.35
804
+ private let tapSlop: CGFloat = 10
735
805
  private let animationKey = "marquee.auto"
736
806
  }
@@ -52,6 +52,7 @@ using namespace facebook::react;
52
52
  configuration.maxFlingVelocity = newProps.maxFlingVelocity;
53
53
  configuration.deceleration = newProps.deceleration;
54
54
  configuration.pauseOnPress = newProps.pauseOnPress;
55
+ configuration.contentPressEnabled = newProps.contentPressEnabled;
55
56
  configuration.resumeDelay = MAX(0, newProps.resumeDelayMs / 1000.0);
56
57
  _pendingConfiguration = configuration;
57
58
  [super updateProps:props oldProps:oldProps];
@@ -115,4 +116,13 @@ using namespace facebook::react;
115
116
  });
116
117
  }
117
118
 
119
+ - (void)marqueeRenderer:(MarqueeRenderer *)renderer didPressContentAt:(CGFloat)x
120
+ {
121
+ if (renderer != _renderer || !_eventEmitter) {
122
+ return;
123
+ }
124
+ auto eventEmitter = std::static_pointer_cast<const RNMarqueeViewEventEmitter>(_eventEmitter);
125
+ eventEmitter->onContentPress({.x = static_cast<Float>(x)});
126
+ }
127
+
118
128
  @end
@@ -10,6 +10,10 @@ type NativeContentLayoutEvent = Readonly<{
10
10
  containerWidth: CodegenTypes.Float;
11
11
  }>;
12
12
 
13
+ type NativeContentPressEvent = Readonly<{
14
+ x: CodegenTypes.Float;
15
+ }>;
16
+
13
17
  export interface NativeMarqueeViewProps extends ViewProps {
14
18
  active: boolean;
15
19
  reduceMotion: boolean;
@@ -22,9 +26,11 @@ export interface NativeMarqueeViewProps extends ViewProps {
22
26
  maxFlingVelocity: CodegenTypes.Float;
23
27
  deceleration: CodegenTypes.Float;
24
28
  pauseOnPress: boolean;
29
+ contentPressEnabled: boolean;
25
30
  resumeDelayMs: CodegenTypes.Double;
26
31
  onAnimationStateChange?: CodegenTypes.DirectEventHandler<NativeAnimationStateEvent>;
27
32
  onContentLayout?: CodegenTypes.DirectEventHandler<NativeContentLayoutEvent>;
33
+ onContentPress?: CodegenTypes.DirectEventHandler<NativeContentPressEvent>;
28
34
  }
29
35
 
30
36
  export default codegenNativeComponent<NativeMarqueeViewProps>(
@@ -9,6 +9,7 @@ export const Marquee = /*#__PURE__*/forwardRef((props, ref) => {
9
9
  accessibilityLabel,
10
10
  children,
11
11
  contentContainerStyle,
12
+ onContentPress,
12
13
  style
13
14
  } = props;
14
15
  const viewProps = getViewProps(props);
@@ -22,7 +23,11 @@ export const Marquee = /*#__PURE__*/forwardRef((props, ref) => {
22
23
  children: /*#__PURE__*/_jsx(View, {
23
24
  accessibilityElementsHidden: true,
24
25
  importantForAccessibility: "no-hide-descendants",
25
- pointerEvents: "none",
26
+ onResponderRelease: event => onContentPress?.({
27
+ x: event.nativeEvent.locationX
28
+ }),
29
+ onStartShouldSetResponder: () => onContentPress !== undefined,
30
+ pointerEvents: onContentPress ? 'box-only' : 'none',
26
31
  style: contentContainerStyle,
27
32
  children: children
28
33
  })
@@ -1 +1 @@
1
- {"version":3,"names":["forwardRef","View","getViewProps","jsx","_jsx","Marquee","props","ref","accessibilityLabel","children","contentContainerStyle","style","viewProps","accessibilityRole","accessible","accessibilityElementsHidden","importantForAccessibility","pointerEvents","displayName"],"sourceRoot":"../../src","sources":["marquee.tsx"],"mappings":";;AAAA,SAASA,UAAU,QAA2B,OAAO;AACrD,SAASC,IAAI,QAAQ,cAAc;AAGnC,SAASC,YAAY,QAAQ,iBAAc;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAE5C,OAAO,MAAMC,OAAO,gBAAGL,UAAU,CAC/B,CAACM,KAAK,EAAEC,GAAG,KAAK;EACd,MAAM;IAAEC,kBAAkB;IAAEC,QAAQ;IAAEC,qBAAqB;IAAEC;EAAM,CAAC,GAClEL,KAAK;EACP,MAAMM,SAAS,GAAGV,YAAY,CAACI,KAAK,CAAC;EAErC,oBACEF,IAAA,CAACH,IAAI;IAAA,GACCW,SAAS;IACbJ,kBAAkB,EAAEA,kBAAmB;IACvCK,iBAAiB,EAAED,SAAS,CAACC,iBAAiB,IAAI,MAAO;IACzDC,UAAU;IACVP,GAAG,EAAEA,GAAI;IACTI,KAAK,EAAEA,KAAM;IAAAF,QAAA,eAEbL,IAAA,CAACH,IAAI;MACHc,2BAA2B;MAC3BC,yBAAyB,EAAC,qBAAqB;MAC/CC,aAAa,EAAC,MAAM;MACpBN,KAAK,EAAED,qBAAsB;MAAAD,QAAA,EAE5BA;IAAQ,CACL;EAAC,CACH,CAAC;AAEX,CACF,CAAC;AAEDJ,OAAO,CAACa,WAAW,GAAG,SAAS","ignoreList":[]}
1
+ {"version":3,"names":["forwardRef","View","getViewProps","jsx","_jsx","Marquee","props","ref","accessibilityLabel","children","contentContainerStyle","onContentPress","style","viewProps","accessibilityRole","accessible","accessibilityElementsHidden","importantForAccessibility","onResponderRelease","event","x","nativeEvent","locationX","onStartShouldSetResponder","undefined","pointerEvents","displayName"],"sourceRoot":"../../src","sources":["marquee.tsx"],"mappings":";;AAAA,SAASA,UAAU,QAA2B,OAAO;AACrD,SAASC,IAAI,QAAQ,cAAc;AAGnC,SAASC,YAAY,QAAQ,iBAAc;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAE5C,OAAO,MAAMC,OAAO,gBAAGL,UAAU,CAC/B,CAACM,KAAK,EAAEC,GAAG,KAAK;EACd,MAAM;IACJC,kBAAkB;IAClBC,QAAQ;IACRC,qBAAqB;IACrBC,cAAc;IACdC;EACF,CAAC,GAAGN,KAAK;EACT,MAAMO,SAAS,GAAGX,YAAY,CAACI,KAAK,CAAC;EAErC,oBACEF,IAAA,CAACH,IAAI;IAAA,GACCY,SAAS;IACbL,kBAAkB,EAAEA,kBAAmB;IACvCM,iBAAiB,EAAED,SAAS,CAACC,iBAAiB,IAAI,MAAO;IACzDC,UAAU;IACVR,GAAG,EAAEA,GAAI;IACTK,KAAK,EAAEA,KAAM;IAAAH,QAAA,eAEbL,IAAA,CAACH,IAAI;MACHe,2BAA2B;MAC3BC,yBAAyB,EAAC,qBAAqB;MAC/CC,kBAAkB,EAAGC,KAAK,IACxBR,cAAc,GAAG;QAAES,CAAC,EAAED,KAAK,CAACE,WAAW,CAACC;MAAU,CAAC,CACpD;MACDC,yBAAyB,EAAEA,CAAA,KAAMZ,cAAc,KAAKa,SAAU;MAC9DC,aAAa,EAAEd,cAAc,GAAG,UAAU,GAAG,MAAO;MACpDC,KAAK,EAAEF,qBAAsB;MAAAD,QAAA,EAE5BA;IAAQ,CACL;EAAC,CACH,CAAC;AAEX,CACF,CAAC;AAEDJ,OAAO,CAACqB,WAAW,GAAG,SAAS","ignoreList":[]}
@@ -23,6 +23,7 @@ export const Marquee = /*#__PURE__*/forwardRef((props, ref) => {
23
23
  interaction,
24
24
  onAnimationStateChange,
25
25
  onContentLayout,
26
+ onContentPress,
26
27
  reduceMotion: reduceMotionPolicy = 'system',
27
28
  shortContentMode = 'static',
28
29
  spacing: spacingProp = 0,
@@ -50,6 +51,11 @@ export const Marquee = /*#__PURE__*/forwardRef((props, ref) => {
50
51
  const handleContentLayout = useCallback(event => {
51
52
  onContentLayout?.(event.nativeEvent);
52
53
  }, [onContentLayout]);
54
+ const handleContentPress = useCallback(event => {
55
+ onContentPress?.({
56
+ x: event.nativeEvent.x
57
+ });
58
+ }, [onContentPress]);
53
59
  return /*#__PURE__*/_jsx(NativeMarqueeView, {
54
60
  ...viewProps,
55
61
  accessibilityLabel: accessibilityLabel,
@@ -58,6 +64,7 @@ export const Marquee = /*#__PURE__*/forwardRef((props, ref) => {
58
64
  accessible: true,
59
65
  active: active,
60
66
  contentAlignment: contentAlignment,
67
+ contentPressEnabled: onContentPress !== undefined,
61
68
  contentWidth: contentWidth,
62
69
  deceleration: resolvedInteraction.deceleration,
63
70
  direction: direction,
@@ -65,6 +72,7 @@ export const Marquee = /*#__PURE__*/forwardRef((props, ref) => {
65
72
  maxFlingVelocity: resolvedInteraction.maxFlingVelocity,
66
73
  onAnimationStateChange: onAnimationStateChange ? handleAnimationStateChange : undefined,
67
74
  onContentLayout: onContentLayout ? handleContentLayout : undefined,
75
+ onContentPress: onContentPress ? handleContentPress : undefined,
68
76
  pauseOnPress: resolvedInteraction.pauseOnPress,
69
77
  reduceMotion: reduceMotion,
70
78
  ref: ref,
@@ -1 +1 @@
1
- {"version":3,"names":["forwardRef","useCallback","useMemo","useState","StyleSheet","View","NativeMarqueeView","resolveAnimationState","resolveMeasuredContentWidth","resolveInteraction","resolveSpacing","resolveSpeed","useMarqueeReducedMotion","jsx","_jsx","NATIVE_SHORT_CONTENT_MODES","repeat","static","Marquee","props","ref","accessibilityLabel","active","children","contentAlignment","contentContainerStyle","direction","interaction","onAnimationStateChange","onContentLayout","reduceMotion","reduceMotionPolicy","shortContentMode","spacing","spacingProp","speed","speedProp","style","viewProps","contentWidth","setContentWidth","resolvedInteraction","handleContentContainerLayout","event","nextWidth","nativeEvent","layout","width","currentWidth","handleAnimationStateChange","state","handleContentLayout","accessibilityLiveRegion","accessibilityRole","accessible","deceleration","importantForAccessibility","maxFlingVelocity","undefined","pauseOnPress","resumeDelayMs","resumeDelay","accessibilityElementsHidden","collapsable","onLayout","pointerEvents","styles","content","displayName","create","alignSelf","flexDirection","flexShrink"],"sourceRoot":"../../src","sources":["marquee.native.tsx"],"mappings":";;AAAA,SACEA,UAAU,EACVC,WAAW,EACXC,OAAO,EACPC,QAAQ,QAEH,OAAO;AACd,SACEC,UAAU,EACVC,IAAI,QAGC,cAAc;AAErB,OAAOC,iBAAiB,MAAM,gCAAgC;AAC9D,SAASC,qBAAqB,QAAQ,sBAAmB;AACzD,SAASC,2BAA2B,QAAQ,wBAAqB;AACjE,SACEC,kBAAkB,EAClBC,cAAc,EACdC,YAAY,QACP,uBAAoB;AAE3B,SAASC,uBAAuB,QAAQ,yBAAsB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAS/D,MAAMC,0BAA0B,GAAG;EACjCC,MAAM,EAAE,QAAQ;EAChBC,MAAM,EAAE;AACV,CAAU;AAEV,OAAO,MAAMC,OAAO,gBAAGlB,UAAU,CAG/B,CAACmB,KAAK,EAAEC,GAAG,KAAK;EAChB,MAAM;IACJC,kBAAkB;IAClBC,MAAM,GAAG,IAAI;IACbC,QAAQ;IACRC,gBAAgB,GAAG,OAAO;IAC1BC,qBAAqB;IACrBC,SAAS,GAAG,MAAM;IAClBC,WAAW;IACXC,sBAAsB;IACtBC,eAAe;IACfC,YAAY,EAAEC,kBAAkB,GAAG,QAAQ;IAC3CC,gBAAgB,GAAG,QAAQ;IAC3BC,OAAO,EAAEC,WAAW,GAAG,CAAC;IACxBC,KAAK,EAAEC,SAAS,GAAG,EAAE;IACrBC,KAAK;IACL,GAAGC;EACL,CAAC,GAAGnB,KAAK;EACT,MAAM,CAACoB,YAAY,EAAEC,eAAe,CAAC,GAAGrC,QAAQ,CAAC,CAAC,CAAC;EACnD,MAAM2B,YAAY,GAAGlB,uBAAuB,CAACmB,kBAAkB,CAAC;EAChE,MAAMU,mBAAmB,GAAGvC,OAAO,CACjC,MAAMO,kBAAkB,CAAC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ACpBA,sBAAsB,GAAGqB,0BAA0B,GAAGS,SACvD;IACD7B,eAAe,EAAEA,eAAe,GAAGsB,mBAAmB,GAAGO,SAAU;IACnEC,YAAY,EAAElB,mBAAmB,CAACkB,YAAa;IAC/C7B,YAAY,EAAEA,YAAa;IAC3BV,GAAG,EAAEA,GAAI;IACTwC,aAAa,EAAEnB,mBAAmB,CAACoB,WAAY;IAC/C7B,gBAAgB,EAAEjB,0BAA0B,CAACiB,gBAAgB,CAAE;IAC/DC,OAAO,EAAEA,OAAQ;IACjBE,KAAK,EAAEA,KAAM;IACbE,KAAK,EAAEA,KAAM;IAAAd,QAAA,eAEbT,IAAA,CAACT,IAAI;MACHyD,2BAA2B;MAC3BC,WAAW,EAAE,KAAM;MACnBP,yBAAyB,EAAC,qBAAqB;MAC/CQ,QAAQ,EAAEtB,4BAA6B;MACvCuB,aAAa,EAAC,MAAM;MACpB5B,KAAK,EAAE,CAAC6B,MAAM,CAACC,OAAO,EAAE1C,qBAAqB,CAAE;MAAAF,QAAA,EAE9CA;IAAQ,CACL;EAAC,CACU,CAAC;AAExB,CAAC,CAAC;AAEFL,OAAO,CAACkD,WAAW,GAAG,SAAS;AAE/B,MAAMF,MAAM,GAAG9D,UAAU,CAACiE,MAAM,CAAC;EAC/BF,OAAO,EAAE;IACPG,SAAS,EAAE,YAAY;IACvBC,aAAa,EAAE,KAAK;IACpBC,UAAU,EAAE;EACd;AACF,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["forwardRef","useCallback","useMemo","useState","StyleSheet","View","NativeMarqueeView","resolveAnimationState","resolveMeasuredContentWidth","resolveInteraction","resolveSpacing","resolveSpeed","useMarqueeReducedMotion","jsx","_jsx","NATIVE_SHORT_CONTENT_MODES","repeat","static","Marquee","props","ref","accessibilityLabel","active","children","contentAlignment","contentContainerStyle","direction","interaction","onAnimationStateChange","onContentLayout","onContentPress","reduceMotion","reduceMotionPolicy","shortContentMode","spacing","spacingProp","speed","speedProp","style","viewProps","contentWidth","setContentWidth","resolvedInteraction","handleContentContainerLayout","event","nextWidth","nativeEvent","layout","width","currentWidth","handleAnimationStateChange","state","handleContentLayout","handleContentPress","x","accessibilityLiveRegion","accessibilityRole","accessible","contentPressEnabled","undefined","deceleration","importantForAccessibility","maxFlingVelocity","pauseOnPress","resumeDelayMs","resumeDelay","accessibilityElementsHidden","collapsable","onLayout","pointerEvents","styles","content","displayName","create","alignSelf","flexDirection","flexShrink"],"sourceRoot":"../../src","sources":["marquee.native.tsx"],"mappings":";;AAAA,SACEA,UAAU,EACVC,WAAW,EACXC,OAAO,EACPC,QAAQ,QAEH,OAAO;AACd,SACEC,UAAU,EACVC,IAAI,QAGC,cAAc;AAErB,OAAOC,iBAAiB,MAAM,gCAAgC;AAC9D,SAASC,qBAAqB,QAAQ,sBAAmB;AACzD,SAASC,2BAA2B,QAAQ,wBAAqB;AACjE,SACEC,kBAAkB,EAClBC,cAAc,EACdC,YAAY,QACP,uBAAoB;AAE3B,SAASC,uBAAuB,QAAQ,yBAAsB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAU/D,MAAMC,0BAA0B,GAAG;EACjCC,MAAM,EAAE,QAAQ;EAChBC,MAAM,EAAE;AACV,CAAU;AAEV,OAAO,MAAMC,OAAO,gBAAGlB,UAAU,CAG/B,CAACmB,KAAK,EAAEC,GAAG,KAAK;EAChB,MAAM;IACJC,kBAAkB;IAClBC,MAAM,GAAG,IAAI;IACbC,QAAQ;IACRC,gBAAgB,GAAG,OAAO;IAC1BC,qBAAqB;IACrBC,SAAS,GAAG,MAAM;IAClBC,WAAW;IACXC,sBAAsB;IACtBC,eAAe;IACfC,cAAc;IACdC,YAAY,EAAEC,kBAAkB,GAAG,QAAQ;IAC3CC,gBAAgB,GAAG,QAAQ;IAC3BC,OAAO,EAAEC,WAAW,GAAG,CAAC;IACxBC,KAAK,EAAEC,SAAS,GAAG,EAAE;IACrBC,KAAK;IACL,GAAGC;EACL,CAAC,GAAGpB,KAAK;EACT,MAAM,CAACqB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,CAACqE,MAAM,CAAC;EAC/BF,OAAO,EAAE;IACPG,SAAS,EAAE,YAAY;IACvBC,aAAa,EAAE,KAAK;IACpBC,UAAU,EAAE;EACd;AACF,CAAC,CAAC","ignoreList":[]}
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
 
3
- const COMPONENT_PROP_KEYS = new Set(['accessibilityLabel', 'active', 'children', 'contentAlignment', 'contentContainerStyle', 'direction', 'interaction', 'onAnimationStateChange', 'onContentLayout', 'reduceMotion', 'shortContentMode', 'spacing', 'speed', 'style']);
3
+ const COMPONENT_PROP_KEYS = new Set(['accessibilityLabel', 'active', 'children', 'contentAlignment', 'contentContainerStyle', 'direction', 'interaction', 'onAnimationStateChange', 'onContentLayout', 'onContentPress', 'reduceMotion', 'shortContentMode', 'spacing', 'speed', 'style']);
4
4
  export const getViewProps = props => Object.fromEntries(Object.entries(props).filter(([key]) => !COMPONENT_PROP_KEYS.has(key)));
5
5
  //# sourceMappingURL=view-props.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["COMPONENT_PROP_KEYS","Set","getViewProps","props","Object","fromEntries","entries","filter","key","has"],"sourceRoot":"../../src","sources":["view-props.ts"],"mappings":";;AAGA,MAAMA,mBAAmB,GAAG,IAAIC,GAAG,CAAC,CAClC,oBAAoB,EACpB,QAAQ,EACR,UAAU,EACV,kBAAkB,EAClB,uBAAuB,EACvB,WAAW,EACX,aAAa,EACb,wBAAwB,EACxB,iBAAiB,EACjB,cAAc,EACd,kBAAkB,EAClB,SAAS,EACT,OAAO,EACP,OAAO,CACR,CAAC;AAEF,OAAO,MAAMC,YAAY,GAAIC,KAAmB,IAC9CC,MAAM,CAACC,WAAW,CAChBD,MAAM,CAACE,OAAO,CAACH,KAAK,CAAC,CAACI,MAAM,CAAC,CAAC,CAACC,GAAG,CAAC,KAAK,CAACR,mBAAmB,CAACS,GAAG,CAACD,GAAG,CAAC,CACvE,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["COMPONENT_PROP_KEYS","Set","getViewProps","props","Object","fromEntries","entries","filter","key","has"],"sourceRoot":"../../src","sources":["view-props.ts"],"mappings":";;AAGA,MAAMA,mBAAmB,GAAG,IAAIC,GAAG,CAAC,CAClC,oBAAoB,EACpB,QAAQ,EACR,UAAU,EACV,kBAAkB,EAClB,uBAAuB,EACvB,WAAW,EACX,aAAa,EACb,wBAAwB,EACxB,iBAAiB,EACjB,gBAAgB,EAChB,cAAc,EACd,kBAAkB,EAClB,SAAS,EACT,OAAO,EACP,OAAO,CACR,CAAC;AAEF,OAAO,MAAMC,YAAY,GAAIC,KAAmB,IAC9CC,MAAM,CAACC,WAAW,CAChBD,MAAM,CAACE,OAAO,CAACH,KAAK,CAAC,CAACI,MAAM,CAAC,CAAC,CAACC,GAAG,CAAC,KAAK,CAACR,mBAAmB,CAACS,GAAG,CAACD,GAAG,CAAC,CACvE,CAAC","ignoreList":[]}
@@ -7,6 +7,9 @@ type NativeContentLayoutEvent = Readonly<{
7
7
  contentWidth: CodegenTypes.Float;
8
8
  containerWidth: CodegenTypes.Float;
9
9
  }>;
10
+ type NativeContentPressEvent = Readonly<{
11
+ x: CodegenTypes.Float;
12
+ }>;
10
13
  export interface NativeMarqueeViewProps extends ViewProps {
11
14
  active: boolean;
12
15
  reduceMotion: boolean;
@@ -19,9 +22,11 @@ export interface NativeMarqueeViewProps extends ViewProps {
19
22
  maxFlingVelocity: CodegenTypes.Float;
20
23
  deceleration: CodegenTypes.Float;
21
24
  pauseOnPress: boolean;
25
+ contentPressEnabled: boolean;
22
26
  resumeDelayMs: CodegenTypes.Double;
23
27
  onAnimationStateChange?: CodegenTypes.DirectEventHandler<NativeAnimationStateEvent>;
24
28
  onContentLayout?: CodegenTypes.DirectEventHandler<NativeContentLayoutEvent>;
29
+ onContentPress?: CodegenTypes.DirectEventHandler<NativeContentPressEvent>;
25
30
  }
26
31
  declare const _default: HostComponent<NativeMarqueeViewProps>;
27
32
  export default _default;
@@ -1 +1 @@
1
- {"version":3,"file":"RNMarqueeViewNativeComponent.d.ts","sourceRoot":"","sources":["../../../src/RNMarqueeViewNativeComponent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC7D,OAAO,EAA0B,KAAK,YAAY,EAAE,MAAM,cAAc,CAAC;AAEzE,KAAK,yBAAyB,GAAG,QAAQ,CAAC;IACxC,KAAK,EAAE,MAAM,CAAC;CACf,CAAC,CAAC;AAEH,KAAK,wBAAwB,GAAG,QAAQ,CAAC;IACvC,YAAY,EAAE,YAAY,CAAC,KAAK,CAAC;IACjC,cAAc,EAAE,YAAY,CAAC,KAAK,CAAC;CACpC,CAAC,CAAC;AAEH,MAAM,WAAW,sBAAuB,SAAQ,SAAS;IACvD,MAAM,EAAE,OAAO,CAAC;IAChB,YAAY,EAAE,OAAO,CAAC;IACtB,KAAK,EAAE,YAAY,CAAC,MAAM,CAAC;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,gBAAgB,EAAE,MAAM,CAAC;IACzB,gBAAgB,EAAE,MAAM,CAAC;IACzB,YAAY,EAAE,YAAY,CAAC,KAAK,CAAC;IACjC,OAAO,EAAE,YAAY,CAAC,KAAK,CAAC;IAC5B,gBAAgB,EAAE,YAAY,CAAC,KAAK,CAAC;IACrC,YAAY,EAAE,YAAY,CAAC,KAAK,CAAC;IACjC,YAAY,EAAE,OAAO,CAAC;IACtB,aAAa,EAAE,YAAY,CAAC,MAAM,CAAC;IACnC,sBAAsB,CAAC,EAAE,YAAY,CAAC,kBAAkB,CAAC,yBAAyB,CAAC,CAAC;IACpF,eAAe,CAAC,EAAE,YAAY,CAAC,kBAAkB,CAAC,wBAAwB,CAAC,CAAC;CAC7E;wBAII,aAAa,CAAC,sBAAsB,CAAC;AAF1C,wBAE2C"}
1
+ {"version":3,"file":"RNMarqueeViewNativeComponent.d.ts","sourceRoot":"","sources":["../../../src/RNMarqueeViewNativeComponent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAA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1,3 @@
1
1
  export { Marquee } from './marquee';
2
- export type { MarqueeAnimationState, MarqueeAnimationStateEvent, MarqueeContentAlignment, MarqueeContentLayoutEvent, MarqueeDirection, MarqueeInteraction, MarqueeProps, MarqueeReduceMotion, MarqueeShortContentMode, } from './types.js';
2
+ export type { MarqueeAnimationState, MarqueeAnimationStateEvent, MarqueeContentAlignment, MarqueeContentLayoutEvent, MarqueeContentPressEvent, MarqueeDirection, MarqueeInteraction, MarqueeProps, MarqueeReduceMotion, MarqueeShortContentMode, } from './types.js';
3
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,YAAY,EACV,qBAAqB,EACrB,0BAA0B,EAC1B,uBAAuB,EACvB,yBAAyB,EACzB,gBAAgB,EAChB,kBAAkB,EAClB,YAAY,EACZ,mBAAmB,EACnB,uBAAuB,GACxB,MAAM,YAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,YAAY,EACV,qBAAqB,EACrB,0BAA0B,EAC1B,uBAAuB,EACvB,yBAAyB,EACzB,wBAAwB,EACxB,gBAAgB,EAChB,kBAAkB,EAClB,YAAY,EACZ,mBAAmB,EACnB,uBAAuB,GACxB,MAAM,YAAS,CAAC"}
@@ -293,6 +293,7 @@ export declare const Marquee: import("react").ForwardRefExoticComponent<{
293
293
  interaction?: import("./types.js").MarqueeInteraction;
294
294
  onAnimationStateChange?: (event: import("./types.js").MarqueeAnimationStateEvent) => void;
295
295
  onContentLayout?: (event: import("./types.js").MarqueeContentLayoutEvent) => void;
296
+ onContentPress?: (event: import("./types.js").MarqueeContentPressEvent) => void;
296
297
  reduceMotion?: import("./types.js").MarqueeReduceMotion;
297
298
  shortContentMode?: import("./types.js").MarqueeShortContentMode;
298
299
  spacing?: number;
@@ -1 +1 @@
1
- {"version":3,"file":"marquee.d.ts","sourceRoot":"","sources":["../../../src/marquee.tsx"],"names":[],"mappings":"AAMA,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA6BohxB,CAAC;kBAAoB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAAtB,CAAC;kBAAoB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oIAH7jxB,CAAC"}
1
+ {"version":3,"file":"marquee.d.ts","sourceRoot":"","sources":["../../../src/marquee.tsx"],"names":[],"mappings":"AAMA,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAsCwwwB,CAAC;kBAAoB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAAtB,CAAC;kBAAoB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oIAHjzwB,CAAC"}
@@ -294,6 +294,7 @@ export declare const Marquee: import("react").ForwardRefExoticComponent<{
294
294
  interaction?: import("./types.js").MarqueeInteraction;
295
295
  onAnimationStateChange?: (event: import("./types.js").MarqueeAnimationStateEvent) => void;
296
296
  onContentLayout?: (event: import("./types.js").MarqueeContentLayoutEvent) => void;
297
+ onContentPress?: (event: import("./types.js").MarqueeContentPressEvent) => void;
297
298
  reduceMotion?: import("./types.js").MarqueeReduceMotion;
298
299
  shortContentMode?: import("./types.js").MarqueeShortContentMode;
299
300
  spacing?: number;
@@ -1 +1 @@
1
- {"version":3,"file":"marquee.native.d.ts","sourceRoot":"","sources":["../../../src/marquee.native.tsx"],"names":[],"mappings":"AAOA,OAAO,EAGL,KAAK,iBAAiB,EAEvB,MAAM,cAAc,CAAC;AAyBtB,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA2GgmrB,CAAC;kBAAoB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAAtB,CAAC;kBAAoB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oIAXxorB,CAAC"}
1
+ {"version":3,"file":"marquee.native.d.ts","sourceRoot":"","sources":["../../../src/marquee.native.tsx"],"names":[],"mappings":"AAOA,OAAO,EAGL,KAAK,iBAAiB,EAEvB,MAAM,cAAc,CAAC;AA0BtB,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAqHotqB,CAAC;kBAAoB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAAtB,CAAC;kBAAoB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oIAX5vqB,CAAC"}
@@ -12,6 +12,10 @@ export type MarqueeContentLayoutEvent = Readonly<{
12
12
  containerWidth: number;
13
13
  contentWidth: number;
14
14
  }>;
15
+ /** `x` is in the content container's own coordinates for one copy: `[0, contentWidth)`. */
16
+ export type MarqueeContentPressEvent = Readonly<{
17
+ x: number;
18
+ }>;
15
19
  export type MarqueeInteraction = Readonly<{
16
20
  maxFlingVelocity?: number;
17
21
  /** Unitless velocity retention per millisecond, greater than 0 and below 1. */
@@ -22,7 +26,7 @@ export type MarqueeInteraction = Readonly<{
22
26
  }>;
23
27
  type InheritedViewProps = Omit<ViewProps, 'accessibilityElementsHidden' | 'accessibilityLabel' | 'children' | 'importantForAccessibility' | 'style'>;
24
28
  export type MarqueeProps = InheritedViewProps & Readonly<{
25
- /** One noninteractive visual strip. React state is mounted exactly once. */
29
+ /** One visual strip. React state is mounted exactly once; descendants receive no touches. */
26
30
  children: ReactNode;
27
31
  /** A single semantic description for all visually repeated content. */
28
32
  accessibilityLabel: string;
@@ -34,6 +38,8 @@ export type MarqueeProps = InheritedViewProps & Readonly<{
34
38
  interaction?: MarqueeInteraction;
35
39
  onAnimationStateChange?: (event: MarqueeAnimationStateEvent) => void;
36
40
  onContentLayout?: (event: MarqueeContentLayoutEvent) => void;
41
+ /** A tap on any visual copy. Taps in the spacing gap or outside static content do not fire. */
42
+ onContentPress?: (event: MarqueeContentPressEvent) => void;
37
43
  reduceMotion?: MarqueeReduceMotion;
38
44
  shortContentMode?: MarqueeShortContentMode;
39
45
  /** Empty distance between the end of one visual copy and the next. */
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEpE,MAAM,MAAM,gBAAgB,GAAG,MAAM,GAAG,OAAO,CAAC;AAChD,MAAM,MAAM,mBAAmB,GAAG,QAAQ,GAAG,QAAQ,GAAG,OAAO,CAAC;AAChE,MAAM,MAAM,uBAAuB,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAC1D,MAAM,MAAM,uBAAuB,GAAG,OAAO,GAAG,QAAQ,GAAG,KAAK,CAAC;AACjE,MAAM,MAAM,qBAAqB,GAC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AE,YAAY,EAAE,MAAM,YAAS,CAAC;AAmB5C,eAAO,MAAM,YAAY,GAAI,OAAO,YAAY,KAAG,SAGhD,CAAC"}
1
+ {"version":3,"file":"view-props.d.ts","sourceRoot":"","sources":["../../../src/view-props.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAS,CAAC;AAoB5C,eAAO,MAAM,YAAY,GAAI,OAAO,YAAY,KAAG,SAGhD,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-marquee-animation",
3
- "version": "0.1.3",
3
+ "version": "0.2.0",
4
4
  "description": "Production-grade generic native marquee for React Native",
5
5
  "main": "./lib/module/index.js",
6
6
  "react-native": "./src/index.ts",
@@ -70,12 +70,12 @@
70
70
  "type": "git",
71
71
  "url": "git+https://github.com/invivek26/react-native-marquee-animation.git"
72
72
  },
73
- "author": "Vivek Indlebele Narasimha Prasad (https://github.com/invivek26)",
73
+ "author": "Vivek Indlebele Narasimha Prasad <vivek@gamestock.app> (https://viveks.app)",
74
74
  "license": "MIT",
75
75
  "bugs": {
76
76
  "url": "https://github.com/invivek26/react-native-marquee-animation/issues"
77
77
  },
78
- "homepage": "https://github.com/invivek26/react-native-marquee-animation#readme",
78
+ "homepage": "https://viveks.app/open-source",
79
79
  "publishConfig": {
80
80
  "access": "public",
81
81
  "provenance": true,
@@ -10,6 +10,10 @@ type NativeContentLayoutEvent = Readonly<{
10
10
  containerWidth: CodegenTypes.Float;
11
11
  }>;
12
12
 
13
+ type NativeContentPressEvent = Readonly<{
14
+ x: CodegenTypes.Float;
15
+ }>;
16
+
13
17
  export interface NativeMarqueeViewProps extends ViewProps {
14
18
  active: boolean;
15
19
  reduceMotion: boolean;
@@ -22,9 +26,11 @@ export interface NativeMarqueeViewProps extends ViewProps {
22
26
  maxFlingVelocity: CodegenTypes.Float;
23
27
  deceleration: CodegenTypes.Float;
24
28
  pauseOnPress: boolean;
29
+ contentPressEnabled: boolean;
25
30
  resumeDelayMs: CodegenTypes.Double;
26
31
  onAnimationStateChange?: CodegenTypes.DirectEventHandler<NativeAnimationStateEvent>;
27
32
  onContentLayout?: CodegenTypes.DirectEventHandler<NativeContentLayoutEvent>;
33
+ onContentPress?: CodegenTypes.DirectEventHandler<NativeContentPressEvent>;
28
34
  }
29
35
 
30
36
  export default codegenNativeComponent<NativeMarqueeViewProps>(
package/src/index.ts CHANGED
@@ -4,6 +4,7 @@ export type {
4
4
  MarqueeAnimationStateEvent,
5
5
  MarqueeContentAlignment,
6
6
  MarqueeContentLayoutEvent,
7
+ MarqueeContentPressEvent,
7
8
  MarqueeDirection,
8
9
  MarqueeInteraction,
9
10
  MarqueeProps,
@@ -29,6 +29,7 @@ type NativeAnimationStateEvent = NativeSyntheticEvent<
29
29
  type NativeContentLayoutEvent = NativeSyntheticEvent<
30
30
  Readonly<{ containerWidth: number; contentWidth: number }>
31
31
  >;
32
+ type NativeContentPressEvent = NativeSyntheticEvent<Readonly<{ x: number }>>;
32
33
 
33
34
  const NATIVE_SHORT_CONTENT_MODES = {
34
35
  repeat: 'repeat',
@@ -49,6 +50,7 @@ export const Marquee = forwardRef<
49
50
  interaction,
50
51
  onAnimationStateChange,
51
52
  onContentLayout,
53
+ onContentPress,
52
54
  reduceMotion: reduceMotionPolicy = 'system',
53
55
  shortContentMode = 'static',
54
56
  spacing: spacingProp = 0,
@@ -92,6 +94,13 @@ export const Marquee = forwardRef<
92
94
  [onContentLayout]
93
95
  );
94
96
 
97
+ const handleContentPress = useCallback(
98
+ (event: NativeContentPressEvent) => {
99
+ onContentPress?.({ x: event.nativeEvent.x });
100
+ },
101
+ [onContentPress]
102
+ );
103
+
95
104
  return (
96
105
  <NativeMarqueeView
97
106
  {...viewProps}
@@ -101,6 +110,7 @@ export const Marquee = forwardRef<
101
110
  accessible
102
111
  active={active}
103
112
  contentAlignment={contentAlignment}
113
+ contentPressEnabled={onContentPress !== undefined}
104
114
  contentWidth={contentWidth}
105
115
  deceleration={resolvedInteraction.deceleration}
106
116
  direction={direction}
@@ -110,6 +120,7 @@ export const Marquee = forwardRef<
110
120
  onAnimationStateChange ? handleAnimationStateChange : undefined
111
121
  }
112
122
  onContentLayout={onContentLayout ? handleContentLayout : undefined}
123
+ onContentPress={onContentPress ? handleContentPress : undefined}
113
124
  pauseOnPress={resolvedInteraction.pauseOnPress}
114
125
  reduceMotion={reduceMotion}
115
126
  ref={ref}
package/src/marquee.tsx CHANGED
@@ -6,8 +6,13 @@ import { getViewProps } from './view-props';
6
6
 
7
7
  export const Marquee = forwardRef<ComponentRef<typeof View>, MarqueeProps>(
8
8
  (props, ref) => {
9
- const { accessibilityLabel, children, contentContainerStyle, style } =
10
- props;
9
+ const {
10
+ accessibilityLabel,
11
+ children,
12
+ contentContainerStyle,
13
+ onContentPress,
14
+ style,
15
+ } = props;
11
16
  const viewProps = getViewProps(props);
12
17
 
13
18
  return (
@@ -22,7 +27,11 @@ export const Marquee = forwardRef<ComponentRef<typeof View>, MarqueeProps>(
22
27
  <View
23
28
  accessibilityElementsHidden
24
29
  importantForAccessibility="no-hide-descendants"
25
- pointerEvents="none"
30
+ onResponderRelease={(event) =>
31
+ onContentPress?.({ x: event.nativeEvent.locationX })
32
+ }
33
+ onStartShouldSetResponder={() => onContentPress !== undefined}
34
+ pointerEvents={onContentPress ? 'box-only' : 'none'}
26
35
  style={contentContainerStyle}
27
36
  >
28
37
  {children}
package/src/types.ts CHANGED
@@ -17,6 +17,11 @@ export type MarqueeContentLayoutEvent = Readonly<{
17
17
  contentWidth: number;
18
18
  }>;
19
19
 
20
+ /** `x` is in the content container's own coordinates for one copy: `[0, contentWidth)`. */
21
+ export type MarqueeContentPressEvent = Readonly<{
22
+ x: number;
23
+ }>;
24
+
20
25
  export type MarqueeInteraction = Readonly<{
21
26
  maxFlingVelocity?: number;
22
27
  /** Unitless velocity retention per millisecond, greater than 0 and below 1. */
@@ -37,7 +42,7 @@ type InheritedViewProps = Omit<
37
42
 
38
43
  export type MarqueeProps = InheritedViewProps &
39
44
  Readonly<{
40
- /** One noninteractive visual strip. React state is mounted exactly once. */
45
+ /** One visual strip. React state is mounted exactly once; descendants receive no touches. */
41
46
  children: ReactNode;
42
47
  /** A single semantic description for all visually repeated content. */
43
48
  accessibilityLabel: string;
@@ -49,6 +54,8 @@ export type MarqueeProps = InheritedViewProps &
49
54
  interaction?: MarqueeInteraction;
50
55
  onAnimationStateChange?: (event: MarqueeAnimationStateEvent) => void;
51
56
  onContentLayout?: (event: MarqueeContentLayoutEvent) => void;
57
+ /** A tap on any visual copy. Taps in the spacing gap or outside static content do not fire. */
58
+ onContentPress?: (event: MarqueeContentPressEvent) => void;
52
59
  reduceMotion?: MarqueeReduceMotion;
53
60
  shortContentMode?: MarqueeShortContentMode;
54
61
  /** Empty distance between the end of one visual copy and the next. */
package/src/view-props.ts CHANGED
@@ -11,6 +11,7 @@ const COMPONENT_PROP_KEYS = new Set([
11
11
  'interaction',
12
12
  'onAnimationStateChange',
13
13
  'onContentLayout',
14
+ 'onContentPress',
14
15
  'reduceMotion',
15
16
  'shortContentMode',
16
17
  'spacing',