mirror of
https://github.com/Sped0n/bridget.git
synced 2026-04-18 20:19:30 -07:00
add tailing image array
now data status is replaced by the class oriented design
This commit is contained in:
@@ -68,11 +68,18 @@ const activate = (image, x, y) => {
|
|||||||
image.style.top = `${y}px`
|
image.style.top = `${y}px`
|
||||||
image.style.zIndex = '' + globalIndex
|
image.style.zIndex = '' + globalIndex
|
||||||
|
|
||||||
image.dataset.status = 'active'
|
// activate image
|
||||||
|
image.classList.remove('inactive')
|
||||||
|
image.classList.add('active')
|
||||||
|
// set top image
|
||||||
image.classList.add('top')
|
image.classList.add('top')
|
||||||
image.addEventListener('click', () => {
|
image.addEventListener('click', () => {
|
||||||
image.style.left = '50%'
|
image.style.left = '50%'
|
||||||
image.style.top = '50%'
|
image.style.top = '50%'
|
||||||
|
const activeImages = document.getElementsByClassName('active')
|
||||||
|
for (let i = 0; i <= 3; i++) {
|
||||||
|
activeImages.item(i).classList.add(`trailingImage${4 - i}`)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
last = { x, y }
|
last = { x, y }
|
||||||
@@ -94,7 +101,10 @@ const handleOnMove = e => {
|
|||||||
activate(lead, e.clientX, e.clientY)
|
activate(lead, e.clientX, e.clientY)
|
||||||
numSpan((imageIndex + 1), featuredPicNum)
|
numSpan((imageIndex + 1), featuredPicNum)
|
||||||
// hide the image unused
|
// hide the image unused
|
||||||
if (tail) tail.dataset.status = 'inactive'
|
if (tail) {
|
||||||
|
tail.classList.remove('active')
|
||||||
|
tail.classList.add('inactive')
|
||||||
|
}
|
||||||
// self increment
|
// self increment
|
||||||
globalIndex++
|
globalIndex++
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user