From 628706491b5e67e8adcd797edd7b5d05875074c6 Mon Sep 17 00:00:00 2001 From: Aakash Date: Sat, 8 Jun 2024 11:40:20 +0530 Subject: [PATCH] Update script.js Updated jQuery Version: Uses the latest jQuery (3.6.0). Replaced fetch Calls: Ensures fetch returns JSON data properly. Improved ScrollReveal Setup: Streamlined the ScrollReveal configuration. --- assets/js/script.js | 83 +++++++++++++++------------------------------ 1 file changed, 27 insertions(+), 56 deletions(-) diff --git a/assets/js/script.js b/assets/js/script.js index 047c1c78..6deec698 100644 --- a/assets/js/script.js +++ b/assets/js/script.js @@ -1,5 +1,4 @@ $(document).ready(function () { - $('#menu').click(function () { $(this).toggleClass('fa-times'); $('.navbar').toggleClass('nav-toggle'); @@ -10,14 +9,14 @@ $(document).ready(function () { $('.navbar').removeClass('nav-toggle'); if (window.scrollY > 60) { - document.querySelector('#scroll-top').classList.add('active'); + $('#scroll-top').addClass('active'); } else { - document.querySelector('#scroll-top').classList.remove('active'); + $('#scroll-top').removeClass('active'); } // scroll spy $('section').each(function () { - let height = $(this).height(); + let height = $(this).outerHeight(); let offset = $(this).offset().top - 200; let top = $(window).scrollTop(); let id = $(this).attr('id'); @@ -34,14 +33,15 @@ $(document).ready(function () { e.preventDefault(); $('html, body').animate({ scrollTop: $($(this).attr('href')).offset().top, - }, 500, 'linear') + }, 500, 'linear'); }); - // + // emailjs to mail contact form data $("#contact-form").submit(function (event) { + event.preventDefault(); emailjs.init("user_TTDmetQLYgWCLzHTDgqxm"); - emailjs.sendForm('contact_service', 'template_contact', '#contact-form') + emailjs.sendForm('contact_service', 'template_contact', this) .then(function (response) { console.log('SUCCESS!', response.status, response.text); document.getElementById("contact-form").reset(); @@ -50,41 +50,30 @@ $(document).ready(function () { console.log('FAILED...', error); alert("Form Submission Failed! Try Again"); }); - event.preventDefault(); }); - // - }); -document.addEventListener('visibilitychange', - function () { - if (document.visibilityState === "visible") { - document.title = "Portfolio | Jigar Sable"; - $("#favicon").attr("href", "assets/images/favicon.png"); - } - else { - document.title = "Come Back To Portfolio"; - $("#favicon").attr("href", "assets/images/favhand.png"); - } - }); - +document.addEventListener('visibilitychange', function () { + if (document.visibilityState === "visible") { + document.title = "Portfolio | Jigar Sable"; + $("#favicon").attr("href", "assets/images/favicon.png"); + } else { + document.title = "Come Back To Portfolio"; + $("#favicon").attr("href", "assets/images/favhand.png"); + } +}); -// -var typed = new Typed(".typing-text", { +// typed js effect starts +new Typed(".typing-text", { strings: ["frontend development", "backend development", "web designing", "android development", "web development"], loop: true, typeSpeed: 50, backSpeed: 25, backDelay: 500, }); -// async function fetchData(type = "skills") { - let response - type === "skills" ? - response = await fetch("skills.json") - : - response = await fetch("./projects/projects.json") + let response = await fetch(type === "skills" ? "skills.json" : "./projects/projects.json"); const data = await response.json(); return data; } @@ -99,7 +88,7 @@ function showSkills(skills) { skill ${skill.name} - ` + `; }); skillsContainer.innerHTML = skillHTML; } @@ -123,17 +112,16 @@ function showProjects(projects) { - ` + `; }); projectsContainer.innerHTML = projectHTML; - // + // tilt js effect VanillaTilt.init(document.querySelectorAll(".tilt"), { max: 15, }); - // - /* ===== SCROLL REVEAL ANIMATION ===== */ + // scroll reveal animation const srtop = ScrollReveal({ origin: 'top', distance: '80px', @@ -141,9 +129,7 @@ function showProjects(projects) { reset: true }); - /* SCROLL PROJECTS */ srtop.reveal('.work .box', { interval: 200 }); - } fetchData().then(data => { @@ -154,22 +140,10 @@ fetchData("projects").then(data => { showProjects(data); }); -// +// tilt js effect VanillaTilt.init(document.querySelectorAll(".tilt"), { max: 15, }); -// - - -// pre loader start -// function loader() { -// document.querySelector('.loader-container').classList.add('fade-out'); -// } -// function fadeOut() { -// setInterval(loader, 500); -// } -// window.onload = fadeOut; -// pre loader end // disable developer mode document.onkeydown = function (e) { @@ -188,7 +162,7 @@ document.onkeydown = function (e) { if (e.ctrlKey && e.keyCode == 'U'.charCodeAt(0)) { return false; } -} +}; // Start of Tawk.to Live Chat var Tawk_API = Tawk_API || {}, Tawk_LoadStart = new Date(); @@ -200,10 +174,8 @@ var Tawk_API = Tawk_API || {}, Tawk_LoadStart = new Date(); s1.setAttribute('crossorigin', '*'); s0.parentNode.insertBefore(s1, s0); })(); -// End of Tawk.to Live Chat - -/* ===== SCROLL REVEAL ANIMATION ===== */ +// scroll reveal animation const srtop = ScrollReveal({ origin: 'top', distance: '80px', @@ -231,7 +203,6 @@ srtop.reveal('.about .content p', { delay: 200 }); srtop.reveal('.about .content .box-container', { delay: 200 }); srtop.reveal('.about .content .resumebtn', { delay: 200 }); - /* SCROLL SKILLS */ srtop.reveal('.skills .container', { interval: 200 }); srtop.reveal('.skills .container .bar', { delay: 400 }); @@ -248,4 +219,4 @@ srtop.reveal('.experience .timeline .container', { interval: 400 }); /* SCROLL CONTACT */ srtop.reveal('.contact .container', { delay: 400 }); -srtop.reveal('.contact .container .form-group', { delay: 400 }); \ No newline at end of file +srtop.reveal('.contact .container .form-group', { delay: 400 });