• 카테고리

    질문 & 답변
  • 세부 분야

    프론트엔드

  • 해결 여부

    미해결

도움 요청 드려요 ..

20.08.25 20:08 작성 조회수 89

0

이러다가 삽을 계속 파게 될 거 같아서.. 도움을 요청합니다

main.add.js 코드 옮기고 나서 애니메이션 동작이 안돼요

https://github.com/kimjinseong1/apple-test

답변 1

답변을 작성해보세요.

0

새로운 씬(섹션) 진입 순간의 여부를 판별해주는 enterNewScene 변수를 설정하는 부분이 잘못 들어갔습니다.
잘못 들어간 부분은 아래 주석처리 했습니다^^

function scrollLoop() { //지금 몇번째 섹션인지 판별해주는 곳 22
enterNewScene= false;
prevScrollHeight = 0;

for(let i = 0; i < currentScene; i++) {
// enterNewScene= true; 이 부분이 잘못 들어갔습니다
prevScrollHeight +=sceneInfo[i].scrollHeight; // 18740 4685 +4685 +4685 +4685
}
if(yOffset > prevScrollHeight +sceneInfo[currentScene].scrollHeight) { //* > 4685 + 4685
enterNewScene= true;
currentScene++;
document.body.setAttribute('id',`show-scene-${currentScene}`);

} else if(yOffset < prevScrollHeight) { // 0~18740 < 4685 & 9370 %
enterNewScene = true; // 여기에 넣어주셔야 합니다 :)
if(currentScene === 0 ) return;
currentScene--;
document.body.setAttribute('id',`show-scene-${currentScene}`);

}
if(enterNewScene) return;
playAnimation();
}