Copybara bot | be50d49 | 2023-11-30 00:16:42 +0100 | [diff] [blame^] | 1 | <p><strong>Note:</strong> Does not work as expected in IE11</p> |
| 2 | |
| 3 | <style> |
| 4 | .carousel-demo { |
| 5 | box-sizing: border-box; |
| 6 | display: block; |
| 7 | padding: 4px; |
| 8 | border: 1px solid #dddddd; |
| 9 | border-radius: 4px; |
| 10 | box-shadow: 0 2px 2px 0 rgba(0, 0, 0, 0.14), 0 3px 1px -2px rgba(0, 0, 0, 0.2), 0 1px 5px 0 rgba(0, 0, 0, 0.12); |
| 11 | } |
| 12 | |
| 13 | .carousel-demo * { |
| 14 | box-sizing: border-box; |
| 15 | } |
| 16 | |
| 17 | #carousel-imgviewer { |
| 18 | display: -webkit-box; |
| 19 | display: -ms-flexbox; |
| 20 | display: flex; |
| 21 | -webkit-box-pack: center; |
| 22 | -ms-flex-pack: center; |
| 23 | justify-content: center; |
| 24 | } |
| 25 | |
| 26 | #carousel-imgviewer figure { |
| 27 | display: -webkit-box; |
| 28 | display: -ms-flexbox; |
| 29 | display: flex; |
| 30 | -webkit-box-orient: vertical; |
| 31 | -webkit-box-direction: normal; |
| 32 | -ms-flex-direction: column; |
| 33 | flex-direction: column; |
| 34 | -webkit-box-pack: center; |
| 35 | -ms-flex-pack: center; |
| 36 | justify-content: center; |
| 37 | |
| 38 | position: relative; |
| 39 | height: 100%; |
| 40 | padding: 0; |
| 41 | margin: 0; |
| 42 | } |
| 43 | |
| 44 | #carousel-imgviewer figure img { |
| 45 | width: auto; |
| 46 | max-width: 100%; |
| 47 | max-height: 100%; |
| 48 | border: 0; |
| 49 | outline: 0; |
| 50 | |
| 51 | -webkit-animation: fade-in-element 0.25s ease-out; |
| 52 | -moz-animation: fade-in-element 0.25s ease-out; |
| 53 | -o-animation: fade-in-element 025s ease-out; |
| 54 | animation: fade-in-element 0.25s ease-out; |
| 55 | } |
| 56 | |
| 57 | #carousel-footer { |
| 58 | display: -webkit-box; |
| 59 | display: -ms-flexbox; |
| 60 | display: flex; |
| 61 | -webkit-box-pack: justify; |
| 62 | -ms-flex-pack: justify; |
| 63 | justify-content: space-between; |
| 64 | -webkit-box-align: center; |
| 65 | -ms-flex-align: center; |
| 66 | align-items: center; |
| 67 | } |
| 68 | |
| 69 | #carousel-footer .mdl-card__supporting-text { |
| 70 | -webkit-box-flex: 1; |
| 71 | -ms-flex: 1; |
| 72 | flex: 1; |
| 73 | overflow: hidden; |
| 74 | white-space: nowrap; |
| 75 | text-overflow: ellipsis; |
| 76 | padding: 0; |
| 77 | width: 100%; |
| 78 | } |
| 79 | |
| 80 | #carousel-footer nav { |
| 81 | display: -webkit-box; |
| 82 | display: -ms-flexbox; |
| 83 | display: flex; |
| 84 | } |
| 85 | |
| 86 | .carousel-button { |
| 87 | } |
| 88 | .carousel-button__icon { |
| 89 | font-size: 24px; |
| 90 | } |
| 91 | |
| 92 | #carousel-container { |
| 93 | } |
| 94 | |
| 95 | @media (max-width: 479px) { |
| 96 | #carousel-imgviewer { |
| 97 | height: 260px; |
| 98 | } |
| 99 | .carousel-button { |
| 100 | width: 28px; |
| 101 | min-width: 28px; |
| 102 | height: 28px; |
| 103 | } |
| 104 | .carousel-button__icon { |
| 105 | font-size: 20px; |
| 106 | } |
| 107 | #carousel-container { |
| 108 | height: 60px; |
| 109 | margin-top: 4px; |
| 110 | } |
| 111 | } |
| 112 | |
| 113 | @media (min-width: 480px) and (max-width: 839px) { |
| 114 | #carousel-imgviewer { |
| 115 | height: 360px; |
| 116 | } |
| 117 | #carousel-container { |
| 118 | height: 90px; |
| 119 | } |
| 120 | } |
| 121 | |
| 122 | @media (min-width: 840px) { |
| 123 | #carousel-imgviewer { |
| 124 | height: 500px; |
| 125 | } |
| 126 | #carousel-container { |
| 127 | height: 110px; |
| 128 | } |
| 129 | } |
| 130 | |
| 131 | @-webkit-keyframes fade-in-element { |
| 132 | 0% { opacity: 0; } |
| 133 | 100% { opacity: 1; } |
| 134 | } |
| 135 | @-moz-keyframes fade-in-element { |
| 136 | 0% { opacity: 0; } |
| 137 | 100% { opacity: 1; } |
| 138 | } |
| 139 | @-o-keyframes fade-in-element { |
| 140 | 0% { opacity: 0; } |
| 141 | 100% { opacity: 1; } |
| 142 | } |
| 143 | @keyframes fade-in-element { |
| 144 | 0% { opacity: 0; } |
| 145 | 100% { opacity: 1; } |
| 146 | } |
| 147 | |
| 148 | </style> |
| 149 | |
| 150 | <artichle class="carousel-demo" style="height: 64px; margin-bottom: 16px; padding-top: 1px;"> |
| 151 | <ul class="mdlext-carousel mdlext-js-carousel" |
| 152 | data-config="{ 'interactive': false, 'autostart': true, 'type': 'scroll', 'interval': 5000 }"> |
| 153 | |
| 154 | <li class="mdlext-carousel__slide"> |
| 155 | <figure> |
| 156 | <img src="./images/_D802141.jpg" title="Northern goshawk with prey"/> |
| 157 | </figure> |
| 158 | </li> |
| 159 | <li class="mdlext-carousel__slide"> |
| 160 | <figure> |
| 161 | <img src="./images/_D802143.jpg" title="Northern goshawk with prey"/> |
| 162 | </figure> |
| 163 | </li> |
| 164 | <li class="mdlext-carousel__slide"> |
| 165 | <figure> |
| 166 | <img src="./images/_D802591.jpg" title="Whooper swans in flight"/> |
| 167 | </figure> |
| 168 | </li> |
| 169 | <li class="mdlext-carousel__slide"> |
| 170 | <figure> |
| 171 | <img src="./images/_D804370-3.jpg" title="European green woodpecker"/> |
| 172 | </figure> |
| 173 | </li> |
| 174 | <li class="mdlext-carousel__slide"> |
| 175 | <figure> |
| 176 | <img src="./images/_D808689.jpg" title="The bridge"/> |
| 177 | </figure> |
| 178 | </li> |
| 179 | <li class="mdlext-carousel__slide"> |
| 180 | <figure> |
| 181 | <img src="./images/_D802181.jpg" title="Landscape in blue pastel"/> |
| 182 | </figure> |
| 183 | </li> |
| 184 | <li class="mdlext-carousel__slide"> |
| 185 | <figure> |
| 186 | <img src="./images/_D800912.jpg" title="Hiking the mountains of Dovre"/> |
| 187 | </figure> |
| 188 | </li> |
| 189 | <li class="mdlext-carousel__slide"> |
| 190 | <figure> |
| 191 | <img src="./images/_D809453-_D809457-4.jpg" title="The Polar Express. End of Line. Ny Aalesund, Spitsbergen" /> |
| 192 | </figure> |
| 193 | </li> |
| 194 | <li class="mdlext-carousel__slide"> |
| 195 | <figure> |
| 196 | <img src="./images/_DSC8214.jpg" title="Still got the blues"/> |
| 197 | </figure> |
| 198 | </li> |
| 199 | <li class="mdlext-carousel__slide"> |
| 200 | <figure> |
| 201 | <img src="./images/_D800017.jpg" title="Flowers"/> |
| 202 | </figure> |
| 203 | </li> |
| 204 | <li class="mdlext-carousel__slide"> |
| 205 | <figure> |
| 206 | <img src="./images/_D800023.jpg" title="Red-breasted merganser"/> |
| 207 | </figure> |
| 208 | </li> |
| 209 | <li class="mdlext-carousel__slide"> |
| 210 | <figure> |
| 211 | <img src="./images/_D800851.jpg" title="Musk oxes, Dovre, Norway"/> |
| 212 | </figure> |
| 213 | </li> |
| 214 | <li class="mdlext-carousel__slide"> |
| 215 | <figure> |
| 216 | <img src="./images/_D800166.jpg" title="Arctic Fox, Svalbard, Norway" /> |
| 217 | </figure> |
| 218 | </li> |
| 219 | <li class="mdlext-carousel__slide"> |
| 220 | <figure> |
| 221 | <img src="./images/_D800951.jpg" title="Fly fishing the arctic waters, Svalbard, Norway"/> |
| 222 | </figure> |
| 223 | </li> |
| 224 | <li class="mdlext-carousel__slide"> |
| 225 | <figure> |
| 226 | <img src="./images/_D801188.jpg" title="Lady of the snows (Pulsatilla vernalis), Dovre, Norway"/> |
| 227 | </figure> |
| 228 | </li> |
| 229 | <li class="mdlext-carousel__slide"> |
| 230 | <figure> |
| 231 | <img src="./images/_D801205-2.jpg" title="PULSE, Kilden Consert Hall, Kristiansand"/> |
| 232 | </figure> |
| 233 | </li> |
| 234 | <li class="mdlext-carousel__slide"> |
| 235 | <figure> |
| 236 | <img src="./images/_D801274.jpg" title="PULSE, Kilden Consert Hall, Kristiansand"/> |
| 237 | </figure> |
| 238 | </li> |
| 239 | <li class="mdlext-carousel__slide"> |
| 240 | <figure> |
| 241 | <img src="./images/_D801392.jpg" title="Peregrine falcon, Norway"/> |
| 242 | </figure> |
| 243 | </li> |
| 244 | <li class="mdlext-carousel__slide"> |
| 245 | <figure> |
| 246 | <img src="./images/_D801436.jpg" title="Peregrine falcon, Norway"/> |
| 247 | </figure> |
| 248 | </li> |
| 249 | <li class="mdlext-carousel__slide"> |
| 250 | <figure> |
| 251 | <img src="./images/_D801952-4.jpg" title="Mr. Per E Knudsen"/> |
| 252 | </figure> |
| 253 | </li> |
| 254 | <li class="mdlext-carousel__slide"> |
| 255 | <figure> |
| 256 | <img src="./images/_D807603.jpg" title="Black Woodpecker"/> |
| 257 | </figure> |
| 258 | </li> |
| 259 | <li class="mdlext-carousel__slide"> |
| 260 | <figure> |
| 261 | <img src="./images/_D807689.jpg" title="Goshina"/> |
| 262 | </figure> |
| 263 | </li> |
| 264 | <li class="mdlext-carousel__slide"> |
| 265 | <figure> |
| 266 | <img src="./images/_D807558.jpg" title="Goshina"/> |
| 267 | </figure> |
| 268 | </li> |
| 269 | <li class="mdlext-carousel__slide"> |
| 270 | <figure> |
| 271 | <img src="./images/_D800464.jpg" title="Svalbard Rock ptarmigan"/> |
| 272 | </figure> |
| 273 | </li> |
| 274 | <li class="mdlext-carousel__slide"> |
| 275 | <figure> |
| 276 | <img src="./images/_DSC7535.jpg" title="Nice, France"/> |
| 277 | </figure> |
| 278 | </li> |
| 279 | <li class="mdlext-carousel__slide"> |
| 280 | <figure> |
| 281 | <img src="./images/_D802478.jpg" title="Cheetah, Bloemfontain, South Africa"/> |
| 282 | </figure> |
| 283 | </li> |
| 284 | <li class="mdlext-carousel__slide"> |
| 285 | <figure> |
| 286 | <img src="./images/_D800698.jpg" title="Red Squirrel"/> |
| 287 | </figure> |
| 288 | </li> |
| 289 | <li class="mdlext-carousel__slide"> |
| 290 | <figure> |
| 291 | <img src="./images/_D803118.jpg" title="Milky Way, Bloemfontain, South Africa"/> |
| 292 | </figure> |
| 293 | </li> |
| 294 | <li class="mdlext-carousel__slide"> |
| 295 | <figure> |
| 296 | <img src="./images/_D803521.jpg" title="Winter Light, Senja, Norway"/> |
| 297 | </figure> |
| 298 | </li> |
| 299 | <li class="mdlext-carousel__slide"> |
| 300 | <figure> |
| 301 | <img src="./images/_D803465-3.jpg" title="Selfie with Aurora B :)"/> |
| 302 | </figure> |
| 303 | </li> |
| 304 | <li class="mdlext-carousel__slide"> |
| 305 | <figure> |
| 306 | <img src="./images/_D806374.jpg" title="Lista Lighthouse, Norway"/> |
| 307 | </figure> |
| 308 | </li> |
| 309 | <li class="mdlext-carousel__slide"> |
| 310 | <figure> |
| 311 | <img src="./images/_D805345-12.jpg" title="Osprey"/> |
| 312 | </figure> |
| 313 | </li> |
| 314 | </ul> |
| 315 | </artichle> |
| 316 | |
| 317 | |
| 318 | |
| 319 | |
| 320 | <artichle class="carousel-demo"> |
| 321 | |
| 322 | <section id="carousel-imgviewer"> |
| 323 | <figure> |
| 324 | <img src="./images/_D802143-2.jpg" alt="" title=""/> |
| 325 | </figure> |
| 326 | </section> |
| 327 | |
| 328 | <footer id="carousel-footer"> |
| 329 | <div id="carousel-viewer-title" class="mdl-card__supporting-text">Northern goshawk with prey</div> |
| 330 | <nav> |
| 331 | <button id="carousel-btn-first" class="mdl-button mdl-button--icon mdl-js-button carousel-button" title="Scroll First"> |
| 332 | <i class="material-icons carousel-button__icon">first_page</i> |
| 333 | </button> |
| 334 | <button id="carousel-btn-scroll-prev" class="mdl-button mdl-button--icon mdl-js-button carousel-button" title="Scroll Previous"> |
| 335 | <i class="material-icons carousel-button__icon">fast_rewind</i> |
| 336 | </button> |
| 337 | <button id="carousel-btn-prev" class="mdl-button mdl-button--icon mdl-js-button carousel-button" title="Previous"> |
| 338 | <i class="material-icons carousel-button__icon">navigate_before</i> |
| 339 | </button> |
| 340 | <button id="carousel-btn-play-pause" class="mdl-button mdl-button--icon mdl-js-button carousel-button" title="Play"> |
| 341 | <i class="material-icons carousel-button__icon">play_circle_outline</i> |
| 342 | </button> |
| 343 | <button id="carousel-btn-next" class="mdl-button mdl-button--icon mdl-js-button carousel-button" title="Next"> |
| 344 | <i class="material-icons carousel-button__icon">navigate_next</i> |
| 345 | </button> |
| 346 | <button id="carousel-btn-scroll-next" class="mdl-button mdl-button--icon mdl-js-button carousel-button" title="Scroll Next"> |
| 347 | <i class="material-icons carousel-button__icon">fast_forward</i> |
| 348 | </button> |
| 349 | <button id="carousel-btn-last" class="mdl-button mdl-button--icon mdl-js-button carousel-button" title="Scroll Last"> |
| 350 | <i class="material-icons carousel-button__icon">last_page</i> |
| 351 | </button> |
| 352 | </nav> |
| 353 | </footer> |
| 354 | |
| 355 | <section id="carousel-container"> |
| 356 | <ul id="mdlext-carousel-demo2" class="mdlext-carousel mdlext-js-carousel mdl-js-ripple-effect mdl-js-ripple-effect--ignore-events"> |
| 357 | <li class="mdlext-carousel__slide" aria-selected > |
| 358 | <a href="./images/_D802143-2.jpg"> |
| 359 | <figure> |
| 360 | <img src="./images/_D802143.jpg" title="Northern goshawk with prey"/> |
| 361 | <figcaption>_D802143.jpg</figcaption> |
| 362 | </figure> |
| 363 | </a> |
| 364 | </li> |
| 365 | <li class="mdlext-carousel__slide"> |
| 366 | <a href="./images/_D802591-2.jpg"> |
| 367 | <figure> |
| 368 | <img src="./images/_D802591.jpg" title="Whooper swans in flight"/> |
| 369 | <figcaption>_D802591.jpg</figcaption> |
| 370 | </figure> |
| 371 | </a> |
| 372 | </li> |
| 373 | <li class="mdlext-carousel__slide"> |
| 374 | <figure> |
| 375 | <img src="./images/_D802181.jpg" title="Landscape in blue pastel"/> |
| 376 | <figcaption>_D802181.jpg</figcaption> |
| 377 | </figure> |
| 378 | </li> |
| 379 | <li class="mdlext-carousel__slide"> |
| 380 | <a href="./images/_D809453-_D809457-3.jpg"> |
| 381 | <figure> |
| 382 | <img src="./images/_D809453-_D809457-4.jpg" title="The Polar Express. End of Line. Ny Aalesund, Spitsbergen" /> |
| 383 | <figcaption>_D809453</figcaption> |
| 384 | </figure> |
| 385 | </a> |
| 386 | </li> |
| 387 | <li class="mdlext-carousel__slide"> |
| 388 | <a href="./images/_DSC8214-2.jpg"> |
| 389 | <figure> |
| 390 | <img src="./images/_DSC8214.jpg" title="Still got the blues"/> |
| 391 | <figcaption>_DSC8214.jpg</figcaption> |
| 392 | </figure> |
| 393 | </a> |
| 394 | </li> |
| 395 | <li class="mdlext-carousel__slide"> |
| 396 | <a href="./images/_D800166-2.jpg"> |
| 397 | <figure> |
| 398 | <img src="./images/_D800166.jpg" title="Arctic Fox, Svalbard, Norway" /> |
| 399 | <figcaption>_D800166.jpg</figcaption> |
| 400 | </figure> |
| 401 | </a> |
| 402 | </li> |
| 403 | <li class="mdlext-carousel__slide"> |
| 404 | <a href="./images/_D801392-2.jpg"> |
| 405 | <figure> |
| 406 | <img src="./images/_D801392.jpg" title="Peregrine falcon, Norway"/> |
| 407 | <figcaption>_D801392.jpg</figcaption> |
| 408 | </figure> |
| 409 | </a> |
| 410 | </li> |
| 411 | <li class="mdlext-carousel__slide"> |
| 412 | <a href="./images/_D801436-2.jpg"> |
| 413 | <figure> |
| 414 | <img src="./images/_D801436.jpg" title="Peregrine falcon, Norway"/> |
| 415 | <figcaption>_D801436.jpg</figcaption> |
| 416 | </figure> |
| 417 | </a> |
| 418 | </li> |
| 419 | <li class="mdlext-carousel__slide"> |
| 420 | <figure> |
| 421 | <img src="./images/_D807558.jpg" title="Goshina"/> |
| 422 | </figure> |
| 423 | </li> |
| 424 | <li class="mdlext-carousel__slide"> |
| 425 | <a href="./images/_D800464.jpg"> |
| 426 | <figure> |
| 427 | <img src="./images/_D800464.jpg" title="Svalbard Rock ptarmigan"/> |
| 428 | <figcaption>_D800464.jpg</figcaption> |
| 429 | </figure> |
| 430 | </a> |
| 431 | </li> |
| 432 | <li class="mdlext-carousel__slide"> |
| 433 | <a href="./images/_DSC7535-2.jpg"> |
| 434 | <figure> |
| 435 | <img src="./images/_DSC7535.jpg" title="Nice, France"/> |
| 436 | <figcaption>_DSC7535.jpg</figcaption> |
| 437 | </figure> |
| 438 | </a> |
| 439 | </li> |
| 440 | <li class="mdlext-carousel__slide"> |
| 441 | <figure> |
| 442 | <img src="./images/_D802478.jpg" title="Cheetah, Bloemfontain, South Africa"/> |
| 443 | <figcaption>_D802478.jpg</figcaption> |
| 444 | </figure> |
| 445 | </li> |
| 446 | <li class="mdlext-carousel__slide"> |
| 447 | <figure> |
| 448 | <img src="./images/_D800698.jpg" title="Red Squirrel"/> |
| 449 | <figcaption>_D800698.jpg</figcaption> |
| 450 | </figure> |
| 451 | </li> |
| 452 | <li class="mdlext-carousel__slide"> |
| 453 | <figure> |
| 454 | <img src="./images/_D803118.jpg" title="Milky Way, Bloemfontain, South Africa"/> |
| 455 | <figcaption>_D803118.jpg</figcaption> |
| 456 | </figure> |
| 457 | </li> |
| 458 | <li class="mdlext-carousel__slide"> |
| 459 | <figure> |
| 460 | <img src="./images/_D803521.jpg" title="Winter Light, Senja, Norway"/> |
| 461 | <figcaption>_D803521.jpg</figcaption> |
| 462 | </figure> |
| 463 | </li> |
| 464 | <li class="mdlext-carousel__slide"> |
| 465 | <figure> |
| 466 | <img src="./images/_D803465-3.jpg" title="Selfie with Aurora B :)"/> |
| 467 | <figcaption>_D803465.jpg</figcaption> |
| 468 | </figure> |
| 469 | </li> |
| 470 | <li class="mdlext-carousel__slide"> |
| 471 | <figure> |
| 472 | <img src="./images/_D806374.jpg" title="Lista Lighthouse, Norway"/> |
| 473 | <figcaption>_D806374.jpg</figcaption> |
| 474 | </figure> |
| 475 | </li> |
| 476 | <li class="mdlext-carousel__slide"> |
| 477 | <figure> |
| 478 | <img src="./images/_D801087.jpg" title="Brokke, Norway"/> |
| 479 | <figcaption>_D801087.jpg</figcaption> |
| 480 | </figure> |
| 481 | </li> |
| 482 | <li class="mdlext-carousel__slide"> |
| 483 | <figure> |
| 484 | <img src="./images/_D803221.jpg" title="Mnt. Seglan, Senja, Norway"/> |
| 485 | <figcaption>_D803221.jpg</figcaption> |
| 486 | </figure> |
| 487 | </li> |
| 488 | <li class="mdlext-carousel__slide"> |
| 489 | <figure> |
| 490 | <img src="./images/_D803759.jpg" title="Fruit bat, Mauritius"/> |
| 491 | <figcaption>_D803759.jpg</figcaption> |
| 492 | </figure> |
| 493 | </li> |
| 494 | <li class="mdlext-carousel__slide"> |
| 495 | <figure> |
| 496 | <img src="./images/_D809758-2.jpg" title="Polar bear, Svalbard, Norway"/> |
| 497 | <figcaption>_D809758.jpg</figcaption> |
| 498 | </figure> |
| 499 | </li> |
| 500 | <li class="mdlext-carousel__slide"> |
| 501 | <figure> |
| 502 | <img src="./images/_D805345-12.jpg" title="Osprey"/> |
| 503 | <figcaption>_D805345.jpg</figcaption> |
| 504 | </figure> |
| 505 | </li> |
| 506 | </ul> |
| 507 | </section> |
| 508 | </artichle> |
| 509 | |
| 510 | |
| 511 | <div style="margin-top: 8px"> |
| 512 | <button id="btn-add-image" class="mdl-button mdl-js-button mdl-js-ripple-effect mdl-button--raised mdl-button--colored"> |
| 513 | Add image to carousel |
| 514 | </button> |
| 515 | <p class="mdl-typography--caption" style="margin-top: 8px"> |
| 516 | Click the button to add a new image to the carousel. Move to the inserted |
| 517 | image and click it. It should have ripple effect if upgraded correctly. |
| 518 | </p> |
| 519 | </div> |
| 520 | |
| 521 | <p class="mdl-typography--caption" style="margin-top: 32px;"> |
| 522 | All images appearing in this page are the exclusive property of Leif Olsen and are protected under the United States |
| 523 | and International Copyright laws. The images may not be reproduced or manipulated without the written permission of |
| 524 | Leif Olsen. Use of any image as the basis for another photographic concept or illustration (digital, artist rendering |
| 525 | or alike) is a violation of the United States and International Copyright laws. All images are copyrighted © Leif Olsen, 2016. |
| 526 | </p> |
| 527 | |
| 528 | |
| 529 | <script> |
| 530 | (function() { |
| 531 | 'use strict'; |
| 532 | |
| 533 | window.addEventListener('load', function() { |
| 534 | |
| 535 | document.querySelector('#carousel-btn-first').addEventListener('click', function (e) { |
| 536 | var ev = new CustomEvent('command', {detail: {action: 'first'}}); |
| 537 | document.querySelector('#mdlext-carousel-demo2').dispatchEvent(ev); |
| 538 | }); |
| 539 | |
| 540 | document.querySelector('#carousel-btn-scroll-prev').addEventListener('click', function (e) { |
| 541 | var ev = new CustomEvent('command', {detail: {action: 'scroll-prev'}}); |
| 542 | document.querySelector('#mdlext-carousel-demo2').dispatchEvent(ev); |
| 543 | }); |
| 544 | |
| 545 | document.querySelector('#carousel-btn-prev').addEventListener('click', function (e) { |
| 546 | var ev = new CustomEvent('command', {detail: {action: 'prev'}}); |
| 547 | document.querySelector('#mdlext-carousel-demo2').dispatchEvent(ev); |
| 548 | }); |
| 549 | |
| 550 | document.querySelector('#carousel-btn-next').addEventListener('click', function (e) { |
| 551 | var ev = new CustomEvent('command', {detail: {action: 'next'}}); |
| 552 | document.querySelector('#mdlext-carousel-demo2').dispatchEvent(ev); |
| 553 | }); |
| 554 | |
| 555 | document.querySelector('#carousel-btn-scroll-next').addEventListener('click', function (e) { |
| 556 | var ev = new CustomEvent('command', {detail: {action: 'scroll-next'}}); |
| 557 | document.querySelector('#mdlext-carousel-demo2').dispatchEvent(ev); |
| 558 | }); |
| 559 | |
| 560 | document.querySelector('#carousel-btn-last').addEventListener('click', function (e) { |
| 561 | var ev = new CustomEvent('command', {detail: {action: 'last'}}); |
| 562 | document.querySelector('#mdlext-carousel-demo2').dispatchEvent(ev); |
| 563 | }); |
| 564 | |
| 565 | document.querySelector('#carousel-btn-play-pause').addEventListener('click', function (e) { |
| 566 | // Toggle play icon |
| 567 | var i = this.querySelector('i'); |
| 568 | var action = i.innerText === 'play_circle_outline' ? 'play' : 'pause'; |
| 569 | i.textContent = action === 'play' ? 'pause_circle_outline' : 'play_circle_outline'; |
| 570 | |
| 571 | var ev = new CustomEvent('command', {detail: {action: action, interval: 3000}}); |
| 572 | document.querySelector('#mdlext-carousel-demo2').dispatchEvent(ev); |
| 573 | }); |
| 574 | |
| 575 | document.querySelector('#mdlext-carousel-demo2').addEventListener('select', function (e) { |
| 576 | |
| 577 | if ('pause' === e.detail.command) { |
| 578 | // Set play icon |
| 579 | var i = document.querySelector('#carousel-btn-play-pause i'); |
| 580 | i.textContent = 'play_circle_outline'; |
| 581 | } |
| 582 | else { |
| 583 | var oldImage = document.querySelector('#carousel-imgviewer img'); |
| 584 | var selectImage = e.detail.source.querySelector('img'); |
| 585 | var selectImageSrc = selectImage.src; |
| 586 | if (e.detail.source.querySelector('a')) { |
| 587 | selectImageSrc = e.detail.source.querySelector('a').href; |
| 588 | } |
| 589 | |
| 590 | if (selectImageSrc !== oldImage.src) { |
| 591 | var newImage = oldImage.cloneNode(true); |
| 592 | newImage.src = selectImageSrc; |
| 593 | oldImage.parentNode.replaceChild(newImage, oldImage); |
| 594 | |
| 595 | var title = document.querySelector('#carousel-viewer-title'); |
| 596 | title.textContent = selectImage.title; |
| 597 | } |
| 598 | } |
| 599 | }); |
| 600 | |
| 601 | document.querySelector('#btn-add-image').addEventListener('click', function (e) { |
| 602 | var slide_fragment = '<li class="mdlext-carousel__slide"><figure><img src="./images/_D809914-2.jpg" alt="Humpback whale" title="Humpback whale"/></figure></li>'; |
| 603 | var carousel = document.querySelector('#mdlext-carousel-demo2'); |
| 604 | carousel.insertAdjacentHTML('beforeend', slide_fragment); |
| 605 | carousel.MaterialExtCarousel.upgradeSlides(); |
| 606 | }); |
| 607 | |
| 608 | }); |
| 609 | |
| 610 | }()); |
| 611 | |
| 612 | </script> |