Skip to content

Commit

Permalink
refactor: loader and slide handling
Browse files Browse the repository at this point in the history
  • Loading branch information
dewanakl committed Mar 1, 2025
1 parent eb4b7a9 commit 66e5f16
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
4 changes: 3 additions & 1 deletion js/app/component/pagination.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { util } from '../../common/util.js';

export const pagination = (() => {

let perPage = 10;
Expand Down Expand Up @@ -88,7 +90,7 @@ export const pagination = (() => {
const buttonAction = (button) => {
button.disabled = true;
const tmp = button.innerHTML;
button.innerHTML = `<span class="spinner-border spinner-border-sm my-0 mx-1 p-0" style="height: 0.8rem; width: 0.8rem;"></span>`;
button.innerHTML = util.loader.replace('ms-0 me-1', 'mx-1');

const process = async () => {
const result = new Promise((res) => comment.addEventListener('comment.result', res));
Expand Down
4 changes: 2 additions & 2 deletions js/app/guest/guest.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,15 +188,15 @@ export const guest = (() => {
}
});

async function nextSlide() {
const nextSlide = async () => {
await util.changeOpacity(slides[currentIndex], false);
slides[currentIndex].classList.remove("slide-desktop-active");

currentIndex = (currentIndex + 1) % slides.length;

slides[currentIndex].classList.add("slide-desktop-active");
await util.changeOpacity(slides[currentIndex], true);
}
};

setInterval(nextSlide, 5000);
};
Expand Down
3 changes: 2 additions & 1 deletion js/common/util.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export const util = (() => {

const loader = '<span class="spinner-border spinner-border-sm my-0 ms-0 me-1 p-0" style="height: 0.8rem; width: 0.8rem"></span>';
const loader = '<span class="spinner-border spinner-border-sm my-0 ms-0 me-1 p-0" style="height: 0.8rem; width: 0.8rem;"></span>';

/**
* @param {string} unsafe
Expand Down Expand Up @@ -202,6 +202,7 @@ export const util = (() => {
};

return {
loader,
copy,
timeOut,
debounce,
Expand Down

0 comments on commit 66e5f16

Please sign in to comment.