Update 1.js

This commit is contained in:
FURK4NGG
2024-11-03 16:04:41 +03:00
committed by GitHub
parent add7a7ebef
commit f78bf55e54
+6 -39
View File
@@ -16,6 +16,7 @@ function switchPhoto() {
// Initially set the first image as visible // Initially set the first image as visible
images[currentIndex].classList.add('visible'); images[currentIndex].classList.add('visible');
/*SCROLL REVEALING*/ /*SCROLL REVEALING*/
document.addEventListener('DOMContentLoaded', () => { document.addEventListener('DOMContentLoaded', () => {
const textContainer = document.getElementById('animatedTextContainer'); const textContainer = document.getElementById('animatedTextContainer');
@@ -87,6 +88,7 @@ document.addEventListener("DOMContentLoaded", function() {
} }
}); });
/*SAVE DATA AND RUN OFFLINE*/ /*SAVE DATA AND RUN OFFLINE*/
if ('serviceWorker' in navigator) { if ('serviceWorker' in navigator) {
window.addEventListener('load', () => { window.addEventListener('load', () => {
@@ -100,6 +102,7 @@ if ('serviceWorker' in navigator) {
}); });
} }
/*TO-TOP BUTTON REVEALING*/ /*TO-TOP BUTTON REVEALING*/
const toTop = document.querySelector(".to-top"); const toTop = document.querySelector(".to-top");
const trandingSlideContent = document.querySelector(".tranding-slide-content"); const trandingSlideContent = document.querySelector(".tranding-slide-content");
@@ -129,6 +132,7 @@ window.addEventListener('load', function() {
if (sidebarCheckbox.checked) {sidebarCheckbox.checked = false;} if (sidebarCheckbox.checked) {sidebarCheckbox.checked = false;}
}); });
/*LOADING SCREEN*/ /*LOADING SCREEN*/
gsap.fromTo( gsap.fromTo(
".loading_page", ".loading_page",
@@ -171,44 +175,6 @@ const options = {
autoMatchOsTheme: true // default: true autoMatchOsTheme: true // default: true
} }
const darkmode = new Darkmode(options);
// Sayfa yüklendiğinde ilk temayı belirle
window.addEventListener('DOMContentLoaded', () => {
// Kayıtlı bir tema tercihi var mı?
const savedTheme = localStorage.getItem('theme');
// Eğer kayıtlı tema yoksa, sistem temasına göre otomatik ayarla
if (!savedTheme) {
const prefersDarkScheme = window.matchMedia("(prefers-color-scheme: dark)").matches;
if (prefersDarkScheme) {
darkmode.toggle(); // Dark mode'u etkinleştir
localStorage.setItem('theme', 'dark');
} else {
localStorage.setItem('theme', 'light');
}
} else if (savedTheme === 'dark') {
darkmode.toggle(); // Kayıtlı tema dark ise dark mode etkin
}
});
// Tema değiştirme fonksiyonu
function toggleTheme() {
const currentTheme = localStorage.getItem('theme');
// Dark mode aktifse light mode'a geç
if (currentTheme === 'dark') {
darkmode.toggle(); // Dark mode'u kapat
localStorage.setItem('theme', 'light');
} else {
darkmode.toggle(); // Dark mode'u etkinleştir
localStorage.setItem('theme', 'dark');
}
}
// Toggle butonunu dinleyiciye bağla
document.querySelector('.darkmode-toggle').addEventListener('click', toggleTheme);
/*GALLERY IMAGES*/ /*GALLERY IMAGES*/
var TrandingSlider = new Swiper('.tranding-slider', { var TrandingSlider = new Swiper('.tranding-slider', {
@@ -259,6 +225,7 @@ document.addEventListener("DOMContentLoaded", function() {
}); });
}); });
/*ANIMATED TEXT*/ /*ANIMATED TEXT*/
const dynamicText = document.querySelector(".h1 span"); const dynamicText = document.querySelector(".h1 span");
const words = ["Developer", "Athlete", "Musician"]; const words = ["Developer", "Athlete", "Musician"];
@@ -373,7 +340,7 @@ function animateCircles() {
animateCircles(); animateCircles();
/*Disable copy-paste*/ /*DISABLE COPY-PASTE*/
const disabledKeys = ["c", "C", "x", "J", "u", "I"]; // keys that will be disabled const disabledKeys = ["c", "C", "x", "J", "u", "I"]; // keys that will be disabled
const showAlert = e => { const showAlert = e => {
e.preventDefault(); // preventing its default behaviour e.preventDefault(); // preventing its default behaviour