| 1 | <!doctype html> |
| 2 | <html lang="en"> |
| 3 | <head> |
| 4 | <meta charset="utf-8"> |
| 5 | <meta name="viewport" content="width=device-width, initial-scale=1"> |
| 6 | <link href="../../../dist/css/bootstrap.min.css" rel="stylesheet"> |
| 7 | <title>Carousel</title> |
| 8 | <style> |
| 9 | .carousel-item { |
| 10 | transition: transform 2s ease, opacity .5s ease; |
| 11 | } |
| 12 | </style> |
| 13 | </head> |
| 14 | <body> |
| 15 | <div class="container"> |
| 16 | <h1>Carousel <small>Bootstrap Visual Test</small></h1> |
| 17 | |
| 18 | <p>The transition duration should be around 2s. Also, the carousel shouldn't slide when its window/tab is hidden. Check the console log.</p> |
| 19 | |
| 20 | <div id="carousel-example-generic" class="carousel slide" data-bs-ride="carousel"> |
| 21 | <div class="carousel-indicators"> |
| 22 | <button type="button" data-bs-target="#carousel-example-generic" data-bs-slide-to="0" class="active" aria-current="true" aria-label="Slide 1"></button> |
| 23 | <button type="button" data-bs-target="#carousel-example-generic" data-bs-slide-to="1" aria-label="Slide 2"></button> |
| 24 | <button type="button" data-bs-target="#carousel-example-generic" data-bs-slide-to="2" aria-label="Slide 3"></button> |
| 25 | </div> |
| 26 | <div class="carousel-inner"> |
| 27 | <div class="carousel-item active"> |
| 28 | <img src="https://i.imgur.com/iEZgY7Y.jpg" alt="First slide"> |
| 29 | </div> |
| 30 | <div class="carousel-item"> |
| 31 | <img src="https://i.imgur.com/eNWn1Xs.jpg" alt="Second slide"> |
| 32 | </div> |
| 33 | <div class="carousel-item"> |
| 34 | <img src="https://i.imgur.com/Nm7xoti.jpg" alt="Third slide"> |
| 35 | </div> |
| 36 | </div> |
| 37 | <button class="carousel-control-prev" data-bs-target="#carousel-example-generic" type="button" data-bs-slide="prev"> |
| 38 | <span class="carousel-control-prev-icon" aria-hidden="true"></span> |
| 39 | <span class="visually-hidden">Previous</span> |
| 40 | </button> |
| 41 | <button class="carousel-control-next" data-bs-target="#carousel-example-generic" type="button" data-bs-slide="next"> |
| 42 | <span class="carousel-control-next-icon" aria-hidden="true"></span> |
| 43 | <span class="visually-hidden">Next</span> |
| 44 | </button> |
| 45 | </div> |
| 46 | </div> |
| 47 | |
| 48 | <script src="../../../dist/js/bootstrap.bundle.js"></script> |
| 49 | <script> |
| 50 | let t0 |
| 51 | let t1 |
| 52 | const carousel = document.getElementById('carousel-example-generic') |
| 53 | |
| 54 | // Test to show that the carousel doesn't slide when the current tab isn't visible |
| 55 | // Test to show that transition-duration can be changed with css |
| 56 | carousel.addEventListener('slid.bs.carousel', event => { |
| 57 | t1 = performance.now() |
| 58 | console.log(`transition-duration took ${t1 - t0}ms, slid at ${event.timeStamp}`) |
| 59 | }) |
| 60 | carousel.addEventListener('slide.bs.carousel', () => { |
| 61 | t0 = performance.now() |
| 62 | }) |
| 63 | </script> |
| 64 | </body> |
| 65 | </html> |