Socket
Book a DemoInstallSign in
Socket

moti

Package Overview
Dependencies
Maintainers
1
Versions
125
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

moti

The universal React Native animation library, powered by Reanimated 3. 🦉

0.30.0
latest
Source
npmnpm
Version published
Weekly downloads
243K
5.64%
Maintainers
1
Weekly downloads
 
Created

What is moti?

Moti is a library for animations in React Native, providing a simple and declarative API to create smooth and complex animations with ease. It leverages Reanimated 2 under the hood to offer performant animations.

What are moti's main functionalities?

Basic Animations

This code demonstrates a basic fade-in animation using Moti. The MotiView component animates its opacity from 0 to 1 over a duration of 1000 milliseconds.

import React from 'react';
import { View } from 'react-native';
import { MotiView } from 'moti';

export default function App() {
  return (
    <MotiView
      from={{ opacity: 0 }}
      animate={{ opacity: 1 }}
      transition={{ type: 'timing', duration: 1000 }}
      style={{ width: 100, height: 100, backgroundColor: 'blue' }}
    />
  );
}

Complex Animations

This example shows how to create a more complex animation with Moti, where a view scales and rotates simultaneously. The transition uses a spring animation for a more natural effect.

import React from 'react';
import { View } from 'react-native';
import { MotiView } from 'moti';

export default function App() {
  return (
    <MotiView
      from={{ scale: 0.5, rotate: '0deg' }}
      animate={{ scale: 1, rotate: '360deg' }}
      transition={{ type: 'spring', damping: 10 }}
      style={{ width: 100, height: 100, backgroundColor: 'red' }}
    />
  );
}

Layout Animations

This code sample demonstrates layout animations with Moti. A view's height animates in and out when toggled, showcasing how Moti can handle dynamic layout changes.

import React from 'react';
import { View, Button } from 'react-native';
import { MotiView } from 'moti';

export default function App() {
  const [visible, setVisible] = React.useState(true);

  return (
    <View>
      <Button title="Toggle" onPress={() => setVisible(!visible)} />
      {visible && (
        <MotiView
          from={{ height: 0 }}
          animate={{ height: 100 }}
          exit={{ height: 0 }}
          style={{ backgroundColor: 'green' }}
        />
      )}
    </View>
  );
}

Other packages similar to moti

Keywords

react-native

FAQs

Package last updated on 29 Jan 2025

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.