react-morph

Morphing Ui transitions made simple

  • Owner: brunnolou/react-morph
  • Platform:
  • License::
  • Category::
  • Topic:
  • Like:
    0
      Compare:

Github stars Tracking Chart

React Morph ️?

Morphing UI transitions made simple

npm version

Magically animates one element into another just by tagging the first and last state.

Getting Started ?

npm install react-morph
# or
yarn add react-morph

Import the useMorph hook.

const morph = useMorph(options);

Then spread the props to the elements you want to morph.

<img {...morph} src="larva.png" width="50">
<img {...morph} src="butterfly.png" width="80">

Make sure you have just ONE element rendered at same time.

Simple Example ?

  1. Create two states as you normally would (HTML + CSS).
  2. Call useMorph hook.
  3. Spread the elements you want to morph with {...morph}
  4. Add and remove the element from the DOM
import React from 'react';
import { useMorph } from 'react-morph';
() => {
  // Handle toggle state as you normally would.
  const [toggle, setToggle] = useState(true);
  const morph = useMorph();

  return (
    <div>
      <button onClick={() => setToggle(!toggle)}>Let's morph!</button>
      <br />

      {toggle ? (
        <img {...morph} src={larva} width="30" />
      ) : (
        <img {...morph} src={butterfly} width="80" />
      )}
    </div>
  );
};

Documentation

Please check the documentation.

Features ?

  • Simplicity
  • No hardcoded absolute positions
  • All GPU accelerated props
  • No layout or paint browser rendering

Live Demos

Main metrics

Overview
Name With Ownerbrunnolou/react-morph
Primary LanguageTypeScript
Program languageJavaScript (Language Count: 4)
Platform
License:
所有者活动
Created At2018-02-12 00:14:52
Pushed At2022-12-12 12:34:24
Last Commit At2019-07-19 22:41:16
Release Count11
Last Release Namev0.3.6 (Posted on 2018-07-24 00:11:02)
First Release Namev0.1.0 (Posted on 2018-02-19 00:34:21)
用户参与
Stargazers Count2.6k
Watchers Count19
Fork Count45
Commits Count88
Has Issues Enabled
Issues Count18
Issue Open Count7
Pull Requests Count12
Pull Requests Open Count15
Pull Requests Close Count5
项目设置
Has Wiki Enabled
Is Archived
Is Fork
Is Locked
Is Mirror
Is Private