inflearn logo
강의

강의

N
챌린지

챌린지

멘토링

멘토링

N
클립

클립

로드맵

로드맵

지식공유

애플 웹사이트 인터랙션 클론!

현재 활성시킬 씬 결정하기

ㅜㅜ11강부터 오류한거같아요

377

kim05

작성한 질문수 1

0

안녕하세요

제가 청각장애인데 못들리지만 강의 잘 따라하고 있는데 11강부터 자꾸 오류 나와서 고치는부분 열심히 찾아봐도 잘모르겠어요...자막없으셔서 무슨말인지 모르고 답답해요ㅠ..

혹시 완성 되신파일 보내주실수있을까요?..

인터랙티브-웹 javascript svg 웹 디자인 HTML/CSS 클론코딩

답변 5

2

1분코딩

자막 없이 보시느라 고생이 많으십니다 ㅠㅠ
setLayout 함수의 for문 설정 부분에 오타가 있네요~

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

sceneInfo,length를 sceneInfo.length로 바꾸어주세요~
(쉼표가 아니라 마침표로)

0

kim05

오류 있으신지 확인부탁드려요~

0

kim05

@charset 'utf-8';

html {
	font-family: 'Abel', sans-serif;
	font-family: 'Noto Sans', sans-serif;
	font-size: 14px;
}
body {
	overflow-x: hidden;
	color: rgb(29, 29, 31);
	letter-spacing: -0.05em;
	background: white;
}
p {
	line-height: 1.6;
}
a{
    color: rgb(29,29,31);
    text-decoration: none;
}
.global-nav{
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 44px;
    padding: 0 1rem;
}
.local-nav{
    position: absolute;
    top: 45px;
    left: 0;
    width: 100%;
    height: 52px;
    padding: 0 1rem;
    border-bottom: 1px solid #ddd;
}
.global-nav-link,
.local-nav-links{
    display: flex;
    align-items: center;
    height: 100%;
    max-width: 1000px;
    margin: 0 auto;
}
.global-nav-link{
    justify-content: space-between;
}
.local-nav-links .product-name{
    margin-right: auto;
    font-size: 1.4rem;
    font-weight: bold;
}
.local-nav-links a{
    font-size: 0.8rem;
}
.local-nav-links a:not(.product-name){
    margin-left: 2em;    
}
.scroll-section{
    border: 3px solid red;
    padding-top: 50vh;
}
#scroll-section-0 h1{
    font-size: 4rem;
    text-align: center;
}
.main-message{
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 5px 0;
    height: 3em;
    font-size: 2.5rem;
/*    background: rgba(0,0,0,0.3); 확인하기*/
}
.main-message p{
    font-weight: bold;
    line-height: 1.2;
    text-align: center;
    
}
.main-message small{
    display: block;
    font-size: 1rem;
    margin-bottom: 0.5em;
}
#scroll-section-2 .main-message{
    font-size: 3.5rem;
}
.description{
    padding: 0 1rem;
    font-size: 1.2rem;
    color: #888;
    max-width: 1000px;
    margin: 0 auto;
}
.description strong{
    float: left;
    margin-right: 0.2em;
    font-size: 3rem;
    color: rgba(29,29,31);
}
/*html-font-size: 14px X .description strong- font-size: 3rem =42
X .description strong-margin-right: 0.2em = 8.4*/
.desc-message {
    width: 50%;
    font-weight: bold;
}
.pin{
    width: 1px;
    height: 100px;
    background: rgb(29,29,31);
}
.mid-messaga{
    max-width: 1000px;
    margin: 0 auto;
    padding: 0 1rem;
    font-size: 2rem;
    color: #888;
}
.mid-messaga strong{
    color: rgb(29,29,31);
}
.canvas-caption{
    padding: 0 1rem;
    color: #888;
    font-size: 1.2erm;
}
.footer{
    display: flex;
    align-items: center;
    justify-content: center;
    height: 7rem;
    background: darkorange;
    color: #fff;
}
.sticky-elem{
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    
}
#show-scene-0 #scroll-section-0 .sticky-elem,
#show-scene-1 #scroll-section-1 .sticky-elem,
#show-scene-2 #scroll-section-2 .sticky-elem,
#show-scene-3 #scroll-section-3 .sticky-elem{
    display: block;
}





@media(min-width: 1024px){
    
    #scroll-section-0 h1{
        font-size: 9vw;
    }
    .main-message{
       font-size: 4vw; 
    }
    .description{  
        font-size: 2rem; 
    }
    .description strong{
        font-size: 6rem;
    }
    #scroll-section-2 .main-message{
        font-size: 6vw;
    }
    .main-message small{
        font-size: 1.5vw;
    }
    .desc-message {
        width: 20%;
    }
    .mid-messaga{
        font-size: 4vw;
    }
    .canvas-caption{
        font-size: 2rem;
    }
}















0

