rn-marquee-text 2.0.4 → 2.0.6
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 +108 -137
- package/dist/AutoScroll.d.ts +4 -2
- package/dist/AutoScroll.js +4 -3
- package/dist/MarqueeText.d.ts +4 -110
- package/dist/MarqueeText.js +3 -9
- package/dist/constants.d.ts +109 -4
- package/dist/constants.js +12 -4
- package/dist/index.d.ts +18 -5
- package/dist/index.js +10 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,38 +1,25 @@
|
|
|
1
|
-
|
|
1
|
+
# React Native Marquee Text 🏃♂️
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/rn-marquee-text)
|
|
4
|
+
[](https://github.com/yourusername/rn-marquee-text/blob/main/LICENSE)
|
|
5
|
+
[](https://www.npmjs.com/package/rn-marquee-text)
|
|
6
|
+
[](https://github.com/yourusername/rn-marquee-text/actions)
|
|
5
7
|
|
|
6
|
-
|
|
7
|
-
[](https://github.com/yourusername/rn-marquee-text/blob/main/LICENSE)
|
|
8
|
-
[](https://www.npmjs.com/package/rn-marquee-text)
|
|
9
|
-
[](http://makeapullrequest.com)
|
|
8
|
+
A high-performance, customizable marquee component for React Native with smooth animations and gesture support.
|
|
10
9
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-

|
|
14
|
-
|
|
15
|
-
## Table of Contents
|
|
16
|
-
- [Features](#features-)
|
|
17
|
-
- [Installation](#installation-)
|
|
18
|
-
- [Usage](#usage-)
|
|
19
|
-
- [API Reference](#api-reference-)
|
|
20
|
-
- [Examples](#examples-)
|
|
21
|
-
- [Troubleshooting](#troubleshooting-)
|
|
22
|
-
- [Contributing](#contributing-)
|
|
23
|
-
- [License](#license-)
|
|
10
|
+

|
|
24
11
|
|
|
25
12
|
## Features ✨
|
|
26
13
|
|
|
27
|
-
-
|
|
28
|
-
-
|
|
29
|
-
-
|
|
30
|
-
-
|
|
31
|
-
-
|
|
32
|
-
-
|
|
33
|
-
-
|
|
14
|
+
- 🎭 Multiple animation modes (loop, bounce)
|
|
15
|
+
- ↔️ Bidirectional scrolling (horizontal/vertical)
|
|
16
|
+
- ✋ Touch gesture interaction
|
|
17
|
+
- ⚡ Optimized with Reanimated 2
|
|
18
|
+
- 🎨 Customizable speed, spacing, and delays
|
|
19
|
+
- 📱 Supports both iOS and Android
|
|
20
|
+
- 🛠 TypeScript support included
|
|
34
21
|
|
|
35
|
-
## Installation
|
|
22
|
+
## Installation 💻
|
|
36
23
|
|
|
37
24
|
```bash
|
|
38
25
|
# Using npm
|
|
@@ -40,136 +27,120 @@ npm install rn-marquee-text react-native-reanimated react-native-gesture-handler
|
|
|
40
27
|
|
|
41
28
|
# Using yarn
|
|
42
29
|
yarn add rn-marquee-text react-native-reanimated react-native-gesture-handler
|
|
43
|
-
|
|
30
|
+
Peer Dependencies Setup
|
|
31
|
+
Follow Reanimated installation guide
|
|
44
32
|
|
|
45
|
-
|
|
46
|
-
Ensure you've properly installed and configured:
|
|
47
|
-
- [React Native Reanimated](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/installation)
|
|
48
|
-
- [React Native Gesture Handler](https://docs.swmansion.com/react-native-gesture-handler/docs/)
|
|
33
|
+
Configure Gesture Handler
|
|
49
34
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
### Basic Implementation
|
|
53
|
-
```jsx
|
|
54
|
-
import React from 'react';
|
|
55
|
-
import { StyleSheet, View } from 'react-native';
|
|
35
|
+
Basic Usage 🚀
|
|
36
|
+
jsx
|
|
56
37
|
import MarqueeText from 'rn-marquee-text';
|
|
57
38
|
|
|
58
|
-
|
|
59
|
-
|
|
39
|
+
function App() {
|
|
40
|
+
return (
|
|
60
41
|
<MarqueeText
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
textStyle={
|
|
42
|
+
speed={50}
|
|
43
|
+
style={{ height: 40 }}
|
|
44
|
+
textStyle={{ fontSize: 16 }}
|
|
64
45
|
>
|
|
65
|
-
|
|
46
|
+
This text will scroll automatically!
|
|
66
47
|
</MarqueeText>
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
| `mode` | 'loop' \| 'bounce' | 'loop' | Animation behavior |
|
|
86
|
-
| `speed` | number | 30 | Pixels per second |
|
|
87
|
-
| `direction` | 'horizontal' \| 'vertical' | 'horizontal' | Scroll direction |
|
|
88
|
-
| `enabled` | boolean | true | Animation active state |
|
|
89
|
-
| `delay` | number | 1500 | Initial delay (ms) |
|
|
90
|
-
| `endPauseDuration` | number | 1000 | Pause at end (bounce mode) |
|
|
91
|
-
|
|
92
|
-
### Methods (via ref)
|
|
93
|
-
```jsx
|
|
94
|
-
const marqueeRef = useRef();
|
|
95
|
-
|
|
96
|
-
// Start animation
|
|
97
|
-
marqueeRef.current?.start();
|
|
98
|
-
|
|
99
|
-
// Stop animation
|
|
100
|
-
marqueeRef.current?.stop();
|
|
101
|
-
|
|
102
|
-
// Check if active
|
|
103
|
-
const isActive = marqueeRef.current?.isActive;
|
|
104
|
-
```
|
|
105
|
-
|
|
106
|
-
## Examples 🎨
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
Advanced Usage 🧠
|
|
51
|
+
Custom Animation Configuration
|
|
52
|
+
jsx
|
|
53
|
+
<MarqueeText
|
|
54
|
+
mode="bounce"
|
|
55
|
+
direction="vertical"
|
|
56
|
+
speed={30}
|
|
57
|
+
delay={2000}
|
|
58
|
+
endPauseDuration={1500}
|
|
59
|
+
spacing={30}
|
|
60
|
+
>
|
|
61
|
+
{yourCustomComponent}
|
|
62
|
+
</MarqueeText>
|
|
63
|
+
Imperative Control
|
|
64
|
+
jsx
|
|
65
|
+
const marqueeRef = useRef(null);
|
|
107
66
|
|
|
108
|
-
|
|
109
|
-
|
|
67
|
+
// Start/pause programmatically
|
|
68
|
+
<>
|
|
69
|
+
<MarqueeText ref={marqueeRef} />
|
|
70
|
+
<Button
|
|
71
|
+
title="Toggle"
|
|
72
|
+
onPress={() => marqueeRef.current?.isActive
|
|
73
|
+
? marqueeRef.current.stop()
|
|
74
|
+
: marqueeRef.current.start()
|
|
75
|
+
}
|
|
76
|
+
/>
|
|
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 {
|
|
91
|
+
start: () => void;
|
|
92
|
+
stop: () => void;
|
|
93
|
+
isActive: boolean;
|
|
94
|
+
}
|
|
95
|
+
Examples 🎨
|
|
96
|
+
News Ticker
|
|
97
|
+
jsx
|
|
98
|
+
<MarqueeText
|
|
99
|
+
style={styles.ticker}
|
|
100
|
+
textStyle={styles.tickerText}
|
|
101
|
+
speed={40}
|
|
102
|
+
>
|
|
103
|
+
BREAKING: React Native Marquee Text released! • New version available • Check out the docs
|
|
104
|
+
</MarqueeText>
|
|
105
|
+
Vertical Product Carousel
|
|
106
|
+
jsx
|
|
110
107
|
<MarqueeText
|
|
111
108
|
direction="vertical"
|
|
112
109
|
mode="bounce"
|
|
113
110
|
speed={20}
|
|
114
|
-
|
|
115
|
-
style={styles.verticalMarquee}
|
|
111
|
+
style={styles.carousel}
|
|
116
112
|
>
|
|
117
|
-
|
|
113
|
+
<ProductCard {...item1} />
|
|
114
|
+
<ProductCard {...item2} />
|
|
115
|
+
<ProductCard {...item3} />
|
|
118
116
|
</MarqueeText>
|
|
119
|
-
|
|
117
|
+
Troubleshooting ⚠️
|
|
118
|
+
Animation not smooth?
|
|
120
119
|
|
|
121
|
-
|
|
122
|
-
```jsx
|
|
123
|
-
const [paused, setPaused] = useState(false);
|
|
120
|
+
Ensure you're using Reanimated 2+
|
|
124
121
|
|
|
125
|
-
|
|
126
|
-
<MarqueeText
|
|
127
|
-
ref={marqueeRef}
|
|
128
|
-
enabled={!paused}
|
|
129
|
-
style={styles.marquee}
|
|
130
|
-
>
|
|
131
|
-
Controllable marquee text
|
|
132
|
-
</MarqueeText>
|
|
133
|
-
|
|
134
|
-
<Button
|
|
135
|
-
title={paused ? "Resume" : "Pause"}
|
|
136
|
-
onPress={() => setPaused(!paused)}
|
|
137
|
-
/>
|
|
138
|
-
</>
|
|
139
|
-
```
|
|
122
|
+
Check for heavy renders in parent components
|
|
140
123
|
|
|
141
|
-
|
|
124
|
+
Text not visible?
|
|
142
125
|
|
|
143
|
-
|
|
144
|
-
- Verify Reanimated installation
|
|
145
|
-
- Check babel.config.js for Reanimated plugin
|
|
126
|
+
Verify container has explicit dimensions
|
|
146
127
|
|
|
147
|
-
|
|
148
|
-
- Ensure container has proper dimensions
|
|
149
|
-
- Verify text color contrasts with background
|
|
128
|
+
Check text color contrast
|
|
150
129
|
|
|
151
|
-
|
|
152
|
-
- Reduce animation speed
|
|
153
|
-
- Simplify marquee content
|
|
154
|
-
- Use `frameRate` prop to limit FPS
|
|
130
|
+
Gesture not working?
|
|
155
131
|
|
|
156
|
-
|
|
157
|
-
Contributions are welcome! Please:
|
|
158
|
-
1. Open an issue to discuss changes
|
|
159
|
-
2. Ensure tests are updated
|
|
160
|
-
3. Maintain consistent code style
|
|
132
|
+
Confirm Gesture Handler installation
|
|
161
133
|
|
|
162
|
-
|
|
163
|
-
MIT © [Your Name](https://github.com/yourusername)
|
|
134
|
+
Wrap root component with GestureHandlerRootView
|
|
164
135
|
|
|
165
|
-
|
|
136
|
+
Contributing 🤝
|
|
137
|
+
We welcome contributions! Please:
|
|
166
138
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
```
|
|
139
|
+
Fork the repository
|
|
140
|
+
|
|
141
|
+
Create a feature branch
|
|
142
|
+
|
|
143
|
+
Submit a pull request
|
|
144
|
+
|
|
145
|
+
License 📄
|
|
146
|
+
MIT © PARESH CHAVDA
|
package/dist/AutoScroll.d.ts
CHANGED
|
@@ -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
|
|
@@ -15,9 +16,9 @@ import { TextStyle, ViewStyle } from 'react-native';
|
|
|
15
16
|
* @prop {boolean} enabled - Whether the scrolling animation is enabled
|
|
16
17
|
* @prop {'horizontal'|'vertical'} direction - The direction of the scrolling animation
|
|
17
18
|
*/
|
|
18
|
-
|
|
19
|
+
declare const AutoScroll: ({ children, mode, speed, delay, endPauseDuration, style, textStyle, enabled, direction, }: {
|
|
19
20
|
children: React.ReactNode;
|
|
20
|
-
mode?:
|
|
21
|
+
mode?: AnimationMode;
|
|
21
22
|
speed?: number;
|
|
22
23
|
delay?: number;
|
|
23
24
|
endPauseDuration?: number;
|
|
@@ -26,3 +27,4 @@ export declare const AutoScroll: ({ children, mode, speed, delay, endPauseDurati
|
|
|
26
27
|
enabled?: boolean;
|
|
27
28
|
direction?: "horizontal" | "vertical";
|
|
28
29
|
}) => React.JSX.Element;
|
|
30
|
+
export default AutoScroll;
|
package/dist/AutoScroll.js
CHANGED
|
@@ -17,8 +17,8 @@ import { AnimationMode } from './constants';
|
|
|
17
17
|
* @prop {boolean} enabled - Whether the scrolling animation is enabled
|
|
18
18
|
* @prop {'horizontal'|'vertical'} direction - The direction of the scrolling animation
|
|
19
19
|
*/
|
|
20
|
-
|
|
21
|
-
var children = _a.children, _b = _a.mode, mode = _b === void 0 ?
|
|
20
|
+
var AutoScroll = function (_a) {
|
|
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 @@ export 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
|
|
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
|
}
|
|
@@ -143,3 +143,4 @@ var styles = StyleSheet.create({
|
|
|
143
143
|
flexShrink: 0,
|
|
144
144
|
},
|
|
145
145
|
});
|
|
146
|
+
export default AutoScroll;
|
package/dist/MarqueeText.d.ts
CHANGED
|
@@ -1,112 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
/**
|
|
4
|
-
* Animation modes for the marquee text
|
|
5
|
-
*/
|
|
6
|
-
declare enum AnimationMode {
|
|
7
|
-
LOOP = "loop",
|
|
8
|
-
BOUNCE = "bounce"
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Direction of the marquee animation
|
|
12
|
-
*/
|
|
13
|
-
type MarqueeDirection = 'horizontal' | 'vertical';
|
|
14
|
-
/**
|
|
15
|
-
* Props for the MarqueeText component
|
|
16
|
-
*/
|
|
17
|
-
interface MarqueeTextProps {
|
|
18
|
-
/**
|
|
19
|
-
* Content to be scrolled (string or React nodes)
|
|
20
|
-
*/
|
|
21
|
-
children: React.ReactNode;
|
|
22
|
-
/**
|
|
23
|
-
* The animation mode: 'loop' for continuous scrolling or 'bounce' for back-and-forth
|
|
24
|
-
* @default AnimationMode.LOOP
|
|
25
|
-
*/
|
|
26
|
-
mode?: AnimationMode;
|
|
27
|
-
/**
|
|
28
|
-
* Speed of the scrolling animation in pixels per second
|
|
29
|
-
* @default 30
|
|
30
|
-
*/
|
|
31
|
-
speed?: number;
|
|
32
|
-
/**
|
|
33
|
-
* Delay in milliseconds before starting the animation
|
|
34
|
-
* @default 1500
|
|
35
|
-
*/
|
|
36
|
-
delay?: number;
|
|
37
|
-
/**
|
|
38
|
-
* Duration in milliseconds to pause at the end of the content (only for bounce mode)
|
|
39
|
-
* @default 1000
|
|
40
|
-
*/
|
|
41
|
-
endPauseDuration?: number;
|
|
42
|
-
/**
|
|
43
|
-
* Container style
|
|
44
|
-
*/
|
|
45
|
-
style?: ViewStyle;
|
|
46
|
-
/**
|
|
47
|
-
* Text style (when children is a string)
|
|
48
|
-
*/
|
|
49
|
-
textStyle?: TextStyle;
|
|
50
|
-
/**
|
|
51
|
-
* Whether to enable the animation
|
|
52
|
-
* @default true
|
|
53
|
-
*/
|
|
54
|
-
enabled?: boolean;
|
|
55
|
-
/**
|
|
56
|
-
* Direction of scrolling ('horizontal' or 'vertical')
|
|
57
|
-
* @default 'horizontal'
|
|
58
|
-
*/
|
|
59
|
-
direction?: MarqueeDirection;
|
|
60
|
-
/**
|
|
61
|
-
* Spacing between cloned elements
|
|
62
|
-
* @default 20
|
|
63
|
-
*/
|
|
64
|
-
spacing?: number;
|
|
65
|
-
/**
|
|
66
|
-
* Allow user interaction with gesture handling
|
|
67
|
-
* @default true
|
|
68
|
-
*/
|
|
69
|
-
withGesture?: boolean;
|
|
70
|
-
/**
|
|
71
|
-
* Custom frame rate for animation
|
|
72
|
-
*/
|
|
73
|
-
frameRate?: number;
|
|
74
|
-
/**
|
|
75
|
-
* Reverse the animation direction
|
|
76
|
-
* @default false
|
|
77
|
-
*/
|
|
78
|
-
reverse?: boolean;
|
|
79
|
-
/**
|
|
80
|
-
* Background color for the container
|
|
81
|
-
* @default 'transparent'
|
|
82
|
-
*/
|
|
83
|
-
backgroundColor?: string;
|
|
84
|
-
/**
|
|
85
|
-
* Callback when animation starts
|
|
86
|
-
*/
|
|
87
|
-
onAnimationStart?: () => void;
|
|
88
|
-
/**
|
|
89
|
-
* Callback when animation stops
|
|
90
|
-
*/
|
|
91
|
-
onAnimationStop?: () => void;
|
|
92
|
-
}
|
|
93
|
-
/**
|
|
94
|
-
* Reference handle for the MarqueeText component
|
|
95
|
-
*/
|
|
96
|
-
export interface MarqueeTextRef {
|
|
97
|
-
/**
|
|
98
|
-
* Start the marquee animation
|
|
99
|
-
*/
|
|
100
|
-
start: () => void;
|
|
101
|
-
/**
|
|
102
|
-
* Stop the marquee animation
|
|
103
|
-
*/
|
|
104
|
-
stop: () => void;
|
|
105
|
-
/**
|
|
106
|
-
* Whether the animation is currently active
|
|
107
|
-
*/
|
|
108
|
-
isActive: boolean;
|
|
109
|
-
}
|
|
2
|
+
import { MarqueeTextRef, MarqueeTextProps, AnimationMode } from './constants';
|
|
110
3
|
/**
|
|
111
4
|
* MarqueeText component for scrolling text or content
|
|
112
5
|
*
|
|
@@ -115,5 +8,6 @@ export interface MarqueeTextRef {
|
|
|
115
8
|
* modes, and user interaction via gestures.
|
|
116
9
|
*/
|
|
117
10
|
declare const MarqueeText: React.ForwardRefExoticComponent<MarqueeTextProps & React.RefAttributes<MarqueeTextRef>>;
|
|
118
|
-
export
|
|
119
|
-
export
|
|
11
|
+
export default MarqueeText;
|
|
12
|
+
export { AnimationMode };
|
|
13
|
+
export type { MarqueeTextProps };
|
package/dist/MarqueeText.js
CHANGED
|
@@ -3,14 +3,7 @@ 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
5
|
import { useFocusEffect } from '@react-navigation/native';
|
|
6
|
-
|
|
7
|
-
* Animation modes for the marquee text
|
|
8
|
-
*/
|
|
9
|
-
var AnimationMode;
|
|
10
|
-
(function (AnimationMode) {
|
|
11
|
-
AnimationMode["LOOP"] = "loop";
|
|
12
|
-
AnimationMode["BOUNCE"] = "bounce";
|
|
13
|
-
})(AnimationMode || (AnimationMode = {}));
|
|
6
|
+
import { AnimationMode } from './constants';
|
|
14
7
|
/**
|
|
15
8
|
* Component to render a child item in the marquee
|
|
16
9
|
*/
|
|
@@ -205,4 +198,5 @@ var styles = StyleSheet.create({
|
|
|
205
198
|
position: 'relative',
|
|
206
199
|
},
|
|
207
200
|
});
|
|
208
|
-
export
|
|
201
|
+
export default MarqueeText;
|
|
202
|
+
export { AnimationMode };
|
package/dist/constants.d.ts
CHANGED
|
@@ -1,4 +1,109 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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
|
|
2
|
-
|
|
3
|
-
|
|
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
|
@@ -1,5 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { AnimationMode } from './MarqueeText';
|
|
2
|
+
export { AnimationMode } from './constants';
|
|
3
|
+
declare const Marquee: {
|
|
4
|
+
AutoScroll: ({ children, mode, speed, delay, endPauseDuration, style, textStyle, enabled, direction, }: {
|
|
5
|
+
children: React.ReactNode;
|
|
6
|
+
mode?: AnimationMode;
|
|
7
|
+
speed?: number;
|
|
8
|
+
delay?: number;
|
|
9
|
+
endPauseDuration?: number;
|
|
10
|
+
style?: import("react-native").ViewStyle;
|
|
11
|
+
textStyle?: import("react-native").TextStyle;
|
|
12
|
+
enabled?: boolean;
|
|
13
|
+
direction?: "horizontal" | "vertical";
|
|
14
|
+
}) => import("react").JSX.Element;
|
|
15
|
+
MarqueeText: import("react").ForwardRefExoticComponent<import("./constants").MarqueeTextProps & import("react").RefAttributes<import("./constants").MarqueeTextRef>>;
|
|
16
|
+
AnimationMode: typeof AnimationMode;
|
|
17
|
+
};
|
|
18
|
+
export default Marquee;
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
export
|
|
5
|
-
|
|
1
|
+
import AutoScroll from './AutoScroll';
|
|
2
|
+
import MarqueeText, { AnimationMode } from './MarqueeText';
|
|
3
|
+
export { AnimationMode } from './constants';
|
|
4
|
+
// Optional: Default export (choose either AutoScroll or MarqueeText as default)
|
|
5
|
+
var Marquee = {
|
|
6
|
+
AutoScroll: AutoScroll,
|
|
7
|
+
MarqueeText: MarqueeText,
|
|
8
|
+
AnimationMode: AnimationMode,
|
|
9
|
+
};
|
|
10
|
+
export default Marquee;
|