20220607 TIL

GURIยท2022๋…„ 6์›” 7์ผ
0
post-thumbnail

full page plugin

full page plugin
https://alvarotrigo.com/fullPage/ko/

CDN
https://cdnjs.com/libraries/fullPage.js



๐Ÿ“ŒFull page plugin ํ™œ์šฉ ์˜ˆ์ œ 1

    <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 ์ง€์ •ํ•˜๋ฉด ํ•ด๋‹น ์„น์…˜์„ ์ธ๋ฑ์Šค๋กœ ๋ถˆ๋Ÿฌ์˜ฌ ์ˆ˜ ์žˆ์Œ.



๐Ÿ“ŒFull page plugin ํ™œ์šฉ ์˜ˆ์ œ 2

์ฝœ๋ฐฑํ•จ์ˆ˜๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ํŽ˜์ด์ง€๊ฐ€ ๋กœ๋“œ๋œ ํ›„ ํšจ๊ณผ ์ ์šฉํ•˜๊ธฐ.

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')
            })
        }
    }






javascript

๋น„๊ตฌ์กฐํ™” ํ• ๋‹น(distructuring)

๊ฐ์ฒด, ๋ฐฐ์—ด์—์„œ ๊ฐ’์„ ๊บผ๋‚ด์–ด ๊ทธ ๊ฐ’์„ ๋ณ„๋„์˜ ๋ณ€์ˆ˜์— ๋Œ€์ž…ํ•˜๋Š” ๋ฌธ์žฅ.

๋ฐฐ์—ด

์ถ•์•ฝ

<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)

jsํŒŒ์ผ์—์„œ ์ผ๋ถ€ ๋ถˆ๋Ÿฌ์˜ค๊ธฐ

ํ˜•์‹

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)






react

single page application

component

style ์ ์šฉํ•˜๊ธฐ

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 ํ˜ผํ•ฉํ•ด์„œ ์‚ฌ์šฉ
์ค‘๊ด„ํ™ˆ, ์นด๋ฉœํ‘œ๊ธฐ๋ฒ• ์‚ฌ์šฉ.

profile
๊ฐœ๋ฐœ์ž ์„ฑ์žฅ๊ธฐ

0๊ฐœ์˜ ๋Œ“๊ธ€