kim05

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>AirMug Pro</title>
    <link rel="stylesheet" href="main.css">

    <link rel="preconnect" href="https://fonts.googleapis.com">
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
    <link href="https://fonts.googleapis.com/css2?family=Abel&family=Noto+Sans:ital,wght@1,700&display=swap" rel="stylesheet">

</head>
<body>
    <div class="container">
        <nav class="global-nav">
            <div class="global-nav-link">
                <a href="#" class="global-nav-item">Rooms</a>
                <a href="#" class="global-nav-item">Ideas</a>
                <a href="#" class="global-nav-item">Stores</a>
                <a href="#" class="global-nav-item">Contact</a>
            </div>
        </nav>
        <nav class="local-nav">
            <div class="local-nav-links">
                <a href="#" class="product-name">AirMug Pro</a>
                <a href="#">개요</a>
                <a href="#">제품사양</a>
                <a href="#">구입하기</a>
            </div>
        </nav>
        <section class="scroll-section" id="scroll-section-0">
            <h1>AirMug Pro</h1>
            <div class="sticky-elem main-message">
                <p >온전히 빠져들게 하는<br>최고급 세라믹</p>
            </div>
            <div class="sticky-elem main-message">
                <p>주변 맛을 느끼게 해주는<br>주변 맛 허용 모드</p>
            </div>
            <div class="sticky-elem main-message">
                <p>온종일 편안한<br>맞춤형 손잡이</p>
            </div>
            <div class="sticky-elem main-message">
               <p>새롭게 입가를<br>찾아온 매혹</p>
            </div>
        </section>
        <section class="scroll-section" id="scroll-section-1">
            <p class="description">
                <strong>보통 스크롤 영역</strong>
                Lorem ipsum dolor sit amet, consectetur adipisicing elit. Beatae est ipsa minima, eligendi error cum vel dolorum pariatur officia facilis ipsam voluptatibus ad quasi porro quod quisquam quidem tempora accusantium accusamus, quaerat aliquam velit exercitationem incidunt? Id vitae quisquam saepe quasi accusantium tempore enim! Aperiam dolorum a vero repellat dolor, inventore ab odit totam molestias expedita? Enim quia dolor maiores veniam ea! Quam illo, est incidunt ipsa reiciendis modi quisquam reprehenderit fuga velit dolorem odit sequi autem blanditiis, ullam commodi quibusdam. Accusamus repellat aperiam quis neque laudantium, dignissimos hic nisi magnam praesentium enim beatae sint architecto cum numquam inventore rerum animi sed nostrum quae delectus, voluptas molestiae placeat aliquid! Vel quaerat error officiis magnam dolorum iste aspernatur at est! Quo, consequuntur? Reiciendis, dolor. Quo at cupiditate in iure obcaecati voluptatum vel ea! Ab vel harum facere hic fuga ducimus sapiente dolore dolorem, nobis sint perferendis cumque esse! Omnis fugiat sint error laborum eveniet labore nam ducimus quisquam in repudiandae impedit excepturi dignissimos tenetur libero placeat rerum maxime tempore, aut nihil. Qui, quam? Voluptate fuga possimus itaque quas nesciunt iste, facilis mollitia illo qui placeat temporibus inventore obcaecati. Recusandae, sequi dignissimos in natus eum maiores dolorem, deleniti nobis accusantium, aspernatur beatae.
            </p>
        </section>
        <section class="scroll-section" id="scroll-section-2">
            <div class="sticky-elem main-message a">
				<p>
					<small>편안한 촉감</small>
					입과 하나 되다
				</p>
			</div>
			<div class="sticky-elem desc-message b">
				<p>
					편안한 목넘김을 완성하는 디테일한 여러 구성 요소들, 우리는 이를 하나하나 새롭게 살피고 재구성하는 과정을 거쳐 새로운 수준의 머그, AirMug Pro를 만들었습니다. 입에 뭔가 댔다는 감각은 어느새 사라지고 오롯이 당신과 음료만 남게 되죠.
				</p>
				<div class="pin"></div>
            </div>
            <div class="sticky-elem desc-message c">
                    <p>
                        디자인 앤 퀄리티 오브 스웨덴,<br>메이드 인 차이나
                    </p>
                    <div class="pin"></div>
            </div>
        </section>
        <section class="scroll-section" id="scroll-section-3">
            <p class="mid-messaga">
				<strong>Retina 머그</strong><br>
				아이디어를 광활하게 펼칠<br>
				아름답고 부드러운 음료 공간.
			</p>
