Skip to content
المشاريع

حول

مكوّن لنصوص متحركة لا يعتمد على أي تبعيات.

مشاريع أخرى

كيف تُقاس هذه الأرقام

1,621 نجمة34 التفرعات +12 خلال 24 ساعة

النمو المقاس للنجوم

خلال 24 ساعة
+١٢
خلال 7 أيام
+٣٣
خلال 15 يومًا
+٥٥
خلال شهر
+١٠١

تغيّر صافي النجوم خلال فترات متداخلة، وليس مجموعًا يوميًا. تبقى القياسات المفقودة فارغة. النجوم تقيس الاهتمام لا جودة البرمجيات.

README.md

الأصل

Torph

Dependency-free animated text morphing component for React, Vue, Svelte, and vanilla JavaScript.

Installation

pnpm i torph

Usage

import { TextMorph } from "torph/react";

<TextMorph>Hello world</TextMorph>;

Numbers

Numeric words morph by place value: digits slide along the block axis and the symbols around them travel with the places they belong to. It is on by default, so any value containing a number already animates this way.

import { TextMorph } from "torph/react";

// 1,204 → 1,318 rolls the hundreds and tens, leaves the thousands alone
<TextMorph>{`$${total.toLocaleString("en")}`}</TextMorph>;

For a field somebody is typing in, pass the caret position so the update matches by position rather than by place value:

<TextMorph cursorIndex={caret}>{value}</TextMorph>

Plugins

Plugins change how text is cut up and how it moves. Each builds on classic(), torph's own look, and changes only what it's about:

import { TextMorph } from "torph/react";
import { blur } from "torph/plugins/blur";

<TextMorph plugins={[blur()]}>{status}</TextMorph>;

torph/plugins/words swaps a changed word whole, and torph/plugins/scramble scrambles text in and out letter by letter. Writing your own is covered in the package README.

Spring Animations

Use physics-based spring easing by passing spring parameters to ease:

import { TextMorph } from "torph/react";

<TextMorph ease={{ stiffness: 200, damping: 20 }}>Hello world</TextMorph>;

See the package README for full API documentation.

Contributing

Install dependencies

pnpm install:all

Dev/Watch Library and Example

pnpm dev

Build Library

pnpm build

Found this useful?

Follow me on Twitter.

Other projects

You might also like:

Acknowledgements

  • Thanks to Alex for assistance with the site design.
  • Thanks to Pugson for putting up with my bullshit.
  • Thanks to Benji for coining the Torph name and outlining the method in Family Values.

استكشف مشاريع مشابهة ومرتبطة

جارٍ التحميل…