1.1.10 • Published 2 years ago

magical-motion v1.1.10

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

Magical Motion 👟

Mount And Unmount Your React Component In A More Magical Way

Installation

Install magical-motion with npm

  npm install magical-motion

or

Install magical-motion with yarn

  yarn add magical-motion

Usage/Examples

import { useState } from 'react'
import Motion from 'magical-motion'

export const Box = () => {
    const [message, setMessage] = useState('mount animation running')
    return (
    <Motion
    key={message}
    animate={{opacity:1}}
    initial={{opacity:0}}
    onFinish={ ()=>{
        setMessage('Finished  animation')
      }}
    >{message}</Motion>
  )
}

API Reference

Bare Minimum

 <Motion 
    initial={{opacity:0}}>
    Hello world
 </Motion>
ParameterTypeDescriptionRequired
initialobjectthe initial state of your animation, accepts any css prop, any properties here reset to animateRequired. false

Full Api

ParameterTypeDescriptionRequired
asstring | | custom componentallows to render <Motion/> component as any html element or a custom react elementRequired. false
initialobjectthe initial state of your animation, accepts any css prop, any properties here reset to animate propRequired. false
animateobjectfrom initial state Motion component moves to animate,accepts any css prop, at the end of animation all props are set as default valueRequired. false
animateobjectfrom initial state Motion component moves to animate,accepts any css prop, at the end of animation all props are set as default valueRequired. false
configureobjectcontrols the feel of <Motion/> spring animation like, stiffness,or FPSRequired. false
transitionsobjectcontrols animation properties like delay before animation start, iterations and directionRequired. false
onFinishfunctiona callback function that runs after animationRequired. false

Default Configuration

  <Motion
    as='main'
    initial={{ x:0,y:0 }}
    animate={{ x:0,y:0 }}
    configure={{
      stiffness: 100,
      mass: 1,
      damping:10,
      FPS: 150
    }}
    transitions={{waitFor:undefined,direction:'normal'}}
    onFinish={()=>null}
  >
    
  </Motion>

Roadmap

  • polyfill ✅

  • support initial animation state ✅

  • support rendered animation state ✅
  • typescript support ✅
  • support exit animation state ❌
  • support option to generate more frames ✅
  • support callback function during animation state ✅
  • ability to wait till or wait until a condition is met before render ✅

TODO

  • exit animation using <Precense/> component
  • ability to pause animation after a certain duration
  • condition to pause animation
  • support exit animation state

License

MIT

Authors

0.1.10

2 years ago

0.1.0

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago

0.1.8

2 years ago

0.0.9

2 years ago

0.1.7

2 years ago

0.0.8

2 years ago

1.1.10

2 years ago

0.1.9

2 years ago

0.1.4

2 years ago

0.1.3

2 years ago

0.1.6

2 years ago

0.0.7

2 years ago

0.1.5

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago