Created
October 13, 2022 17:11
-
-
Save xiCO2k/9d51d2c34093bb863fbd7c448ca19ecf to your computer and use it in GitHub Desktop.
Infinite Image fadeIn fadeOut
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
<div | |
class="relative pointer-events-none" | |
x-data="{ active: 0 }" | |
x-init="setInterval(() => | |
active = ++active > $el.childElementCount - 1 ? 0 : active | |
, 3000)" | |
> | |
@foreach([ | |
'hero-pic1.webp', | |
'hero-pic2.webp', | |
'hero-pic3.webp', | |
'hero-pic4.webp', | |
] as $index => $image) | |
<div | |
class="absolute h-full w-full bg-cover" | |
style="background-image: url({{ Vite::asset("resources/img/{$image}") }})" | |
x-show="active === {{ $index }}" | |
x-transition.opacity.duration.500ms | |
></div> | |
@endforeach | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment