react-native-marquee-animation 0.2.1 → 0.2.3

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
@@ -20,15 +20,15 @@ https://github.com/user-attachments/assets/9f4e1655-0f2c-468f-b0e4-25af40de5631
20
20
 
21
21
  ## Compatibility
22
22
 
23
- | Requirement | Supported |
24
- | ------------ | ---------------------------------------- |
25
- | React Native | 0.85.x |
26
- | React | 19.2.x |
27
- | Expo | SDK 56 development and production builds |
28
- | iOS | 17 and newer |
29
- | Android | API 24 and newer |
30
- | Architecture | New Architecture (Fabric) only |
31
- | Expo Go | No |
23
+ | Requirement | Supported |
24
+ | ------------ | ---------------------------------------------- |
25
+ | React Native | 0.85.x to 0.88.x |
26
+ | React | 19.2.x and 19.3.x |
27
+ | Expo | SDK 56 to 58 development and production builds |
28
+ | iOS | 17 and newer |
29
+ | Android | API 24 and newer |
30
+ | Architecture | New Architecture (Fabric) only |
31
+ | Expo Go | No |
32
32
 
33
33
  ## Installation
34
34
 
@@ -11,6 +11,7 @@ import android.view.VelocityTracker
11
11
  import android.view.View
12
12
  import android.view.ViewConfiguration
13
13
  import android.view.ViewGroup
14
+ import android.view.ViewTreeObserver
14
15
  import com.facebook.react.uimanager.PixelUtil
15
16
  import kotlin.math.abs
16
17
  import kotlin.math.hypot
@@ -39,6 +40,13 @@ class MarqueeView : ViewGroup, Choreographer.FrameCallback {
39
40
  private var pressContentX: Double? = null
40
41
  private val resumeRunnable = Runnable { reconcileMotionState() }
41
42
 
43
+ // doFrame stops the loop while the view is scrolled fully out of view, and
44
+ // scrolling an ancestor changes no prop, layout or visibility. Restart the
45
+ // loop on the next scroll that could bring it back.
46
+ private val scrollChangedListener = ViewTreeObserver.OnScrollChangedListener {
47
+ if (motion.isFrameDriven() && shouldScheduleMotion()) postFrame()
48
+ }
49
+
42
50
  init {
43
51
  setWillNotDraw(false)
44
52
  clipChildren = false
@@ -47,6 +55,8 @@ class MarqueeView : ViewGroup, Choreographer.FrameCallback {
47
55
  importantForAccessibility = IMPORTANT_FOR_ACCESSIBILITY_YES
48
56
  }
49
57
 
58
+ internal val testingPhasePx: Double get() = motion.phasePx
59
+
50
60
  internal fun setEventListener(listener: MarqueeEventListener?) {
51
61
  eventListener = listener
52
62
  }
@@ -226,12 +236,14 @@ class MarqueeView : ViewGroup, Choreographer.FrameCallback {
226
236
 
227
237
  override fun onAttachedToWindow() {
228
238
  super.onAttachedToWindow()
239
+ viewTreeObserver.addOnScrollChangedListener(scrollChangedListener)
229
240
  attachedAndVisible = isShown
230
241
  reconcileMotionState()
231
242
  }
232
243
 
233
244
  override fun onDetachedFromWindow() {
234
245
  attachedAndVisible = false
246
+ viewTreeObserver.removeOnScrollChangedListener(scrollChangedListener)
235
247
  removeCallbacks(resumeRunnable)
236
248
  stopFrames()
237
249
  motion.pause()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-marquee-animation",
3
- "version": "0.2.1",
3
+ "version": "0.2.3",
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",
@@ -115,7 +115,7 @@
115
115
  },
116
116
  "peerDependencies": {
117
117
  "react": ">=19.2.0 <20.0.0",
118
- "react-native": ">=0.85.0 <0.87.0"
118
+ "react-native": ">=0.85.0 <0.89.0"
119
119
  },
120
120
  "workspaces": [
121
121
  "example"