[메모] Slide 인덱스 설정하기

임택·2021년 3월 5일
0

메모

목록 보기
4/14
// data = [], show = [], currIdx = -5, range = 5;
// this.seShow(false);
    setShow = (isLeft) => {
        let { data, show, currIdx, range } = this.state;
        const len = data.length;
        currIdx += len;
        if (isLeft == 1) {
            console.log('>>> ', isLeft);
			for (let i = range - 1; i >= 0; i--) {
                currIdx--;
                show[i] = (currIdx) % len;
			}            
        } else {
            for (let i = 0; i < range; i++) {
                show[i] = (currIdx + range) % len;
                currIdx++;
			}
        }
        
        this.setState({ ...this.state, currIdx: currIdx % len, show});
        console.log(isLeft, this.state.currIdx);
        return show;
    }
.arrow {
	/* border: 2px dotted red; */
	text-align: center;
	display: inline;

	/* TODO: 가로 길이를 정해 놓아야 font-size가 커지는 이벤트 새길 때 
			 다른 엘리먼트가 밀려나지 않는다.
	*/
	width: 5vw;
	font-size: 2.5em;
	padding: 0 0.5vw;

	min-width: 35px;
}
profile
캬-!

0개의 댓글