Skip to content

Commit

Permalink
Update Loaded
Browse files Browse the repository at this point in the history
  • Loading branch information
rdp77 committed Jul 19, 2023
1 parent 6c6717a commit 1a4871d
Showing 1 changed file with 65 additions and 63 deletions.
128 changes: 65 additions & 63 deletions assets/js/glitche-scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,81 +58,83 @@ new Typed(typedLoadElement, {
});

/* Preloader */
const preloaderInner = document.querySelector(".preloader .pre-inner");
const cursorElement = document.querySelector(".cursor");
cursorElement.style.display = "none";

setTimeout(function () {
fadeOut(preloaderInner, 2000, function() {
/* Preload hide */
let preloader = document.querySelector(".preloader");
preloader.style.display = "none";
document.body.classList.add("loaded");
document.body.style.overflow = "visible";
cursorElement.style.display = "unset";

/* Typed subtitle */
new Typed(".typed-subtitle", {
stringsElement: document.querySelector(".typing-subtitle"),
loop: true,
typeSpeed: 50,
});
document.addEventListener("DOMContentLoaded", function() {
const preloaderInner = document.querySelector(".preloader .pre-inner");
const cursorElement = document.querySelector(".cursor");
cursorElement.style.display = "none";

setTimeout(function () {
fadeOut(preloaderInner, 2000, function() {
/* Preload hide */
let preloader = document.querySelector(".preloader");
preloader.style.display = "none";
document.body.classList.add("loaded");
document.body.style.overflow = "visible";
cursorElement.style.display = "unset";

/* Typed subtitle */
new Typed(".typed-subtitle", {
stringsElement: document.querySelector(".typing-subtitle"),
loop: true,
typeSpeed: 50,
});

/* Typed breadcrumbs */
new Typed(".typed-bread", {
stringsElement: document.querySelector(".typing-bread"),
showCursor: false,
typeSpeed: 50,
});
/* Typed breadcrumbs */
new Typed(".typed-bread", {
stringsElement: document.querySelector(".typing-bread"),
showCursor: false,
typeSpeed: 50,
});

/* One-Page Nav */
let urlHash = window.location.hash;
let sectionElem = document.querySelector(urlHash);
if (urlHash.startsWith("#section-") && sectionElem) {
smoothScrollTo(sectionElem.offsetTop - 70, 400);
}
});
}, 2000);
/* One-Page Nav */
let urlHash = window.location.hash;
let sectionElem = document.querySelector(urlHash);
if (urlHash.startsWith("#section-") && sectionElem) {
smoothScrollTo(sectionElem.offsetTop - 70, 400);
}
});
}, 2000);

function fadeOut(element, duration, callback) {
let opacity = 1;
let startTime = null;
function fadeOut(element, duration, callback) {
let opacity = 1;
let startTime = null;

function fade(currentTime) {
if (!startTime) startTime = currentTime;
const elapsedTime = currentTime - startTime;
opacity = 1 - (elapsedTime / duration);
element.style.opacity = opacity;
function fade(currentTime) {
if (!startTime) startTime = currentTime;
const elapsedTime = currentTime - startTime;
opacity = 1 - (elapsedTime / duration);
element.style.opacity = opacity;

if (opacity <= 0) {
callback();
} else {
requestAnimationFrame(fade);
if (opacity <= 0) {
callback();
} else {
requestAnimationFrame(fade);
}
}
}

requestAnimationFrame(fade);
}
requestAnimationFrame(fade);
}

function smoothScrollTo(targetPosition, duration) {
const startPosition = window.scrollY;
const distance = targetPosition - startPosition;
let startTime = null;
function smoothScrollTo(targetPosition, duration) {
const startPosition = window.scrollY;
const distance = targetPosition - startPosition;
let startTime = null;

function scrollTo(currentTime) {
if (!startTime) startTime = currentTime;
const elapsedTime = currentTime - startTime;
const progress = Math.min(elapsedTime / duration, 1);
const newPosition = startPosition + (distance * progress);
window.scrollTo(0, newPosition);
function scrollTo(currentTime) {
if (!startTime) startTime = currentTime;
const elapsedTime = currentTime - startTime;
const progress = Math.min(elapsedTime / duration, 1);
const newPosition = startPosition + (distance * progress);
window.scrollTo(0, newPosition);

if (progress < 1) {
requestAnimationFrame(scrollTo);
if (progress < 1) {
requestAnimationFrame(scrollTo);
}
}
}

requestAnimationFrame(scrollTo);
}
requestAnimationFrame(scrollTo);
}
});

/*Fade-out animation between load pages*/
document.addEventListener("click", function (event) {
Expand Down

0 comments on commit 1a4871d

Please sign in to comment.