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

react-native-magic-moving

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-magic-moving

A novel transition animation between components

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

MagicMoving

A novel transition animation between components.

1. Examples

Download the repository, cd the examples directory, and run it on simulator.

git clone git@github.com:SmallStoneSK/react-native-magic-moving.git
cd examples
react-native run-ios      # for ios
react-native run-android  # for android

2. Basic Usage

At first, you should install react-native-magic-moving. Like this:

npm install react-native-magic-moving --save

Then, you can refer to the following example. At least, you should pass 4 properties to MagicMoving:

  1. data: the dataSource for rendered list.
  2. cardStyle: it will work on the list's card container.
  3. renderCardContent: custom what you want to show in the card.
  4. renderPopupLayerContent: custom what you want to show in the popup layer.

Note: each item in the data should have a image. Because it is the image source of popup layer banner image.

import React from 'react';
import {Text, Image, StyleSheet} from 'react-native';
import {MagicMoving} from 'react-native-magic-moving';

const mockedData = [
  {
    image: {uri: 'https://hellorfimg.zcool.cn/preview260/525525049.jpg'},
    content: 'card 0'
  },
  {
    image: {uri: 'https://hellorfimg.zcool.cn/preview260/267756197.jpg'},
    content: 'card 1'
  },
  {
    image: {uri: 'https://hellorfimg.zcool.cn/preview260/409679020.jpg'},
    content: 'card 2'
  },
  {
    image: {uri: 'https://hellorfimg.zcool.cn/preview260/682966966.jpg'},
    content: 'card 3'
  }
];

export class Demo extends React.Component {

  _renderCardContent = (item, index) => {
    return <Image style={styles.cardImage} source={item.image}/>;
  };

  _renderPopupLayerContent = (item, index) => {
    return <Text>{item.content}</Text>;
  };

  render() {
    return (
      <MagicMoving
        data={mockedData}
        cardStyle={styles.cardContainer}
        renderCardContent={this._renderCardContent}
        renderPopupLayerContent={this._renderPopupLayerContent}
      />
    );
  }
}

const styles = StyleSheet.create({
  cardContainer: {
    marginTop: 20,
    marginHorizontal: 20
  },
  cardImage: {
    width: 335,
    height: 200
  }
});

In the example above, the content of popup layer is ready before it shows. If you want to read it asynchronously from the network, you can see the demo2 (click here).

In fact, you can do much things as MagicMoving offers 3 methods for you: onPopupLayerWillShow, onPopupLayerDidShow, onPopupLayerDidHide.

3. Properties

PropDefaultTypeDescription
style-objectallow custom list
cardStyle-objectallow custom list card
data[]arraydata source of list
openDuration300numberduration of showing popup layer animation
closeDuration300numberduration of closing popup layer animation
renderCardContent-functioncomplete control how to render the content of list card
renderPopupLayerContent-functioncomplete control how to render the content of popup layer
renderPopupLayerBanner-functionyou can custom the popup layer's banner using this function with params(bannerImageStyle)
onPopupLayerWillShow-functionbe called before popup layer showing
onPopupLayerDidShow-functionbe called after popup layer has shown
onPopupLayerDidHide-functionbe called after popup layer has hidden

Keywords

FAQs

Package last updated on 12 Jun 2018

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