rn-marquee-text 2.0.5 → 2.0.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/README.md CHANGED
@@ -27,30 +27,35 @@ npm install rn-marquee-text react-native-reanimated react-native-gesture-handler
27
27
 
28
28
  # Using yarn
29
29
  yarn add rn-marquee-text react-native-reanimated react-native-gesture-handler
30
- Peer Dependencies Setup
31
- Follow Reanimated installation guide
30
+ ```
32
31
 
33
- Configure Gesture Handler
32
+ ### Peer Dependencies Setup
33
+ - Follow [Reanimated installation guide](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/installation)
34
+ - Configure [Gesture Handler](https://docs.swmansion.com/react-native-gesture-handler/docs/installation)
34
35
 
35
- Basic Usage 🚀
36
- jsx
37
- import MarqueeText from 'rn-marquee-text';
36
+ ## Basic Usage 🚀
37
+
38
+ ```jsx
39
+ import Marquee from 'rn-marquee-text';
38
40
 
39
41
  function App() {
40
42
  return (
41
- <MarqueeText
43
+ <Marquee.MarqueeText
42
44
  speed={50}
43
45
  style={{ height: 40 }}
44
46
  textStyle={{ fontSize: 16 }}
45
47
  >
46
48
  This text will scroll automatically!
47
- </MarqueeText>
49
+ </Marquee.MarqueeText>
48
50
  );
49
51
  }
50
- Advanced Usage 🧠
51
- Custom Animation Configuration
52
- jsx
53
- <MarqueeText
52
+ ```
53
+
54
+ ## Advanced Usage 🧠
55
+
56
+ ### Custom Animation Configuration
57
+ ```jsx
58
+ <Marquee.MarqueeText
54
59
  mode="bounce"
55
60
  direction="vertical"
56
61
  speed={30}
@@ -59,14 +64,16 @@ jsx
59
64
  spacing={30}
60
65
  >
61
66
  {yourCustomComponent}
62
- </MarqueeText>
63
- Imperative Control
64
- jsx
67
+ </Marquee.MarqueeText>
68
+ ```
69
+
70
+ ### Imperative Control
71
+ ```jsx
65
72
  const marqueeRef = useRef(null);
66
73
 
67
74
  // Start/pause programmatically
68
75
  <>
69
- <MarqueeText ref={marqueeRef} />
76
+ <Marquee.MarqueeText ref={marqueeRef} />
70
77
  <Button
71
78
  title="Toggle"
72
79
  onPress={() => marqueeRef.current?.isActive
@@ -74,37 +81,69 @@ const marqueeRef = useRef(null);
74
81
  : marqueeRef.current.start()
75
82
  }
76
83
  />
