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

react-native-animated-stopwatch

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-animated-stopwatch

React Native Stopwatch component that smoothly animates the digits change

  • 0.3.0
  • unpublished
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Animated Stopwatch

npm npm bundle size platforms: ios, android, web license MIT

React Native Stopwatch component that smoothly animates the digits change. Cross-platform, performant, with all animations executed on the UI thread at 60FPS. Compatible with Expo.

Installation

npm install react-native-animated-stopwatch

Usage

import { useRef } from 'react';
import AnimatedStopwatch, {
  StopWatchMethods,
} from 'react-native-animated-stopwatch';

const stopwatchRef = useRef<StopWatchMethods>(null);

function play() {
  stopwatchRef.current?.play();
}

function pause() {
  const elapsedTimeInMs = stopwatchRef.current?.pause();
  // Do something with the elapsed time
  console.log(elapsedTimeInMs);
}

function reset() {
  stopwatchRef.current?.reset();
}

return <AnimatedStopwatch ref={stopwatchRef} />;

Props

NameRequiredTypeDescription
animationDurationnonumberThe enter/exit animation duration in milliseconds of a stopwatch digit. Defaults to 80
animationDelaynonumberThe enter/exit animation delay in milliseconds of a stopwatch digit. Defaults to 0
animationDistancenonumberThe enter/exit animation vertical distance in dp of a stopwatch digit. Defaults to 120
containerStylenoStyleProp<ViewStyle>The style of the stopwatch View container
digitStylenoStyleProp<TextStyle>Extra style applied to each digit, excluding separators (: and ,)
leadingZerosno1 or 2The number of zeros for the minutes. Defaults to 1
enterAnimationTypeno'slide-in-up' or 'slide-in-down'Whether the new digit should enter from the top or the bottom
separatorStylenoStyleProp<TextStyle>Extra style applied only to separators. In this case, the colon (:) and the comma (,)
textCharStylenoStyleProp<TextStyle>The style applied to each individual character of the stopwatch
trailingZerosno0, 1 or 2If 0, the stopwatch will only display seconds and minutes. If 1, the stopwatch will display seconds, minutes and hundredth of ms. If 2, the stopwatch will display seconds, minutes and tens of ms. Defaults to 1

Methods

play: () => void

Starts the stopwatch or resumes it if paused. It has no effect if the stopwatch is already running.

stopwatchRef.current?.play();
pause: () => number

Pauses the stopwatch. It has no effect if the stopwatch is either paused or reset. The method returns a snapshot of the time elapsed in ms.

stopwatchRef.current?.pause();
reset: () => void

Resets the stopwatch to 0.

stopwatchRef.current?.reset();
getSnapshot: () => number

Returns the current time elapsed in ms.

stopwatchRef.current?.getSnapshot();

stopwatchRef refers to the ref passed to the AnimatedStopwatch component.

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT


Made with create-react-native-library

Keywords

FAQs

Package last updated on 12 Jan 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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