<!--			<canvas class="image-blend-canvas" width="1920" height="1080"></canvas>-->
			<p class="canvas-caption">
				Lorem ipsum dolor, sit amet consectetur adipisicing elit. Eveniet at fuga quae perspiciatis veniam impedit et, ratione est optio porro. Incidunt aperiam nemo voluptas odit quisquam harum in mollitia. Incidunt minima iusto in corporis, dolores velit. Autem, sit dolorum inventore a rerum distinctio vero illo magni possimus temporibus dolores neque adipisci, repudiandae repellat. Ducimus accusamus similique quas earum laborum. Autem tempora repellendus asperiores illum ex! Velit ea corporis odit? Ea, incidunt delectus. Sapiente rerum neque error deleniti quis, et, quibusdam, est autem voluptate rem voluptas. Ratione soluta similique harum nihil vel. Quas inventore perferendis iusto explicabo animi eos ratione obcaecati.
			</p>
        </section>
        <footer class="footer">
			2020, 1분코딩
		</footer>
    </div>
    
    <script src="main.js"></script>
</body>
</html>

0

kim05

(()=>{
    
    let y0ffset = 0 ; //window.pageYOffset 대신 쓸 변수
    let prevScrollHeight = 0; //현재 스크롤 위치(yOffset)보다 이전에 위치한 스크롤 섹션들의 스크롤 높이값의 합
    let currentScene = 0; //현재 활성화된(눈 앞에 보고있는) 씬(scroll-section)
    
//    const arr =[1,2,3];
    const sceneInfo = [
        {//스크롤 높이 0
            type: 'sticky',
            heightNum: 5, //브라우저 높이의 5배로 scrollHeight 세팅
            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; i < sceneInfo,length; i++){
            sceneInfo[i].scrollHeight = sceneInfo[i].heightNum * window.innerHeight;
            sceneInfo[i].objs.container.style.height = '${sceneInfo[i].scrollHeight}px';
        }
        
        console.log(sceneInfo);
    }

    
//    let y0ffset = 0;
    function scrollLoop(){
//        y0ffset = window.pageYOffset;
//        console.log(y0ffset);
        
        prevScrollHeight = 0;
        for(let i = 0; i < currentScene; i++){
            prevScrollHeight += sceneInfo[i].scrollHeight;
        }
//        console.log(prevScrollHeight);
        
        if(y0ffset > prevScrollHeight + sceneInfo[currentScene].scrollHeight) {
            currentScene++;
        }
        
        if(y0ffset < prevScrollHeight){
            if(currentScene === 0) return; //브라우저 바운스 효과로 인해 마이너스가 되는 것을 방지(모바일)
            currentScene--;
        }
        
//        console.log(currentScene);
        document.body.setAttribute('id','show-scenes-${currentScene}');
    }
    
    
    window.addEventListener('resize', setLayout);
    window.addEventListener('scroll', () => {
        y0ffset = window.pageYOffset;
        scrollLoop();
    });
    
    setLayout();
    
})();
//(function() {})();

//comsole.log(arr);

이미지 배경 문의

0

81

1

[크로스브라우징] safari에서 동영상 영역 미노출

0

123

1

항상 궁금했는데 크림슨 컬러 선택하셨을때 활용했던 사이트 좀 알려주세요~

0

130

2

vue강의는안하시나요?!

0

124

1

스크롤 속도에 따른 messageA_opacity_out

0

130

1

drawImage(objs.videoImages[sequence], 0, 0); error

0

94

1

선생님 캔버스 width 크기는 이미지 크기에맞게 해줘야하나요?

0

137

0

선생님 안녕하세요. 혹시 메인개발(?)분야가 뭔지 궁금합니다.

0

219

1

React에서 load 상태를 어떻게 감지할 수 있을까요?

0

699

1

[섹션7-3: 버그수정 2] tempYOffset 오류

0

207

1

스크롤할 때 캔버스로 하신 이유가 있으신가요? 그냥 성능 떄문에 캔버스로 하신건가요?

0

326

2

게속 오류떠서 글 작성해봐요....

0

531

2

Vanilla JavaScript로 SPA 만드는 자료 혹은 선택 기준을 추천해주실 수 있으신가요?

1

500

1

특정 타이밍 스크롤 애니메이션 적용하기 섹션 수강중입니다.

0

464

2

[#svg, #이미지프레임과 텍스트 싱크] 스크롤 값에 움직이는 svg path, 이미지프레임과 텍스트 싱크 맞추는 것, 2가지 질문이 있습니다.

0

460

2

페이지가 처음 로딩 되었을 때 애니메이션 처리가 되지 않는 느낌입니다

0

444

1

섹션2 번째, opacity=0 되지 않고 잔상이 남습니다.

0

538

1

원래 쿼리셀렉터에서는 띄워쓰기 하면안되나요?

0

605

2

라이브러리 질문

1

419

2

translateY대신 애플에서 사용한 것 처럼 matrix로 scale의 크기를 주려고 하는데

0

416

1

[스크롤 높이 세팅] scrollHeight값이 3990아닌 4645로만 나오는데 뭐가 문제일까요? ㅠㅠ

0

606

2

scrollLoop 함수 질문

0

482

2

도메인 웹호스팅시 이미지가 안 뜨는데 누가 좀 알려주세요ㅠㅜ

0

1242

2

load 이벤트시 첫 비디오 이미지가 뜨네요.

0

512

2