-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhover.js
More file actions
37 lines (24 loc) · 815 Bytes
/
hover.js
File metadata and controls
37 lines (24 loc) · 815 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
const slideshow = documentquerySelector("div.slideshow")
const images = slideshow.querySelectorAll("img")
slideshow.addEventListener("mousemove", function(event){
const y =event.offsetY
const height = this.offsetHeight
const percentage = y/height
const imageNumber = Math.floor(percentage * images.length)
images.forEach(image => {
image.style.zIndex = 0
})
images[imageNumber].style.zIndex = 1
});
const slideshow = documentquerySelector("div.slideshow")
const images = slideshow.querySelectorAll("img")
slideshow.addEventListener("touchmove", function(event){
const x =event.offsetX
const width = this.offsetWidth
const percentage = x/width
const imageNumber = Math.floor(percentage * images.length)
images.forEach(image => {
image.style.zIndex = 0
})
images[imageNumber].style.zIndex = 1
});