Skip to content

Commit

Permalink
setTimeOut removed while loading
Browse files Browse the repository at this point in the history
  • Loading branch information
mervekaraman committed Oct 27, 2023
1 parent c60e250 commit f43e93f
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 8 deletions.
13 changes: 10 additions & 3 deletions resources/views/components/loading/absolute.blade.php
@@ -1,10 +1,17 @@
<div
x-data="{ }"
x-init="document.querySelector('[data-modal-handle]') ? document.querySelectorAll('[data-modal-handle]').forEach((item) => { item.classList.add('invisible') }) : null, setTimeout(() => $refs.loadingAbsoluteContent.remove(), 1000), setTimeout(() => document.querySelector('[data-modal-handle]') ? document.querySelectorAll('[data-modal-handle]').forEach((item) => { item.classList.remove('invisible') }) : null , 1010)"
x-data="{ loaded: false }"
x-init="() => {
const loadEvent = 'onpagehide' in window ? 'pageshow' : 'load';
window.addEventListener(loadEvent, () => {
loaded = true;
$refs.loadingAbsoluteContent.remove();
document.querySelectorAll('[data-modal-handle]').forEach(item => item.classList.remove('invisible'));
});
}"
x-ref="loadingAbsoluteContent"
class="absolute w-full lg:flex items-start justify-center bg-body top-0 bottom-0 left-0 right-0 z-50"
style="z-index: 60;"
>
<img src="{{ asset('public/img/akaunting-loading.gif') }}" class="w-28 h-28" alt="Akaunting" />
<img src="{{ asset('public/img/akaunting-loading.gif') }}" class="w-40 h-40" alt="Akaunting" />
</div>
<!--data attr added because for none vue.js pages-->
14 changes: 11 additions & 3 deletions resources/views/components/loading/content.blade.php
@@ -1,10 +1,18 @@
<div
x-data="{ }"
x-init="document.querySelector('[data-modal-handle]') ? document.querySelectorAll('[data-modal-handle]').forEach((item) => { item.classList.add('invisible') }) : null, setTimeout(() => $refs.loadingContent.remove(), 1000), setTimeout(() => document.querySelector('[data-modal-handle]') ? document.querySelectorAll('[data-modal-handle]').forEach((item) => { item.classList.remove('invisible') }) : null , 1010)"
x-data="{ loaded: false }"
x-init="() => {
const loadEvent = 'onpagehide' in window ? 'pageshow' : 'load';
window.addEventListener(loadEvent, () => {
loaded = true;
$refs.loadingContent.remove();
document.querySelectorAll('[data-modal-handle]').forEach(item => item.classList.remove('invisible'));
});
}"
x-ref="loadingContent"
class="fixed w-full lg:w-4/5 h-screen flex items-center justify-center bg-body top-0 bottom-0 ltr:right-0 rtl:left-0 -mx-1 z-50"
style="z-index: 60;"
>
<img src="{{ asset('public/img/akaunting-loading.gif') }}" class="w-28 h-28 lg:-mt-16" alt="Akaunting" />
<img src="{{ asset('public/img/akaunting-loading.gif') }}" class="w-40 h-40 lg:-mt-16" alt="Akaunting" />
</div>
<!--data attr added because for none vue.js pages-->

7 changes: 5 additions & 2 deletions resources/views/components/loading/menu.blade.php
@@ -1,6 +1,9 @@
<div
x-data="{ }"
x-init="setTimeout(() => $refs.loadingMenu.remove(), 1000)"
x-data="{ loaded: false }"
x-init="window.addEventListener('load', () => {
loaded = true;
$refs.loadingMenu.remove();
})"
x-ref="loadingMenu"
class="w-70 h-screen hidden lg:flex fixed top-0 js-menu z-20 transition-all ltr:-left-80 rtl:-right-80 xl:ltr:left-0 xl:rtl:right-0"
>
Expand Down

0 comments on commit f43e93f

Please sign in to comment.