-
Notifications
You must be signed in to change notification settings - Fork 0
/
05-out-of-box.html
71 lines (71 loc) · 1.58 KB
/
05-out-of-box.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
62
63
64
65
66
67
68
69
70
71
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
.container {
display: flex;
justify-content: space-between;
}
.box {
width: 150px;
height: 200px;
border-radius: 20px;
margin: 16px;
background-color: skyblue;
display: flex;
justify-content: center;
align-items: center;
overflow: hidden;
/* view-transition-name: spot; */
}
.spot {
width: 10px;
height: 10px;
border-radius: 50%;
background-color: orangered;
view-transition-name: spot;
}
.spot.huge {
width: 100px;
height: 100px;
display: none;
}
</style>
</head>
<body>
<button onclick="changeDOM()">CHANGE DOM</button>
<div class="container">
<div class="box left">
<div class="spot mini"></div>
</div>
<div class="box right">
<div class="spot huge"></div>
</div>
</div>
<script>
let isMini = true
const changeDOM = () => {
if (!document.startViewTransition) {
transfer()
return
}
document.startViewTransition(() => transfer());
}
const transfer = () => {
const mini = document.querySelector('.mini')
const huge = document.querySelector('.huge')
if (isMini) {
mini.style.display = 'none'
huge.style.display = 'block'
} else {
huge.style.display = 'none'
mini.style.display = 'block'
}
isMini = !isMini
}
</script>
</body>
</html>