From 631194bb7a2136a114352900c1b976a49889ff6b Mon Sep 17 00:00:00 2001 From: BenjaminToby <52448020+BenjaminToby@users.noreply.github.com> Date: Wed, 9 Jun 2021 12:39:27 +0100 Subject: [PATCH] add intro animations and interactions --- scripts/v3.js | 139 ++++++++++++++++++++++++++++++++++++++++++++++---- v3.css | 23 ++++++++- v3.html | 6 +-- 3 files changed, 153 insertions(+), 15 deletions(-) diff --git a/scripts/v3.js b/scripts/v3.js index c713544..f097c10 100644 --- a/scripts/v3.js +++ b/scripts/v3.js @@ -11,6 +11,8 @@ const myBigTextBlock = document.querySelector(".benjamin-big-text-block"); const mainTextBlock = document.querySelector(".main-text-block"); const mainCTA = document.querySelector(".main-cta-button"); const allHeaderElements = document.querySelectorAll("header *"); +const mountains = document.querySelectorAll("#mountains"); +const clouds = document.querySelectorAll("#clouds"); function intro() { @@ -18,10 +20,10 @@ function intro() { anime({ targets: heroTextSection, width: [0, "50%"], - opacity: [0, 1], - easing: "cubicBezier(0, 0.72, 0.355, 1)", - duration: 800, - delay: 1400, + translateX: [200, 0], + easing: "cubicBezier( 0.93, 0, 0.09, 1 )", + duration: 1500, + delay: 1000, }); anime({ @@ -57,8 +59,8 @@ function intro() { translateX: [-50, 0], opacity: [0, 1], easing: "cubicBezier( 0.1, 0.63, 0.355, 1 )", - duration: 800, - delay: 2800, + duration: 1200, + delay: 2500, }); anime({ @@ -66,13 +68,84 @@ function intro() { translateX: [-50, 0], opacity: [0, 1], easing: "cubicBezier( 0.1, 0.63, 0.355, 1 )", - duration: 800, - delay: 2900, + duration: 1200, + delay: 2600, + }); + + anime({ + targets: mountains, + translateY: [200, 0], + opacity: [0, 1], + easing: "cubicBezier(0.1, 0.63, 0.355, 1)", + duration: 1500, + delay: 1000, + }); + + anime({ + targets: clouds, + opacity: [0.2, 1], + easing: "easeOutQuad", + duration: 1200, + delay: 800, }); } -intro(); +// Intro Initialization + +function introInit() { + + anime({ + targets: heroTextSection, + width: [0], + translateX: 200, + duration: 0 + }); + + anime({ + targets: allHeaderElements, + translateX: [-20], + opacity: [0], + duration: 0 + }); + + anime({ + targets: myBigTextBlock, + translateY: [100], + opacity: [0], + duration: 0 + }); + + anime({ + targets: myImageBlock, + translateY: [100], + opacity: [0], + duration: 0 + }); + + anime({ + targets: mainTextBlock, + translateX: [-50], + opacity: [0], + duration: 0 + }); + + anime({ + targets: mainCTA, + translateX: [-50], + opacity: [0], + duration: 0 + }); + + anime({ + targets: mountains, + opacity: 0, + duration: 0 + }); + +} + +introInit(); @@ -127,9 +200,55 @@ function changeHeader(entry) { } } + + + +//############################################# -- Window Load + setTimeout(() => { headerObserver.observe(headerController); -}, 2000); +}, 3000); + + +window.addEventListener("load", () => { + setTimeout(() => {intro();}, 1000); + +}); + + + + + + + +//############################################# -- Secitons intersection Observer + +const sections = document.querySelectorAll("section"); +var sectionContainer = document.querySelector("#samp-div"); + +var windowRect2 = { + rootMargin: "0px", +}; + +var sectionsIntersectionObserver = new IntersectionObserver(sectionsObserverFn, windowRect); + +function sectionsObserverFn(entries) { + if(entries[1].isInersecting) { + anime({ + targets: sectionContainer, + width: [0, 500], + delay: 1000, + }); + } +} + + + +sections.forEach(entry => { + sectionsIntersectionObserver.observe(entry); +}); + + diff --git a/v3.css b/v3.css index 8a01bda..a7df8a1 100644 --- a/v3.css +++ b/v3.css @@ -167,7 +167,7 @@ a { border: none; cursor: pointer; font-size: inherit; -/* transition: all .3s ease-out;*/ + transition: all .3s ease-out; } a:hover { @@ -247,7 +247,7 @@ button { padding: 10px 20px; color: white; cursor: pointer; -/* transition: all .2s ease-out; */ + transition: all .2s ease-out; background-image: linear-gradient(var(--main-color),var(--main-color)); background-repeat: no-repeat; background-position: 0px 67px; @@ -376,6 +376,7 @@ input:focus { min-height: 100vh; left: 0px; top: 0px; + opacity: 0.2; } #mountains { @@ -430,6 +431,24 @@ input:focus { +/*############################################################# -- My Work -- */ + +.my-work-section { + +} + +.my-work-section > div:nth-child(2) { + background-color: var(--sec-color-1); +} + + + + + + + + + diff --git a/v3.html b/v3.html index ea5ec14..0fdd409 100644 --- a/v3.html +++ b/v3.html @@ -89,13 +89,13 @@ - + -
+
-
+