From 1c9b4297cebb7867a8beb25466bb6e35369a9430 Mon Sep 17 00:00:00 2001 From: Alec Larson Date: Mon, 30 Sep 2019 10:14:43 -0400 Subject: [PATCH] fix: use "frameLoop.onFrame" in Parallax Closes #820 --- packages/addons/src/parallax.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/addons/src/parallax.tsx b/packages/addons/src/parallax.tsx index 0bb3c06f29..57cf16f149 100644 --- a/packages/addons/src/parallax.tsx +++ b/packages/addons/src/parallax.tsx @@ -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' @@ -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) ) @@ -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! }