Skip to content

Commit

Permalink
fix: use "frameLoop.onFrame" in Parallax
Browse files Browse the repository at this point in the history
Closes #820
  • Loading branch information
aleclarson committed May 3, 2020
1 parent 3ccdfe7 commit 1c9b429
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/addons/src/parallax.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import React, {
useEffect,
CSSProperties,
} from 'react'
import { requestAnimationFrame, defaultElement as View } from 'shared/globals'
import { frameLoop, defaultElement as View } from 'shared/globals'
import { Controller, SpringConfig, config as configs } from '@react-spring/core'
import { withAnimated } from '@react-spring/animated'
import { useMemoOne } from 'use-memo-one'
Expand Down Expand Up @@ -239,7 +239,7 @@ export const Parallax = React.memo(
if (!state.busy) {
state.busy = true
state.current = event.target[getScrollType(horizontal)]
requestAnimationFrame(() => {
frameLoop.onFrame(() => {
state.layers.forEach(layer =>
layer.setPosition(state.space, state.current)
)
Expand All @@ -254,7 +254,7 @@ export const Parallax = React.memo(

const onResize = () => {
const update = () => state.update()
requestAnimationFrame(update)
frameLoop.onFrame(update)
setTimeout(update, 150) // Some browsers don't fire on maximize!
}

Expand Down

0 comments on commit 1c9b429

Please sign in to comment.