react-scrollmagic icon indicating copy to clipboard operation
react-scrollmagic copied to clipboard

How do I add ScrollMagic EventHandlers in React?

Open rgala98 opened this issue 5 years ago • 1 comments

How Do I add scrollmagic Event handlers in React. I want to use scene.on("update",e => {....}). But I don't find a way to use it.

Please help

rgala98 avatar Nov 26 '20 05:11 rgala98

@rgala98 I am looking into event handling atm.

This is relevant: https://github.com/bitworking/react-scrollmagic/issues/2

This means, that you should wrap the child of your scene in a function, that returns the child of <Scene>. You can access progress and event there.

Check the event for what is available.

Barebones example (not tested, but illustrates the concept):


import React from "react"
import { Controller, Scene } from "react-scrollmagic"

export const AnimationPlug = ({}) => {
  return (
    <>
      <Controller>
        <Scene>
          {(event) => {
            console.log("event:",  event)

            return <div></div>
          }}
        </Scene>
      </Controller>
    </>
  )
}

Hahlh avatar Mar 02 '21 11:03 Hahlh