All Projects → matthiaaas → framer-motion-hooks

matthiaaas / framer-motion-hooks

Licence: MIT license
Fill the hook gap in Framer Motion

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to framer-motion-hooks

Use Is In Viewport
A react hook to find out if an element is in a given viewport with a simple api.
Stars: ✭ 129 (-19.37%)
Mutual labels:  hooks, viewport
react-awesome-reveal
React components to add reveal animations using the Intersection Observer API and CSS Animations.
Stars: ✭ 564 (+252.5%)
Mutual labels:  hooks, viewport
React Intersection Observer
React implementation of the Intersection Observer API to tell you when an element enters or leaves the viewport.
Stars: ✭ 2,689 (+1580.63%)
Mutual labels:  hooks, viewport
React Awesome Reveal
React components to add reveal animations using the Intersection Observer API and CSS Animations.
Stars: ✭ 346 (+116.25%)
Mutual labels:  hooks, viewport
react-scroll-trigger
📜 React component that monitors scroll events to trigger callbacks when it enters, exits and progresses through the viewport. All callback include the progress and velocity of the scrolling, in the event you want to manipulate stuff based on those values.
Stars: ✭ 126 (-21.25%)
Mutual labels:  viewport, scroll-progress
LunaDesk
The people-first scheduling tool, coming 2022. LunaDesk is a web app, originally created by Josh Cawthorne and known as "WorkFrom" for the Supabase Hackathon.
Stars: ✭ 85 (-46.87%)
Mutual labels:  framer-motion
react-generate-context
A helper function for reducing React Context boilerplate
Stars: ✭ 24 (-85%)
Mutual labels:  hooks
taeseung vimrc
Taeseung Lee's vim setting
Stars: ✭ 16 (-90%)
Mutual labels:  viewport
onscroll-effect
A tiny JavaScript library to enable CSS animations when user scrolls.
Stars: ✭ 35 (-78.12%)
Mutual labels:  viewport
use-google-autocomplete
A simple React Hook API that returns Google Autocomplete results with session_token handling.
Stars: ✭ 27 (-83.12%)
Mutual labels:  hooks
dobux
🍃 Lightweight responsive state management solution.
Stars: ✭ 75 (-53.12%)
Mutual labels:  hooks
on-outside-click-hook
A React custom hook to detect clicks which triggers outside the element and then fire an event.
Stars: ✭ 17 (-89.37%)
Mutual labels:  hooks
vue-observable
IntersectionObserver, MutationObserver and PerformanceObserver in Vue.js
Stars: ✭ 24 (-85%)
Mutual labels:  viewport
react-hooks-form
React Forms the Hooks Way
Stars: ✭ 25 (-84.37%)
Mutual labels:  hooks
booktez-client
📚진짜 독서가들의 독서법 - 북스테어즈 (React)
Stars: ✭ 53 (-66.87%)
Mutual labels:  framer-motion
uni-design
基于React hooks的一套基础组件
Stars: ✭ 22 (-86.25%)
Mutual labels:  hooks
portfolio
My personal portfolio to show my skills, experience, and articles I published.
Stars: ✭ 81 (-49.37%)
Mutual labels:  framer-motion
react-ui-hooks
🧩Simple repository of React hooks for building UI components
Stars: ✭ 20 (-87.5%)
Mutual labels:  hooks
react-useForm
World's simplest React hook to manage form state
Stars: ✭ 30 (-81.25%)
Mutual labels:  hooks
Coherence
Blender viewport renderer using the Unity Engine
Stars: ✭ 28 (-82.5%)
Mutual labels:  viewport

Framer Motion Hooks

Fill the hook gap in Framer Motion.

Installation

npm install framer-motion-hooks

Note: If you prefer yarn instead of npm, just use yarn add framer-motion-hooks.

Hooks

useInViewScroll

Returns a MotionValue representing the y scroll progress that updates when the target element is visible in viewport.

const MyComponent = () => {
  const ref = useRef()

  const progress = useInViewScroll(ref)

  return <motion.div ref={ref} style={{ scale: progress }} />
}

Comprehensive example →

API

const scrollProgress = useInViewScroll(ref, options)

  • scrollProgress: A number between 0 and 1 indicating relative page scroll
  • ref: React ref target element
  • options: (optional) Scroll options (e.g. threshold)

useInViewAnimate Deprecated

Note: Deprecated in favor of Framer Motion's native whileInView prop introduced in version 5.3.

Fires an animation as soon as the element is visible in viewport.

const MyComponent = () => {
  const { inViewRef, animation } = useInViewAnimate({ animate: "visible" })

  return (
    <motion.div
      ref={inViewRef}
      initial="initial"
      animate={animation}
      variants={variants}
    />
  )
}

const variants = {
  initial: {
    x: 0
  },
  visible: {
    x: 200
  }
}

Comprehensive example →

Note: Also works with direct props on the React element

API

const { inViewRef, animation } = useInViewAnimate(variants, options)

  • inViewRef: React ref
  • animation: Motion animation controls
  • variants: Motion target object
  • options: (optional) Intersection options

useMotionAsState

Returns a React state value that updates when the MotionValue changes

const MyComponent = () => {
  const { scrollY } = useViewportScroll()

  const reactState = useMotionAsState(scrollY)

  return <span>{reactState}</span>
}

API

const state = useMotionAsState(value)

  • state: React state
  • value: Motion value

useStateAsMotion

Returns a MotionValue value that updates when the React state changes

const MyComponent = () => {
  const [opacity, setOpacity] = useState(0)

  const motionOpacity = useStateAsMotion(opacity)

  return <motion.div style={{ opacity: motionOpacity }} />
}

API

const value = useStateAsMotion(state)

  • value: Motion value
  • state: React state
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].