Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-native-text-ticker

Package Overview
Dependencies
Maintainers
1
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-text-ticker - npm Package Compare versions

Comparing version 0.12.0 to 0.13.0

80

index.js
import React, { PureComponent } from 'react'
import {
import {
Animated,
Easing,
StyleSheet,
Text,
View,
ScrollView,
NativeModules,
StyleSheet,
Text,
View,
ScrollView,
NativeModules,
findNodeHandle

@@ -68,2 +68,8 @@ } from 'react-native'

componentWillUnmount() {
this.stopAnimation();
// always stop timers when unmounting, common source of crash
this.clearTimeout();
}
startAnimation = (timeDelay) => {

@@ -78,11 +84,11 @@ if (this.state.animating) {

const {
duration,
marqueeDelay,
loop,
useNativeDriver,
repeatSpacer,
easing,
duration,
marqueeDelay,
loop,
useNativeDriver,
repeatSpacer,
easing,
children,
onMarqueeComplete
} = this.props
} = this.props
this.setTimeout(() => {

@@ -116,3 +122,3 @@ Animated.timing(this.animatedValue, {

easing: easing,
useNativeDriver: useNativeDriver
useNativeDriver: useNativeDriver
}),

@@ -123,4 +129,4 @@ Animated.timing(this.animatedValue, {

easing: easing,
useNativeDriver: useNativeDriver
})
useNativeDriver: useNativeDriver
})
]).start(({finished}) => {

@@ -152,24 +158,30 @@ if (loop) {

}
async calculateMetrics() {
return new Promise(async (resolve, reject) => {
try {
const measureWidth = node =>
new Promise(resolve => {
UIManager.measure(findNodeHandle(node), (x, y, w) => {
// console.log('Width: ' + w)
return resolve(w)
})
})
const measureWidth = node =>
new Promise(async (resolve, reject) => {
// nodehandle is not always there, causes crash. modified to check..
const nodeHandle = findNodeHandle(node);
if (nodeHandle) {
UIManager.measure(nodeHandle, (x, y, w) => {
// console.log('Width: ' + w)
return resolve(w)
})
} else {
return reject('nodehandle_not_found');
}
});
const [containerWidth, textWidth] = await Promise.all([
measureWidth(this.containerRef),
measureWidth(this.textRef)
])
]);
this.containerWidth = containerWidth
this.textWidth = textWidth
this.distance = textWidth - containerWidth
this.setState({
this.setState({
// Is 1 instead of 0 to get round rounding errors from:

@@ -183,3 +195,3 @@ // https://github.com/facebook/react-native/commit/a534672

} catch (error) {
console.warn(error)
console.warn('react-native-text-ticker: could not calculate metrics', error);
}

@@ -221,4 +233,4 @@ })

<View style={[styles.container]}>
<Text
{...props}
<Text
{...props}
numberOfLines={1}

@@ -246,3 +258,3 @@ style={[style, { opacity: animating ? 0 : 1 }]}

>
{this.props.children}
{this.props.children}
</Animated.Text>

@@ -256,3 +268,3 @@ {!contentFits && !isScrolling

>
{this.props.children}
{this.props.children}
</Animated.Text>

@@ -259,0 +271,0 @@ </View> : null }

{
"name": "react-native-text-ticker",
"version": "0.12.0",
"version": "0.13.0",
"description": "React Native Text Ticker/Marquee Component",

@@ -5,0 +5,0 @@ "main": "index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc