最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - GSAP Horizontal Scroll component not working when there is another one that takes time to load - Stack Overflow

programmeradmin1浏览0评论

Here is the problem: I have this horizontal scroll component that works fine with all the other static components, but once I add a component which loads the camera and a library called Mediapipe, it glitches when I scroll. As you can see in the video the Test component is alright, but when it comes to the CameraQuestions it glitches. Video. Thanks :)

import React, { useState } from "react";
import CameraQuestions from "../components/quiz/CameraQuestions.jsx";
import Test from "../components/quiz/Test.jsx";
import ScrollSection from "../components/quiz/ScrollSection.jsx";
import "../styles/quiz.css";

function Quiz() {
  const [result, setResult] = useState({}); // Initialize as an empty object

  const handleFinalResults = (newScores) => {
    // Merge new scores with the existing ones
    setResult((prevResult) => {
      const updatedResult = { ...prevResult };
      Object.keys(newScores).forEach((key) => {
        updatedResult[key] = (prevResult[key] || 0) + newScores[key];
      });
      console.log("Result received in parent:", updatedResult);
      return updatedResult;
    });
  };

  return (
    <>
      <CameraQuestions onCalculateFinalResults={handleFinalResults} />
      <Test onCalculateFinalResults={handleFinalResults} />
      {Object.keys(result).length > 0 && (
        <div>
          <h2>Parent Results:</h2>
          <pre>{JSON.stringify(result, null, 2)}</pre>
        </div>
      )}
      <ScrollSection />
    </>
  );
}

export default Quiz;

I tried adding the horizontal scroll component to the beginning of the page, but didn't work.

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论