77
- </>```
78
-
79
- API Reference 📚
80
- Props
81
- Prop Type Default Description
82
- mode 'loop' | 'bounce' 'loop' Animation behavior
83
- speed number 30 Scroll speed (px/sec)
84
- direction 'horizontal' | 'vertical' 'horizontal' Scroll axis
85
- delay number 1500 Initial delay (ms)
86
- spacing number 20 Space between clones
87
- enabled boolean true Animation state
88
- Methods (via ref)
89
- typescript
90
- interface MarqueeRef {
84
+ </>
85
+ ```
86
+
87
+ ## API Reference 📚
88
+
89
+ ### Props
90
+
91
+ | Prop | Type | Default | Description |
92
+ |------|------|---------|-------------|
93
+ | `mode` | `'loop' \| 'bounce'` | `'loop'` | Animation behavior |
94
+ | `speed` | `number` | `30` | Scroll speed (px/sec) |
95
+ | `direction` | `'horizontal' \| 'vertical'` | `'horizontal'` | Scroll axis |
96
+ | `delay` | `number` | `1500` | Initial delay (ms) |
97
+ | `endPauseDuration` | `number` | `1000` | Pause duration at end (bounce mode) |
98
+ | `spacing` | `number` | `20` | Space between clones |
99
+ | `enabled` | `boolean` | `true` | Animation state |
100
+ | `withGesture` | `boolean` | `true` | Enable gesture interaction |
101
+ | `reverse` | `boolean` | `false` | Reverse animation direction |
102
+ | `backgroundColor` | `string` | `'transparent'` | Container background color |
103
+ | `frameRate` | `number` | `60` | Animation frame rate |
104
+ | `style` | `ViewStyle` | - | Container style |
105
+ | `textStyle` | `TextStyle` | - | Text style (when children is string) |
106
+ | `onAnimationStart` | `() => void` | - | Animation start callback |
107
+ | `onAnimationStop` | `() => void` | - | Animation stop callback |
108
+
109
+ ### Methods (via ref)
110
+
111
+ ```typescript
112
+ interface MarqueeTextRef {
91
113
  start: () => void;
92
114
  stop: () => void;
93
115
  isActive: boolean;
94
116
  }
95
- Examples 🎨
96
- News Ticker
97
- jsx
98
- <MarqueeText
117
+ ```
118
+
119
+ ## Examples 🎨
120
+
121
+ ### News Ticker
122
+ ```jsx
123
+ <Marquee.MarqueeText
99
124
  style={styles.ticker}
100
125
  textStyle={styles.tickerText}
101
126
  speed={40}
102
127
  >
103
128
  BREAKING: React Native Marquee Text released! • New version available • Check out the docs
104
- </MarqueeText>
105
- Vertical Product Carousel
106
- jsx
107
- <MarqueeText
129
+ </Marquee.MarqueeText>
130
+
131
+ const styles = StyleSheet.create({
132
+ ticker: {
133
+ backgroundColor: '#ff0000',
134
+ height: 30,
135
+ },
136
+ tickerText: {
137
+ color: 'white',
138
+ fontSize: 14,
139
+ fontWeight: 'bold',
140
+ },
141
+ });
142
+ ```
143
+
144
+ ### Vertical Product Carousel
145
+ ```jsx
146
+ <Marquee.MarqueeText
108
147
  direction="vertical"
109
148
  mode="bounce"
110
149
  speed={20}
@@ -113,34 +152,65 @@ jsx
113
152
  <ProductCard {...item1} />
114
153
  <ProductCard {...item2} />
115
154
  <ProductCard {...item3} />
116
- </MarqueeText>
117
- Troubleshooting ⚠️
118
- Animation not smooth?
119
-
120
- Ensure you're using Reanimated 2+
121
-
122
- Check for heavy renders in parent components
123
-
124
- Text not visible?
125
-
126
- Verify container has explicit dimensions
127
-
128
- Check text color contrast
129
-
130
- Gesture not working?
131
-
132
- Confirm Gesture Handler installation
133
-
134
- Wrap root component with GestureHandlerRootView
155
+ </Marquee.MarqueeText>
156
+ ```
157
+
158
+ ### Custom Component with High Speed
159
+ ```jsx
160
+ <Marquee.MarqueeText
161
+ style={styles.marquee}
162
+ speed={500}
163
+ textStyle={styles.text}
164
+ >
165
+ Smarty was created by the creators of React Native.
166
+ </Marquee.MarqueeText>
167
+
168
+ const styles = StyleSheet.create({
169
+ marquee: {
170
+ width: '100%',
171
+ height: 30,
172
+ },
173
+ text: {
174
+ fontSize: 16,
175
+ color: '#333'
176
+ }
177
+ });
178
+ ```
179
+
180
+ ## Troubleshooting ⚠️
181
+
182
+ ### Animation not smooth?
183
+ - Ensure you're using Reanimated 2+
184
+ - Check for heavy renders in parent components
185
+ - Try reducing the `frameRate` prop
186
+
187
+ ### Text not visible?
188
+ - Verify container has explicit dimensions
189
+ - Check text color contrast
190
+ - Ensure `textStyle` is properly applied
191
+
192
+ ### Gesture not working?
193
+ - Confirm Gesture Handler installation
194
+ - Wrap root component with `GestureHandlerRootView`
195
+ - Set `withGesture={true}` (default)
196
+
197
+ ### Performance Issues?
198
+ - Reduce `speed` for smoother animation
199
+ - Minimize `spacing` to reduce clone count
200
+ - Use `enabled={false}` when not needed
201
+
202
+ ## Contributing 🤝
135
203
 
