Created
October 11, 2021 17:34
-
-
Save alanef/3a5d174345d4265906c60cafade87361 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <head> | |
| <style> | |
| .vfx-slideshow { | |
| position: relative; | |
| } | |
| .vfx-slideshow > div:not(:first-child) { | |
| display:none; | |
| } | |
| .vfx-slideshow > div { | |
| position: absolute; | |
| top: 0; | |
| left: 0; | |
| right: 0; | |
| bottom: 0; | |
| } | |
| </style> | |
| </head> | |
| <?php | |
| //hmtl / PHP | |
| ?> | |
| <div class="vfx-wrap"> | |
| <div class="vfx-slides"> | |
| <div class="vfx-slideshow <?php echo $slide_class; ?>" | |
| <?php echo $slide_control; ?> | |
| > | |
| <?php | |
| // loop images | |
| foreach ( $img_urls as $id => $img_url ) { | |
| ?> | |
| <div> | |
| <img src="<?php echo $img_url; ?> alt=""> | |
| </div> | |
| <?php | |
| } | |
| ?> | |
| </div> | |
| </div> | |
| </div> | |
| <?php | |
| // jquery | |
| ?> | |
| <script> | |
| (function ($) { | |
| $(function () { | |
| if (vfx_count > 1) { // only when more than one slide | |
| if (vfx_speed > 0) { // auto rotate | |
| var counter = 0; | |
| var DELAY = vfx_speed; | |
| var old_timestamp = Date.now(); | |
| function rotate(timestamp) { | |
| if (timestamp > old_timestamp + DELAY) { | |
| // HAVE WE WAITED LONG ENOUGH? | |
| counter++; | |
| old_timestamp = timestamp; | |
| $('.vfx-slideshow > div:first') | |
| .fadeOut(100) | |
| .next() | |
| .fadeIn(100) | |
| .end() | |
| .appendTo('.vfx-slideshow'); | |
| } | |
| } | |
| setInterval(function () { | |
| rotate(Date.now()); | |
| }, 100); | |
| } | |
| // speed is zero so no rotate | |
| $(".hero__slide-click").on("click", function () { | |
| old_timestamp = Date.now(); | |
| $('.vfx-slideshow > div:first') | |
| .fadeOut(100) | |
| .next() | |
| .fadeIn(100) | |
| .end() | |
| .appendTo('.vfx-slideshow'); | |
| }); | |
| } | |
| }); | |
| })(jQuery); | |
| </script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment