• Runtimes
  • The click event bound to React cannot be triggered

  • Изменено

After the skeletal animation appears, the click event bound to React cannot be triggered. I want to implement a click event at a certain position in the image to change the animation mode

const SpineAnimation = () => {

    const containerRef = useRef(null);

    useEffect(() => {
        if (containerRef.current) {
            const spinePlayer = new SpinePlayer(containerRef.current, {
                jsonUrl: "https://i1.branchcn.com/static/skeleton.json",
                atlas: "https://i1.branchcn.com/static/skeleton.atlas",
                backgroundColor: '#00000000',
                preserveDrawingBuffer: true,
                animation: "animation",
                showControls: false,
                showLoading: false,
                alpha: true,
            });


            return () => {
                spinePlayer && spinePlayer.dispose();
            };
        }
    }, []);

    return (
        <div ref={containerRef}
            onClick={() => {
                console.log(1)
            }}></div>
    );
};

export default SpineAnimation;
Related Discussions
...

Spinebot It doesn't work either, how to prevent Spine Player from capturing click events

  • Davide ответили на это сообщение.

    17573207179

    I've deleted Spinebot's answer since it wasn't the best advice.

    I tried your code, and it works fine for me. Which Spine runtime version and React version are you using?

    Ideally, the easiest way to assist you would be if you shared a minimal reproduction project here or via email at contact@esotericsoftware.com.