react-morph

Morphing Ui transitions made simple

  • 所有者: brunnolou/react-morph
  • 平台:
  • 许可证:
  • 分类:
  • 主题:
  • 喜欢:
    0
      比较:

Github星跟踪图

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

主要指标

概览
名称与所有者brunnolou/react-morph
主编程语言TypeScript
编程语言JavaScript (语言数: 4)
平台
许可证
所有者活动
创建于2018-02-12 00:14:52
推送于2022-12-12 12:34:24
最后一次提交2019-07-19 22:41:16
发布数11
最新版本名称v0.3.6 (发布于 2018-07-24 00:11:02)
第一版名称v0.1.0 (发布于 2018-02-19 00:34:21)
用户参与
星数2.6k
关注者数19
派生数45
提交数88
已启用问题?
问题数18
打开的问题数7
拉请求数12
打开的拉请求数15
关闭的拉请求数5
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?