full page plugin
https://alvarotrigo.com/fullPage/ko/
CDN
https://cdnjs.com/libraries/fullPage.js
<div id="menuBar"> <ul class="gnb"> <li data-menuanchor="section0"><a href="#section0">Section1</a></li> <li data-menuanchor="section1"><a href="#section1">Section2</a></li> <li data-menuanchor="section2"><a href="#section2">Section3</a></li> <li data-menuanchor="section3"><a href="#section3">Section4</a></li> </ul> </div> <div id="fullpage"> <div class="section s1"></div> <div class="section s2"></div> <div class="section s3"></div> <div class="section s4"></div> </div>
<script> new fullpage('#fullpage', { licenseKey:'OPEN-SOURCE-GPLv3-LICENSE', autoScrolling:true, scrollHorizontally: true, menu : '.gnb',๐ anchors: ['section0','section1','section2','section3']๐ }); </script>
1) ๋ฉ๋ด์ ํด๋นํ๋ li์ data-menuanchor
๊ฐ ์ง์ .
2) js ์ด๊ธฐํ์ menu์ anchor ์ง์ ํ๋ฉด ํด๋น ์น์ ์ ์ธ๋ฑ์ค๋ก ๋ถ๋ฌ์ฌ ์ ์์.
์ฝ๋ฐฑํจ์๋ฅผ ์ฌ์ฉํ์ฌ ํ์ด์ง๊ฐ ๋ก๋๋ ํ ํจ๊ณผ ์ ์ฉํ๊ธฐ.
afterLoad
(origin, destination, direction, trigger)
Demo Callback fired once the sections have been loaded, after the scrolling has ended. Parameters:
origin
: (Object) section of origin.
destination
: (Object) destination section.
direction
: (String) it will take the values up or down depending on the scrolling direction.
trigger
: (String) indicates what triggered the scroll. It can be: "wheel", "keydown", "menu", "slideArrow", "verticalNav", "horizontalNav".
์ถ์ฒ : https://github.com/alvarotrigo/fullPage.js#readme
afterLoad: function(origin, destination, direction){ let num = destination.index; if(num==2){ li.forEach((ele)=>{ ele.classList.add('on') }) }else{ li.forEach((ele)=>{ ele.classList.remove('on') }) } }
๊ฐ์ฒด, ๋ฐฐ์ด์์ ๊ฐ์ ๊บผ๋ด์ด ๊ทธ ๊ฐ์ ๋ณ๋์ ๋ณ์์ ๋์ ํ๋ ๋ฌธ์ฅ.
์ถ์ฝ
<script> const arr = [1,2,3,4,5]; const arr1 = arr[0]; const arr2 = arr[1]; const arr3 = arr[2]; const arr4 = arr[3]; const arr5 = arr[4]; </script>
<script> let arr = [1,2,3,4,5]; const [arr1,arr2,arr3,arr4,arr5] = [1,2,3,4,5]; </script>
const [num1,num2,num3 = 300]=[100,200] console.log(num3)
num3=300
์์ ์ undefined.
์ฌํ ๋น
let[a,b] = ['์ฒ ์','์ํฌ']; console.log(a); [a,b]=[100,200]; console.log(a);
์ค์ฒฉ
let price, item1, item2; price = [item1, item2] = ['์ฌ๊ณผ','๋ฐฐ','ํค์','๊ทค']; console.log(item1); //์ฌ๊ณผ console.log(item2); //๋ฐฐ console.log(price)//['์ฌ๊ณผ', '๋ฐฐ', 'ํค์', '๊ทค']
์ค์ฒฉ๋ ๊ฒฝ์ฐ ๊ฐ์ฅ ์ฐ๋ณ์ ๊ฐ์ด ๋ค์ด๊ฐ๋ค.
last element
const [txt1,txt2,...txt3] = ['a','b','c','d'] console.log(txt3)//['c', 'd'] console.log(txt3[0], txt3[1])//c , d
...
: ๋๋จธ์ง ๊ฐ ๋ฐฐ์ด๋ก ์ ๋ถ ๋ฐ์์ด.
ํจ์๋ก ํธ์ถ
function arrFnc(name, age){ console.log(name) console.log(age) } const people = ['shin', 20<] arrFnc(people[0],people[1])
... arrFnc(['shin', 20]) //[name, age] = ['shin', 20]
const {age : b,name : a} = {name:'lee', age:30} console.log(a)//lee console.log(b)//30
๋ฐฐ์ด์ ์ธ๋ฑ์ค ๊ฐ์ผ๋ก ๋ถ๋ฌ์ด. ์์๋ฅผ ๋ฐ๊พธ๋ฉด ๋ค์ด๊ฐ๋ ๊ฐ์ด ๋ฌ๋ผ์ง. ๋ฐ๋ฉด ๊ฐ์ฒด๋ ์์๊ฐ ์๋ key๊ฐ์ผ๋ก ํธ์ถ.
์ถ์ฝ
const {age : age,name : name} = {name:'lee', age:30}
const {age,name} = {name:'lee', age:30}
const address = 'seoul'; const telNum = '010'; const gender = 'male'; const user ={ address :address, telNum : telNum, gender : gender }
const user ={address ,telNum ,gender}
์ด๊ธฐ๊ฐ
const {a:x=0,b:y=0,c:z=0} = {a:1, b:2, c:3} console.log(x,y,z)//1 2 3
const {a:x=0,b:y=0,c:z=0} = {a:1, b:2, c} //์๋ฌ๋ฐ์
const {a:x=0,b:y=0,c:z=0} = {a:1, b:2} console.log(x,y,z)//1 2 0
ํจ์๋ก ํธ์ถ
function objFnc (name, age){ console.log(name) console.log(age) } const obj = {name : 'won', age : 10} objFnc(obj.name , obj.age)
function objFnc (name, age){ console.log(name) console.log(age) } const obj = {name : 'won', age : 10}//=objFnc(obj.name , obj.age) objFnc(obj)//={name, age} = {name : 'won', age : 10}
let product ={ shape :{width:150,height:100,weight:50,},color:['red', 'green', 'yellow'] } console.log(product.shape.width) let {shape :{width,height,weight},color:[topColor,bottomColor,sideColor]} = product console.log(width) console.log(weight) console.log(height) console.log(topColor) console.log(bottomColor) console.log(sideColor)
ํ์
import valuebox from 'jsํ์ผ ๊ฒฝ๋ก';
์์
1) ํ๋๋ง ๋ด๋ณด๋ผ ๋
html ํ์ผ
<script type="module"> import a from './a.js';๐ </script> </head>
js ํ์ผ
const a = 100; const b = 200; const hi = '์๋ ํ์ธ์'; export default b;๐
default๋ก ์ง์ ํ์ฌ ํ๋๋ง ๋ด๋ณด๋ผ๋๋ import ์์ ์ง์ ํ ์ด๋ฆ๊ณผ ์๊ด ์์ด jsํ์ผ์์ ๋ด๋ณด๋ด๊ธฐ๋ก ์ง์ ํ ๊ฐ์ ๋ฐ์์ด.
2) ๋๊ฐ ์ด์ ๋ด๋ณด๋ผ ๋.
html ํ์ผ
<script type="module"> import {a,b,hi} from './a.js';๐ </script> </head>
js ํ์ผ
const a = 100; const b = 200; const hi = '์๋ ํ์ธ์'; export {a,b,hi};๐
๋ชจ๋์์ ์ด๋ฆ์ ์ผ์น์์ผ์ผ ๋ฐ์์ฌ ์ ์์.
3) ์ด๋ฆ ๋ค๋ฅด๊ฒ ์ง์ ํ๊ณ ์ถ์ ๋
import {a as value} from './b.js'; console.log(value)
1) css ์ฐ๊ฒฐ
import './App.css';
2) ๋ฐ๋ณต๋๋ ์์ ๋ณ์ ์ง์ ํ์ฌ ์ ์ฉ
const listLi = {margin:'0 10px',lineHeight:'50px',backgroundColor:'#778A35'} ... <li style={listLi}>๋ฆฌ์คํธ{num}</li>
3) ์ธ๋ผ์ธ์ผ๋ก ์ ์ฉ
... <ul style = {{fontSize:'30px', color:'#fff', margin:'50px auto', display:'flex',justifyContent:'center', backgroundColor:'#D1E2C4'}}> ...
jsx๋ฌธ๋ฒ : js, html ํผํฉํด์ ์ฌ์ฉ
์ค๊ดํ, ์นด๋ฉํ๊ธฐ๋ฒ ์ฌ์ฉ.