Skip to content

Commit

Permalink
Merge pull request #18 from vickkie/Pair
Browse files Browse the repository at this point in the history
Selector
  • Loading branch information
vickkie authored Mar 24, 2024
2 parents ca86371 + 3ad1abc commit 8991021
Showing 1 changed file with 31 additions and 28 deletions.
59 changes: 31 additions & 28 deletions js/main.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
let select = (e) => document.querySelector(e);
let selectAll = (e) => document.querySelectorAll(e);

// Group 0: service worker
// main.js
if ("serviceWorker" in navigator) {
Expand All @@ -14,7 +17,7 @@ if ("serviceWorker" in navigator) {
//Group 1; code to update time
document.addEventListener("DOMContentLoaded", function () {
setTimeout(() => {
let time = document.querySelector(".time");
let time = select(".time");
function updateTime() {
var date = new Date();
time.innerHTML = date.toTimeString().substr(0, 5);
Expand All @@ -25,10 +28,10 @@ document.addEventListener("DOMContentLoaded", function () {
}, 1000);

//Group 2; code to open menu
let openMenu = document.querySelector(".button-menu");
let closeMenu = document.querySelector(".button-close");
let menuholders = document.querySelectorAll(".menu-will-open");
let myCursor = document.querySelector(".mf-cursor");
let openMenu = select(".button-menu");
let closeMenu = select(".button-close");
let menuholders = selectAll(".menu-will-open");
let myCursor = select(".mf-cursor");

menuholders.forEach((body) => {
openMenu.addEventListener("click", () => {
Expand Down Expand Up @@ -108,7 +111,7 @@ document.addEventListener("DOMContentLoaded", function () {
return afterPseudo;
}

document.querySelectorAll("[line-triggerX]").forEach(function (element) {
selectAll("[line-triggerX]").forEach(function (element) {
const lineTrigger = element.getAttribute("line-triggerX");

const linetimeline = lineTimeline(element);
Expand Down Expand Up @@ -147,7 +150,7 @@ document.addEventListener("DOMContentLoaded", function () {
return afterPseudoY;
}

document.querySelectorAll("[line-triggerY]").forEach(function (element) {
selectAll("[line-triggerY]").forEach(function (element) {
const lineyTrigger = element.getAttribute("line-triggerY");

const lineytimeline = lineyTimeline(element);
Expand Down Expand Up @@ -192,7 +195,7 @@ document.addEventListener("DOMContentLoaded", function () {

// Group 6 : folding of text from opaCITY AnimaTION

const fx28Titles = [...document.querySelectorAll("[data-splitting][data-effect28]")];
const fx28Titles = [...selectAll("[data-splitting][data-effect28]")];

if (fx28Titles) {
gsap.registerPlugin(ScrollTrigger);
Expand Down Expand Up @@ -266,8 +269,8 @@ document.addEventListener("DOMContentLoaded", function () {

//Group 7; code to change image on menu clicking

let menGallery = document.querySelector(".menu-gallery"),
workMenu = document.querySelector(".menu-work"),
let menGallery = select(".menu-gallery"),
workMenu = select(".menu-work"),
gallerypics = menGallery.querySelectorAll(".gallery__item-imginner");

const changeWorkMenu = () => {
Expand Down Expand Up @@ -334,11 +337,11 @@ document.addEventListener("DOMContentLoaded", function () {

//Group 8; code to toggle dark-light modes

let toggleButton = document.querySelector(".knob");
let togglePath = document.querySelector(".dark-toggle");
let root = document.querySelector("body");
let toggleButton = select(".knob");
let togglePath = select(".dark-toggle");
let root = select("body");

let xCursor = document.querySelector(".mf-cursor");
let xCursor = select(".mf-cursor");

let on = false;

Expand All @@ -351,7 +354,7 @@ document.addEventListener("DOMContentLoaded", function () {
duration: 0.4,
ease: "expo.in",
});
let heylinkers = document.querySelectorAll(".portfolio-map a");
let heylinkers = selectAll(".portfolio-map a");
heylinkers.forEach((heylinker) => {
gsap.set(heylinker, {
color: on ? "#fff" : "#000",
Expand All @@ -373,10 +376,10 @@ document.addEventListener("DOMContentLoaded", function () {
let cursor = new MouseFollower();
}

if (document.querySelector(".mf-cursor")) {
if (select(".mf-cursor")) {
function hideMf() {
if (innerWidth < 768) {
document.querySelector(".mf-cursor").style.display = "none";
select(".mf-cursor").style.display = "none";
}
}

Expand All @@ -386,7 +389,7 @@ document.addEventListener("DOMContentLoaded", function () {

// Group 10: Magnetic effect for elements with class .viewall

const els = document.querySelectorAll(".magnetic");
const els = selectAll(".magnetic");

els.forEach((el) => {
el.addEventListener("mouseenter", () => {
Expand All @@ -411,10 +414,10 @@ document.addEventListener("DOMContentLoaded", function () {

gsap.registerPlugin(ScrollToPlugin);

let toContact = document.querySelector(".tocontact"),
toworks = document.querySelector(".toworks"),
tohero = document.querySelector(".tohero"),
toabout = document.querySelector(".toabout");
let toContact = select(".tocontact"),
toworks = select(".toworks"),
tohero = select(".tohero"),
toabout = select(".toabout");

toContact.addEventListener("click", () => {
gsap.to(window, {
Expand Down Expand Up @@ -450,8 +453,8 @@ document.addEventListener("DOMContentLoaded", function () {

// Group 12: turn scrollers to white

let linkers = document.querySelectorAll(".portfolio-map a");
let body = document.querySelector("body");
let linkers = selectAll(".portfolio-map a");
let body = select("body");
let colordefault = getComputedStyle(body).backgroundColor;
let colorbackup = getComputedStyle(body).color;

Expand Down Expand Up @@ -517,7 +520,7 @@ function copyToClipboard(text) {
if (innerWidth > 767 && document.hasFocus()) {
navigator.clipboard.writeText(text);

let copies = document.querySelectorAll(".copy");
let copies = selectAll(".copy");

copies.forEach((copy) => {
copy.innerHTML = "Copied";
Expand All @@ -533,7 +536,7 @@ function copyToClipboard(text) {
const text3d = () => {
if (innerWidth > 767) {
gsap.registerPlugin(ScrollTrigger);
const fx19Titles = [...document.querySelectorAll("[data-splitting][data-effect19]")];
const fx19Titles = [...selectAll("[data-splitting][data-effect19]")];

fx19Titles.forEach((title) => {
const chars = title.querySelectorAll(".char");
Expand Down Expand Up @@ -607,7 +610,7 @@ if (innerWidth > 767) {

//Group 15: lets rotate some i's in the footer

let chars = [...document.querySelectorAll(".rotate-i .char")];
let chars = [...selectAll(".rotate-i .char")];

// Here we're creating a timeline that we can use
const lettertl = gsap.timeline({
Expand All @@ -622,7 +625,7 @@ lettertl.to(chars[11], { rotation: 360 });

//use the defaults

let emailbox = document.querySelector(".email-box");
let emailbox = select(".email-box");

// Group 13: darkmode if user browser prefers

Expand Down

0 comments on commit 8991021

Please sign in to comment.