-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
61 lines (54 loc) · 1.56 KB
/
index.html
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Sneaker Slider</title>
<style>
body {
height: 100vh;
margin: 0;
align-items: center;
justify-content: center;
display: flex;
flex-direction: column;
}
input {
width: 768px;
}
</style>
</head>
<body>
<input type="range" min="1" max="36" step="1" value="1" class="slider" id="slider" />
<canvas id="canvas" width="768" height="512"></canvas>
</body>
<script>
const slider = document.querySelector('#slider')
const canvas = document.querySelector('#canvas')
slider.addEventListener('input', handleInputSlider)
const ctx = canvas.getContext('2d')
const images = []
window.addEventListener('load', pageLoaded)
function pageLoaded(){
for(let i=1; i <= 36; i++){
const number = i.toString().padStart(2, '00')
const url = `https://stockx-360.imgix.net/adidas-Yeezy-Boost-350-V2-Yecheil/Images/adidas-Yeezy-Boost-350-V2-Yecheil/Lv2/img${number}.jpg?auto=format,compress&w=559&q=90&dpr=2&updated_at=1574449122`
const image = new Image()
image.src = url
image.addEventListener('load', () => {
images[i] = image
if(i === 1) {
loadImage(i)
}
})
}
}
function loadImage(index){
ctx.drawImage(images[index], 0, 0, canvas.width, canvas.height)
}
function handleInputSlider(){
console.log(this.value)
loadImage(this.value)
}
</script>
</html>