How to use the @react-spring/animated.withAnimated function in @react-spring/animated

To help you get started, we’ve selected a few @react-spring/animated examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github react-spring / react-spring / packages / addons / src / parallax.tsx View on Github external
import { useOnce } from 'shared'

declare const window: {
  addEventListener(
    name: string,
    fn: (event: any) => void,
    capture?: boolean
  ): void
  removeEventListener(
    name: string,
    fn: (event: any) => void,
    capture?: boolean
  ): void
}

const AnimatedView = withAnimated(View)
const ParentContext = React.createContext(null)

function getScrollType(horizontal: boolean) {
  return horizontal ? 'scrollLeft' : 'scrollTop'
}

const START_TRANSLATE_3D = 'translate3d(0px,0px,0px)'
const START_TRANSLATE = 'translate(0px,0px)'

interface IParallaxLayer {
  setHeight(height: number, immediate?: boolean): void
  setPosition(height: number, scrollTop: number, immediate?: boolean): void
}

interface IParallax {
  config: ConfigProp