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?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?