136
- Contributing 🤝
137
204
  We welcome contributions! Please:
138
205
 
139
- Fork the repository
206
+ 1. Fork the repository
207
+ 2. Create a feature branch
208
+ 3. Submit a pull request
209
+
210
+ ## License 📄
140
211
 
141
- Create a feature branch
212
+ MIT © PARESH CHAVDA
142
213
 
143
- Submit a pull request
214
+ ---
144
215
 
145
- License 📄
146
- MIT © PARESH CHAVDA
216
+ Made with ❤️ for the React Native community
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
2
  import { TextStyle, ViewStyle } from 'react-native';
3
+ import { AnimationMode } from './constants';
3
4
  /**
4
5
  * AutoScroll component that measures its content and container
5
6
  * dimensions and automatically sets up a scrolling animation if
@@ -17,7 +18,7 @@ import { TextStyle, ViewStyle } from 'react-native';
17
18
  */
18
19
  declare const AutoScroll: ({ children, mode, speed, delay, endPauseDuration, style, textStyle, enabled, direction, }: {
19
20
  children: React.ReactNode;
20
- mode?: "loop" | "bounce";
21
+ mode?: AnimationMode;
21
22
  speed?: number;
22
23
  delay?: number;
23
24
  endPauseDuration?: number;
@@ -18,7 +18,7 @@ import { AnimationMode } from './constants';
18
18
  * @prop {'horizontal'|'vertical'} direction - The direction of the scrolling animation
19
19
  */
20
20
  var AutoScroll = function (_a) {
21
- var children = _a.children, _b = _a.mode, mode = _b === void 0 ? 'loop' : _b, _c = _a.speed, speed = _c === void 0 ? 30 : _c, _d = _a.delay, delay = _d === void 0 ? 1500 : _d, _e = _a.endPauseDuration, endPauseDuration = _e === void 0 ? 1000 : _e, _f = _a.style, style = _f === void 0 ? {} : _f, _g = _a.textStyle, textStyle = _g === void 0 ? {} : _g, _h = _a.enabled, enabled = _h === void 0 ? true : _h, _j = _a.direction, direction = _j === void 0 ? 'vertical' : _j;
21
+ var children = _a.children, _b = _a.mode, mode = _b === void 0 ? AnimationMode.LOOP : _b, _c = _a.speed, speed = _c === void 0 ? 30 : _c, _d = _a.delay, delay = _d === void 0 ? 1500 : _d, _e = _a.endPauseDuration, endPauseDuration = _e === void 0 ? 1000 : _e, _f = _a.style, style = _f === void 0 ? {} : _f, _g = _a.textStyle, textStyle = _g === void 0 ? {} : _g, _h = _a.enabled, enabled = _h === void 0 ? true : _h, _j = _a.direction, direction = _j === void 0 ? 'vertical' : _j;
22
22
  // References for measurement
23
23
  var containerRef = useRef(null);
24
24
  var contentRef = useRef(null);
@@ -88,7 +88,7 @@ var AutoScroll = function (_a) {
88
88
  console.log('Animation setup:', { distance: distance, duration: duration });
89
89
  // Reset position
90
90
  scrollPosition.value = 0;
91
- if (mode === AnimationMode.LOOP || mode === 'loop') {
91
+ if (mode === AnimationMode.LOOP) {
92
92
  // Continuous loop animation
93
93
  scrollPosition.value = withDelay(delay, withRepeat(withTiming(-distance, { duration: duration, easing: Easing.linear }), -1, false));
94
94
  }
@@ -115,6 +115,6 @@ export interface MarqueeTextRef {
115
115
  * modes, and user interaction via gestures.
116
116
  */
117
117
  declare const MarqueeText: React.ForwardRefExoticComponent<MarqueeTextProps & React.RefAttributes<MarqueeTextRef>>;
118
- export default MarqueeText;
119
118
  export { AnimationMode };
120
119
  export type { MarqueeDirection, MarqueeTextProps };
120
+ export default MarqueeText;
@@ -2,7 +2,6 @@ import * as React from 'react';
2
2
  import { StyleSheet, View, Text } from 'react-native';
3
3
  import { Gesture, GestureDetector } from 'react-native-gesture-handler';
4
4
  import Animated, { runOnJS, useAnimatedReaction, useAnimatedStyle, useSharedValue, useFrameCallback, withDecay, } from 'react-native-reanimated';
5
- import { useFocusEffect } from '@react-navigation/native';
6
5
  /**
7
6
  * Animation modes for the marquee text
8
7
  */
@@ -128,33 +127,25 @@ var MarqueeText = React.forwardRef(function (_a, ref) {
128
127
  });
129
128
  });
130
129
  }, [withGesture, isVertical, anim, start, stop, enabled]);
131
- // Handle focus/unmount
132
- useFocusEffect(React.useCallback(function () {
133
- // Start animation when screen comes into focus
134
- if (enabled) {
135
- start();
136
- }
137
- return function () {
138
- // Stop animation when screen loses focus
139
- stop();
140
- anim.value = 0;
141
- };
142
- }, [start, stop, anim, enabled]));
143
130
  // Cleanup on unmount
144
131
  React.useEffect(function () {
145
132
  return function () {
146
133
  isMounted.current = false;
134
+ stop();
147
135
  };
148
- }, []);
136
+ }, [stop]);
149
137
  // Start/stop based on enabled prop changes
