// 즉시실행 인명함수
(() => {
const actions = {
bordFlies(){
document.querySelector(['data-index="2"'] .bird).style.transform = `translateX($(window.innerWidth)px)`;
}
}
const stepElems = document.querySelectorAll('.step');
const graphicElems = document.querySelectorAll('.graphic-item');
// 현재 활성화된(visible 클래스가 붙은) .graphic-item을 지정
let currentItem = graphicElems[0];
let ioIndex;
const io = new IntersectionObserver((entries, observer) => {
//console.log(entries[0].target.dataset.index);
ioIndex = entries[0].target.dataset.index * 1;
//console.log(iosIndex);
});
for(let i=0; i< stepElems.length; i++){
io.observe(stepElems[i]);
//stepElems[i].setAttribute('data-index', i);
stepElems[i].dataset.index = i;
graphicElems[i].dataset.index = i;
//console.log(stepElems[i].setAttribute('data-index', i));
}
// 활성화
function activate(action){
currentItem.classList.add('visible');
if(action){
actions[action](); // 오류
}
console.log(action);
}
// 비활성화
function inactivate(){
currentItem.classList.remove('visible');
}
window.addEventListener('scroll', () => {
let step;
let boundingRect;
let temp = 0;
//for (let i = 0; i < stepElems.length; i++){
for (let i = ioIndex - 1; i < ioIndex + 2; i++){
step = stepElems[i];
if(!step) continue;
boundingRect = step.getBoundingClientRect();
//console.log(boundingRect.top);
temp++;
// 범위설정
if(boundingRect.top > window.innerHeight * 0.1 && boundingRect.top < window.innerHeight * 0.8){
//console.log(step.dataset.index);
//graphicElems[step.dataset.index].classList.add('visible');
if(currentItem){
inactivate();
}
currentItem = graphicElems[step.dataset.index];
activate(currentItem.dataset.action); // 오류
}
}
console.log(temp);
});
activate();
})();// 즉시실행 인명함수
(() => {
const actions = {
bordFlies(){
document.querySelector(['data-index="2"'] .bird).style.transform = `translateX($(window.innerWidth)px)`;
}
}
const stepElems = document.querySelectorAll('.step');
const graphicElems = document.querySelectorAll('.graphic-item');
// 현재 활성화된(visible 클래스가 붙은) .graphic-item을 지정
let currentItem = graphicElems[0];
let ioIndex;
const io = new IntersectionObserver((entries, observer) => {
//console.log(entries[0].target.dataset.index);
ioIndex = entries[0].target.dataset.index * 1;
//console.log(iosIndex);
});
for(let i=0; i< stepElems.length; i++){
io.observe(stepElems[i]);
//stepElems[i].setAttribute('data-index', i);
stepElems[i].dataset.index = i;
graphicElems[i].dataset.index = i;
//console.log(stepElems[i].setAttribute('data-index', i));
}
// 활성화
function activate(action){
currentItem.classList.add('visible');
if(action){
actions[action](); // 오류
}
console.log(action);
}
// 비활성화
function inactivate(){
currentItem.classList.remove('visible');
}
window.addEventListener('scroll', () => {
let step;
let boundingRect;
let temp = 0;
//for (let i = 0; i < stepElems.length; i++){
for (let i = ioIndex - 1; i < ioIndex + 2; i++){
step = stepElems[i];
if(!step) continue;
boundingRect = step.getBoundingClientRect();
//console.log(boundingRect.top);
temp++;
// 범위설정
if(boundingRect.top > window.innerHeight * 0.1 && boundingRect.top < window.innerHeight * 0.8){
//console.log(step.dataset.index);
//graphicElems[step.dataset.index].classList.add('visible');
if(currentItem){
inactivate();
}
currentItem = graphicElems[step.dataset.index];
activate(currentItem.dataset.action); // 오류
}
}
console.log(temp);
});
activate();
})();// 즉시실행 인명함수
(() => {
const actions = {
bordFlies(){
document.querySelector(['data-index="2"'] .bird).style.transform = `translateX($(window.innerWidth)px)`;
}
}
const stepElems = document.querySelectorAll('.step');
const graphicElems = document.querySelectorAll('.graphic-item');
// 현재 활성화된(visible 클래스가 붙은) .graphic-item을 지정
let currentItem = graphicElems[0];
let ioIndex;
const io = new IntersectionObserver((entries, observer) => {
//console.log(entries[0].target.dataset.index);
ioIndex = entries[0].target.dataset.index * 1;
//console.log(iosIndex);
});
for(let i=0; i< stepElems.length; i++){
io.observe(stepElems[i]);
//stepElems[i].setAttribute('data-index', i);
stepElems[i].dataset.index = i;
graphicElems[i].dataset.index = i;
//console.log(stepElems[i].setAttribute('data-index', i));
}
// 활성화
function activate(action){
currentItem.classList.add('visible');
if(action){
actions[action](); // 오류
}
console.log(action);
}
// 비활성화
function inactivate(){
currentItem.classList.remove('visible');
}
window.addEventListener('scroll', () => {
let step;
let boundingRect;
let temp = 0;
//for (let i = 0; i < stepElems.length; i++){
for (let i = ioIndex - 1; i < ioIndex + 2; i++){
step = stepElems[i];
if(!step) continue;
boundingRect = step.getBoundingClientRect();
//console.log(boundingRect.top);
temp++;
// 범위설정
if(boundingRect.top > window.innerHeight * 0.1 && boundingRect.top < window.innerHeight * 0.8){
//console.log(step.dataset.index);
//graphicElems[step.dataset.index].classList.add('visible');
if(currentItem){
inactivate();
}
currentItem = graphicElems[step.dataset.index];
activate(currentItem.dataset.action); // 오류
}
}
console.log(temp);
});
activate();
})();