-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
251 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
{ | ||
"extends": ["@finsweet"], | ||
"rules": { | ||
"no-console": "off" | ||
"no-console": "off", | ||
"simple-import-sort/imports": "off" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
const CURSOR_OUTER_SELECTOR = '.page-cursor.is-outer'; | ||
const CURSOR_INNER_SELECTOR = '.page-cursor.is-inner'; | ||
|
||
let scaleAnim: gsap.core.Timeline; | ||
let outerX: gsap.QuickToFunc; | ||
let outerY: gsap.QuickToFunc; | ||
let InnerX: gsap.QuickToFunc; | ||
let innerY: gsap.QuickToFunc; | ||
|
||
export function cursorInit() { | ||
if (window.innerWidth < 992) { | ||
return; | ||
} | ||
|
||
window.gsap.set(CURSOR_INNER_SELECTOR, { scale: 0.3 }); | ||
window.gsap.set(`${CURSOR_OUTER_SELECTOR}, ${CURSOR_INNER_SELECTOR}`, { opacity: 1 }); | ||
|
||
document.addEventListener('mousemove', cursorMove); | ||
|
||
outerX = window.gsap.quickTo(CURSOR_OUTER_SELECTOR, 'left', { | ||
duration: 0.2, | ||
ease: 'power3', | ||
}); | ||
outerY = window.gsap.quickTo(CURSOR_OUTER_SELECTOR, 'top', { | ||
duration: 0.2, | ||
ease: 'power3', | ||
}); | ||
|
||
InnerX = window.gsap.quickTo(CURSOR_INNER_SELECTOR, 'left', { | ||
duration: 0.6, | ||
ease: 'power3', | ||
}); | ||
innerY = window.gsap.quickTo(CURSOR_INNER_SELECTOR, 'top', { | ||
duration: 0.6, | ||
ease: 'power3', | ||
}); | ||
|
||
setScaleAnimations(); | ||
setLinksInteraction(); | ||
} | ||
|
||
function setScaleAnimations() { | ||
scaleAnim = window.gsap.timeline({ paused: true }); | ||
|
||
scaleAnim.to( | ||
CURSOR_OUTER_SELECTOR, | ||
{ | ||
scale: 0.4, | ||
duration: 0.35, | ||
}, | ||
0 | ||
); | ||
scaleAnim.to( | ||
CURSOR_INNER_SELECTOR, | ||
{ | ||
opacity: 0, | ||
duration: 0.35, | ||
}, | ||
0 | ||
); | ||
} | ||
|
||
function cursorMove(mouseEv: MouseEvent) { | ||
const cursorPosition = { | ||
left: mouseEv.clientX, | ||
top: mouseEv.clientY, | ||
}; | ||
|
||
outerX(cursorPosition.left); | ||
outerY(cursorPosition.top); | ||
InnerX(cursorPosition.left); | ||
innerY(cursorPosition.top); | ||
} | ||
|
||
function setLinksInteraction() { | ||
const TARGET_SELECTORS_LIST = | ||
'a, [data-cursor-link], .button.is-form-submit, .process_slider_pagination-bullet'; | ||
|
||
document.addEventListener( | ||
'mouseenter', | ||
(e: MouseEvent) => { | ||
const target = e.target as HTMLElement; | ||
const isTargetMatch = target.matches(TARGET_SELECTORS_LIST); | ||
if (!isTargetMatch) { | ||
return; | ||
} | ||
|
||
window.DEBUG('link hover - cursor scale play'); | ||
scaleAnim.play(); | ||
|
||
target.addEventListener( | ||
'mouseleave', | ||
(e) => { | ||
window.DEBUG('link hover - cursor scale reverse'); | ||
scaleAnim.reverse(); | ||
}, | ||
{ once: true } | ||
); | ||
}, | ||
true | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
import 'fslightbox'; | ||
import { SCRIPTS_LOADED_EVENT } from 'src/constants'; | ||
|
||
const PROJECTS_LIST_SELECTOR = '[data-projects-list]'; | ||
const PROJECT_ITEM_SELECTOR = '.projects_item-link-wrapper'; | ||
const LIGHTBOX_WRAPPER_SELECTOR = '[data-lightbox-wrapper]'; | ||
const LIGHTBOX_CONTENT_WRAPPER_SELECTOR = '[data-lightbox-content-wrapper]'; | ||
const LIGHTBOX_CLOSE_BTN_ATTRIBUTE = 'data-lightbox-close'; | ||
|
||
let lightboxWrapperEl: HTMLElement | null; | ||
let projectsListEl: HTMLElement | null; | ||
let projectItemsList: NodeListOf<HTMLElement>; | ||
|
||
window.addEventListener(SCRIPTS_LOADED_EVENT, () => { | ||
lightboxWrapperEl = document.querySelector(LIGHTBOX_WRAPPER_SELECTOR); | ||
projectsListEl = document.querySelector(PROJECTS_LIST_SELECTOR); | ||
projectItemsList = document.querySelectorAll(PROJECT_ITEM_SELECTOR); | ||
|
||
if (!lightboxWrapperEl || !projectsListEl || !projectItemsList.length) { | ||
window.DEBUG( | ||
'One of these elements not found on page - Lightbox wrapper, Projects List, or any Project items.', | ||
'Looking for', | ||
{ LIGHTBOX_WRAPPER_SELECTOR, PROJECTS_LIST_SELECTOR, PROJECT_ITEM_SELECTOR }, | ||
{ lightboxWrapperEl, projectsListEl, projectItemsList } | ||
); | ||
return; | ||
} | ||
|
||
initLightbox(); | ||
onProjectsItemLoad(); | ||
refreshLightbox(); | ||
}); | ||
|
||
/** | ||
* On loading new projects via CMS Load | ||
*/ | ||
window.fsAttributes = window.fsAttributes || []; | ||
window.fsAttributes.push([ | ||
'cmsload', | ||
(listInstances) => { | ||
const [listInstance] = listInstances; | ||
|
||
listInstance.on('renderitems', (renderedItems: NodeListOf<HTMLElement>) => { | ||
projectItemsList = renderedItems; | ||
|
||
onProjectsItemLoad(); | ||
}); | ||
}, | ||
]); | ||
|
||
function onProjectsItemLoad() { | ||
document.querySelectorAll(`${PROJECT_ITEM_SELECTOR}[data-slug]`).forEach((item) => { | ||
initHTMX(item); | ||
}); | ||
} | ||
|
||
/** | ||
* Sets `hx-get` attribute on the project list items, dynamically joining the slug | ||
*/ | ||
function initHTMX(item: HTMLElement) { | ||
const slug = item.getAttribute('data-slug'); | ||
const currentGetPath = item.getAttribute('hx-get') || '/projects/'; | ||
item.setAttribute('hx-get', currentGetPath + slug); | ||
|
||
item.removeAttribute('data-slug'); | ||
|
||
htmx.process(item); | ||
} | ||
|
||
function initLightbox() { | ||
window.gsap.set(lightboxWrapperEl, { opacity: 0 }); | ||
|
||
const lightboxContentWrapperEl = lightboxWrapperEl?.querySelector( | ||
LIGHTBOX_CONTENT_WRAPPER_SELECTOR | ||
); | ||
|
||
// open | ||
projectsListEl?.addEventListener('click', (clickEv) => { | ||
const target = clickEv.target as HTMLElement; | ||
if (!target.closest(PROJECT_ITEM_SELECTOR)) { | ||
return; | ||
} | ||
|
||
window.gsap.set(lightboxWrapperEl, { display: 'block' }); | ||
window.gsap.set('body', { overflow: 'hidden' }); | ||
window.gsap.to(lightboxWrapperEl, { opacity: 1, duration: 0.3 }); | ||
}); | ||
|
||
// close | ||
lightboxWrapperEl?.addEventListener('click', (clickEv) => { | ||
const target = clickEv.target as HTMLElement; | ||
if (!target.closest(`[${LIGHTBOX_CLOSE_BTN_ATTRIBUTE}]`)) { | ||
return; | ||
} | ||
|
||
window.gsap.to(lightboxWrapperEl, { | ||
opacity: 0, | ||
duration: 0.3, | ||
onComplete: () => { | ||
window.gsap.set(lightboxWrapperEl, { display: 'none' }); | ||
window.gsap.set('body', { overflow: 'auto' }); | ||
|
||
if (lightboxContentWrapperEl) { | ||
lightboxContentWrapperEl.innerHTML = ''; | ||
} | ||
}, | ||
}); | ||
}); | ||
} | ||
|
||
function refreshLightbox() { | ||
htmx.onLoad(function (content) { | ||
window.DEBUG('htmx content loaded', content); | ||
refreshFsLightbox(); | ||
}); | ||
} | ||
|
||
export {}; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const SCRIPTS_LOADED_EVENT = 'scriptsLoaded'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
import { homeHeroImageReveal } from 'src/components/home-hero-image-reveal'; | ||
import { initProcessSlider } from 'src/components/home-process-slider'; | ||
import 'src/components/home-projects-gallery'; | ||
import { SCRIPTS_LOADED_EVENT } from 'src/constants'; | ||
|
||
window.Webflow?.push(() => { | ||
window.addEventListener(SCRIPTS_LOADED_EVENT, () => { | ||
homeHeroImageReveal(); | ||
initProcessSlider(); | ||
}); |