150
138
  React.useEffect(function () {
151
139
  if (enabled) {
152
- start();
140
+ var timer_1 = setTimeout(function () {
141
+ start();
142
+ }, delay);
143
+ return function () { return clearTimeout(timer_1); };
153
144
  }
154
145
  else {
155
146
  stop();
156
147
  }
157
- }, [enabled, start, stop]);
148
+ }, [enabled, start, stop, delay]);
158
149
  // Render the content
159
150
  var renderContent = function () {
160
151
  if (typeof children === 'string') {
@@ -205,5 +196,5 @@ var styles = StyleSheet.create({
205
196
  position: 'relative',
206
197
  },
207
198
  });
208
- export default MarqueeText;
209
199
  export { AnimationMode };
200
+ export default MarqueeText;
@@ -1,4 +1,109 @@
1
- export declare const AnimationMode: {
2
- LOOP: string;
3
- BOUNCE: string;
4
- };
1
+ import { ViewStyle, TextStyle } from "react-native";
2
+ /**
3
+ * Animation modes for the marquee text
4
+ */
5
+ export declare enum AnimationMode {
6
+ LOOP = "loop",
7
+ BOUNCE = "bounce"
8
+ }
9
+ /**
10
+ * Direction of the marquee animation
11
+ */
12
+ type MarqueeDirection = 'horizontal' | 'vertical';
13
+ /**
14
+ * Props for the MarqueeText component
15
+ */
16
+ export interface MarqueeTextProps {
17
+ /**
18
+ * Content to be scrolled (string or React nodes)
19
+ */
20
+ children: React.ReactNode;
21
+ /**
22
+ * The animation mode: 'loop' for continuous scrolling or 'bounce' for back-and-forth
23
+ * @default AnimationMode.LOOP
24
+ */
25
+ mode?: AnimationMode;
26
+ /**
27
+ * Speed of the scrolling animation in pixels per second
28
+ * @default 30
29
+ */
30
+ speed?: number;
31
+ /**
32
+ * Delay in milliseconds before starting the animation
33
+ * @default 1500
34
+ */
35
+ delay?: number;
36
+ /**
37
+ * Duration in milliseconds to pause at the end of the content (only for bounce mode)
38
+ * @default 1000
39
+ */
40
+ endPauseDuration?: number;
41
+ /**
42
+ * Container style
43
+ */
44
+ style?: ViewStyle;
45
+ /**
46
+ * Text style (when children is a string)
47
+ */
48
+ textStyle?: TextStyle;
49
+ /**
50
+ * Whether to enable the animation
51
+ * @default true
52
+ */
53
+ enabled?: boolean;
54
+ /**
55
+ * Direction of scrolling ('horizontal' or 'vertical')
56
+ * @default 'horizontal'
57
+ */
58
+ direction?: MarqueeDirection;
59
+ /**
60
+ * Spacing between cloned elements
61
+ * @default 20
62
+ */
63
+ spacing?: number;
64
+ /**
65
+ * Allow user interaction with gesture handling
66
+ * @default true
67
+ */
68
+ withGesture?: boolean;
69
+ /**
70
+ * Custom frame rate for animation
71
+ */
72
+ frameRate?: number;
73
+ /**
74
+ * Reverse the animation direction
75
+ * @default false
76
+ */
77
+ reverse?: boolean;
78
+ /**
79
+ * Background color for the container
80
+ * @default 'transparent'
81
+ */
82
+ backgroundColor?: string;
83
+ /**
84
+ * Callback when animation starts
85
+ */
86
+ onAnimationStart?: () => void;
87
+ /**
88
+ * Callback when animation stops
89
+ */
90
+ onAnimationStop?: () => void;
91
+ }
92
+ /**
93
+ * Reference handle for the MarqueeText component
94
+ */
95
+ export interface MarqueeTextRef {
96
+ /**
97
+ * Start the marquee animation
98
+ */
99
+ start: () => void;
100
+ /**
101
+ * Stop the marquee animation
102
+ */
103
+ stop: () => void;
104
+ /**
105
+ * Whether the animation is currently active
106
+ */
107
+ isActive: boolean;
108
+ }
109
+ export {};
package/dist/constants.js CHANGED
@@ -1,4 +1,12 @@
1
- export var AnimationMode = {
2
- LOOP: 'loop',
3
- BOUNCE: 'bounce',
4
- };
1
+ // export const AnimationMode = {
2
+ // LOOP: 'loop',
3
+ // BOUNCE: 'bounce',
4
+ // };
5
+ /**
6
+ * Animation modes for the marquee text
7
+ */
8
+ export var AnimationMode;
9
+ (function (AnimationMode) {
10
+ AnimationMode["LOOP"] = "loop";
11
+ AnimationMode["BOUNCE"] = "bounce";
12
+ })(AnimationMode || (AnimationMode = {}));
package/dist/index.d.ts CHANGED
@@ -3,7 +3,7 @@ export { AnimationMode } from './constants';
3
3
  declare const Marquee: {
4
4
  AutoScroll: ({ children, mode, speed, delay, endPauseDuration, style, textStyle, enabled, direction, }: {
5
5
  children: React.ReactNode;
6
- mode?: "loop" | "bounce";
6
+ mode?: import("./constants").AnimationMode;
7
7
  speed?: number;
8
8
  delay?: number;
9
9
  endPauseDuration?: number;
package/dist/index.js CHANGED
@@ -5,6 +5,6 @@ export { AnimationMode } from './constants';
5
5
  var Marquee = {
6
6
  AutoScroll: AutoScroll,
7
7
  MarqueeText: MarqueeText,
8
- AnimationMode: AnimationMode
8
+ AnimationMode: AnimationMode,
9
9
  };
10
10
  export default Marquee;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rn-marquee-text",
3
- "version": "2.0.5",
3
+ "version": "2.0.7",
4
4
  "description": "A customizable marquee (scrolling) text component for React Native",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -52,6 +52,6 @@
52
52
  "dependencies": {
53
53
  "@react-navigation/native": "^7.1.9",
54
54
  "react-native-gesture-handler": "^2.25.0",
55
- "rn-marquee-text": "^1.0.4"
55
+ "rn-marquee-text": "^1.0.7"
56
56
  }
57
57
  }