|
29 | 29 |
|
30 | 30 |
|
31 | 31 |
|
| 32 | + |
| 33 | + |
32 | 34 | .container { |
33 | 35 | position: relative; |
34 | 36 | display: flex; |
|
69 | 71 |
|
70 | 72 | .v2 { |
71 | 73 | clip-path: polygon(-15% 0%, 0% 0%, -10% 100%, -25% 100%); |
72 | | - animation-name: v2LeftToRight; |
73 | | - animation-duration: 3s; |
74 | | - animation-timing-function: ease-in; |
75 | | - animation-iteration-count: infinite; |
76 | 74 | } |
77 | 75 |
|
78 | 76 |
|
| 77 | + |
| 78 | + |
79 | 79 | video { |
80 | 80 | width: 100%; |
81 | 81 | height: 100%; |
|
103 | 103 | height: 100%; |
104 | 104 | background: linear-gradient(-80deg, rgba(0, 0, 0, 0) 25%, rgba(0, 0, 0, 1) 35%, rgba(0, 0, 0, 1) 65%, rgba(0, 0, 0, 0) 75%); |
105 | 105 | transform: scaleX(1.1); |
106 | | - animation-name: v2ShadowLeftToRight; |
107 | | - animation-duration: 3s; |
108 | | - animation-timing-function: ease-in; |
109 | | - animation-iteration-count: infinite; |
110 | 106 | } |
111 | 107 |
|
112 | 108 | .l2 { |
113 | 109 | position: absolute; |
114 | 110 | width: 100%; |
115 | 111 | height: 100%; |
116 | | - transition: opacity .5s ease; |
117 | 112 | } |
118 | 113 |
|
119 | | - .hide { |
120 | | - opacity: 0; |
| 114 | + |
| 115 | + .v2.playing { |
| 116 | + animation-name: v2LeftToRight; |
| 117 | + animation-duration: 3s; |
| 118 | + animation-timing-function: ease-in; |
| 119 | + animation-iteration-count: infinite; |
| 120 | + } |
| 121 | + |
| 122 | + .v2-shadow.playing { |
| 123 | + animation-name: v2ShadowLeftToRight; |
| 124 | + animation-duration: 3s; |
| 125 | + animation-timing-function: ease-in; |
| 126 | + animation-iteration-count: infinite; |
121 | 127 | } |
122 | 128 | </style> |
123 | 129 | </head> |
124 | 130 |
|
125 | 131 | <body> |
126 | 132 | <div class="container"> |
127 | 133 | <div class="v1"> |
128 | | - <video muted autoplay class="l1"> |
| 134 | + <video muted class="l1"> |
129 | 135 | <source src="./assets/effects-video/frxxz-p1.mp4"> |
130 | | - </video> |
131 | | - <video muted class="l2 hide"> |
132 | 136 | <source src="./assets/effects-video/frxxz-p2.mp4"> |
133 | 137 | </video> |
134 | 138 | </div> |
135 | | - <div class="v2-shadow"></div> |
136 | | - <div class="v2"> |
137 | | - <video muted autoplay class="l1"> |
| 139 | + <div class="v2-shadow playing"></div> |
| 140 | + <div class="v2 playing"> |
| 141 | + <video muted class="l1"> |
138 | 142 | <source src="./assets/effects-video/frxxz-p1.mp4"> |
139 | | - </video> |
140 | | - <video muted class="l2 hide"> |
141 | 143 | <source src="./assets/effects-video/frxxz-p2.mp4"> |
142 | 144 | </video> |
143 | 145 | </div> |
144 | 146 | </div> |
145 | 147 |
|
146 | 148 | <script type="module"> |
147 | | - let v1VideoDOM = document.querySelectorAll('.v1 video') |
148 | | - let v2VideoDOM = document.querySelectorAll('.v2 video') |
| 149 | + let v2DOM = document.querySelector(".v2") |
149 | 150 | let v2ShadowDOM = document.querySelector(".v2-shadow") |
150 | | - v1VideoDOM.item(0).addEventListener("ended", () => { |
151 | | - v1VideoDOM.item(1).classList.remove('hide') |
152 | | - v1VideoDOM.item(1).play() |
153 | | - }) |
154 | | - v2VideoDOM.item(0).addEventListener("ended", () => { |
155 | | - v2VideoDOM.item(1).classList.remove('hide') |
156 | | - v2VideoDOM.item(1).play() |
157 | | - }) |
158 | | - |
159 | | - v1VideoDOM.item(1).addEventListener("ended", () => { |
160 | | - v1VideoDOM.item(1).classList.add('hide') |
161 | | - v1VideoDOM.item(0).play() |
162 | | - }) |
163 | | - v2VideoDOM.item(1).addEventListener("ended", () => { |
164 | | - v2VideoDOM.item(1).classList.add('hide') |
165 | | - v2VideoDOM.item(0).play() |
166 | | - }) |
167 | 151 |
|
| 152 | + let videosDOM = document.querySelectorAll('video') |
| 153 | + let videoMainDOM = videosDOM.item(0); |
| 154 | + let videoSubDOM = videosDOM.item(1) |
| 155 | + |
| 156 | + let sources = videoMainDOM.querySelectorAll('source') |
| 157 | + let currentPlayIndex = 0; |
| 158 | + function playNextVideo() { |
| 159 | + currentPlayIndex++; |
| 160 | + videoMainDOM.src = videoSubDOM.src = sources[currentPlayIndex % sources.length].src |
| 161 | + videoMainDOM.play() |
| 162 | + videoSubDOM.play() |
| 163 | + } |
| 164 | + videoMainDOM.addEventListener('ended', playNextVideo) |
| 165 | + videoMainDOM.play(); |
| 166 | + videoSubDOM.play() |
168 | 167 |
|
169 | 168 | function updateV2Shadow() { |
170 | 169 | const opposite = document.body.clientWidth * .1; |
|
0 commit comments