document.getElementsByClassName('element_mob')
const texts = document.getElementsByClassName('texts')
const slider = document.getElementById('slider_mob')
console.log(items)
function activeListitem() {
for(let i in items){
try {
i = parseInt(i)
items[i].classList.remove('active_mobile')
if (i === mobActive){
items[i].classList.add('active_mobile')
items[i].scrollIntoView()
this.diff = window.innerWidth - items[i].getBoundingClientRect().left;
// console.log(this.diff += items[i].offsetWidth/2)
// console.log(items[i].offsetWidth/2)
// console.log(items[i])
console.log(items[i].getBoundingClientRect().left)
this.diff += items[i].offsetWidth/2
slider.style = left: ${this.diff}px;
}
}catch (e) {}
}
for (let i in texts) {
try {
i = parseInt(i)
if (i === mobActive) {
texts[i].classList.add('isactive')
} else {
texts[i].classList.remove('isactive')
}
} catch (e) {
}
}
}
function switchItem(to) {
mobActive = mobActive + to < 0 ? mobActive = items.length - 1 : mobActive + to > items.length - 1 ? 0 : mobActive + to
activeListitem(to)
}
function switchId(id) {
mobActive = id
activeListitem()
}
switchItem(-1)
чел, https://pastebin.com/ или https://jsfiddle.net/ есть
Обсуждают сегодня