• 카테고리

    질문 & 답변
  • 세부 분야

    프론트엔드

  • 해결 여부

    미해결

모르겟습니다ㅠㅠ..

22.02.21 16:31 작성 조회수 157

0

안녕하세요, 스크립트 에러가 나서ㅠ 어떤게 문제인지 모르겟습니다,,

 

아래 스크립트 소스 드리고, 에러가 나는건 현재 이거랑 같습니다.

 
(() => {

    const sceneInfo = [
        {
            // 0
            type:'sticky',
            heightNum: 5, // 브라우저 높이의 5배로 스크롤하이트 세팅
            scrollHeight: 0,
            objs :  {
                container: document.querySelector('#scroll-section-0')
            }
        },

        {
            // 1
            type:'normal',
            heightNum: 5,
            scrollHeight: 0,
            objs :  {
                container: document.querySelector('#scroll-section-1')
            }
        },

        {
            // 2
            type:'sticky',
            heightNum: 5,
            scrollHeight: 0,
            objs :  {
                container: document.querySelector('#scroll-section-2')
            }
        },

        {
            // 3
            type:'sticky',
            heightNum: 5,
            scrollHeight: 0,
            objs :  {
                container: document.querySelector('#scroll-section-3')
            }
        },

    ];

    function setLayout() {
        // 각 스크롤 섹션의 높이 세팅
        for (let i = 0; 1 < sceneInfo.length; i++) {
            sceneInfo[i].scrollHeight = sceneInfo[i].heightNum * innerHeight;
            sceneInfo[i].objs.container.style.height = `${sceneInfo[i].scrollHeight}px`;
        }


    }

    window.addEventListener('resize', setLayout);

    setLayout();

})();
 

답변 1

답변을 작성해보세요.

0

setLayout에서 for문에 i를 1로 잘못 쓰셨네요~

for (let i = 0; 1 < sceneInfo.length; i++) {

for (let i = 0; i < sceneInfo.length; i++) {

로 고쳐주세요.