thema de comienzo con efectos
This commit is contained in:
@@ -0,0 +1,111 @@
|
||||
/* Animated background from trivelta: drifting orbs, particle canvas, grain. */
|
||||
|
||||
.ambient-bg {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
z-index: 0;
|
||||
overflow: hidden;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
body > header,
|
||||
body > main,
|
||||
body > footer {
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.ambient-bg__canvas {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
z-index: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
opacity: 0.55;
|
||||
}
|
||||
|
||||
.ambient-bg__orbs {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
z-index: 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.ambient-bg__orb {
|
||||
position: absolute;
|
||||
border-radius: 50%;
|
||||
filter: blur(100px);
|
||||
}
|
||||
|
||||
.ambient-bg__orb--a {
|
||||
top: -260px;
|
||||
left: -180px;
|
||||
width: 680px;
|
||||
height: 680px;
|
||||
background: radial-gradient(circle, #0a4fd1, transparent 70%);
|
||||
opacity: 0.55;
|
||||
animation: ambient-drift-1 22s ease-in-out infinite;
|
||||
}
|
||||
|
||||
.ambient-bg__orb--b {
|
||||
top: 30%;
|
||||
right: -240px;
|
||||
width: 600px;
|
||||
height: 600px;
|
||||
background: radial-gradient(circle, #1f7ae5, transparent 70%);
|
||||
opacity: 0.34;
|
||||
animation: ambient-drift-2 26s ease-in-out infinite;
|
||||
}
|
||||
|
||||
.ambient-bg__orb--c {
|
||||
bottom: -220px;
|
||||
left: 34%;
|
||||
width: 560px;
|
||||
height: 560px;
|
||||
background: radial-gradient(circle, #4fb8ff, transparent 70%);
|
||||
opacity: 0.22;
|
||||
animation: ambient-drift-3 30s ease-in-out infinite;
|
||||
}
|
||||
|
||||
.ambient-bg__grain {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
z-index: 1;
|
||||
opacity: 0.04;
|
||||
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
|
||||
}
|
||||
|
||||
@keyframes ambient-drift-1 {
|
||||
0%,
|
||||
100% { transform: translate(0, 0); }
|
||||
50% { transform: translate(80px, 60px); }
|
||||
}
|
||||
|
||||
@keyframes ambient-drift-2 {
|
||||
0%,
|
||||
100% { transform: translate(0, 0); }
|
||||
50% { transform: translate(-90px, 40px); }
|
||||
}
|
||||
|
||||
@keyframes ambient-drift-3 {
|
||||
0%,
|
||||
100% { transform: translate(0, 0); }
|
||||
50% { transform: translate(60px, -70px); }
|
||||
}
|
||||
|
||||
@media (max-width: 880px) {
|
||||
.ambient-bg__canvas,
|
||||
.ambient-bg__orbs {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.ambient-bg__orb {
|
||||
animation: none;
|
||||
}
|
||||
|
||||
.ambient-bg__canvas {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
/* Animated background from trivelta: aurora orbs plus a particle constellation. */
|
||||
(function () {
|
||||
var reduceMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
|
||||
|
||||
var root = document.createElement('div');
|
||||
root.className = 'ambient-bg';
|
||||
root.setAttribute('aria-hidden', 'true');
|
||||
root.innerHTML = '<canvas class="ambient-bg__canvas"></canvas>'
|
||||
+ '<div class="ambient-bg__orbs">'
|
||||
+ '<div class="ambient-bg__orb ambient-bg__orb--a"></div>'
|
||||
+ '<div class="ambient-bg__orb ambient-bg__orb--b"></div>'
|
||||
+ '<div class="ambient-bg__orb ambient-bg__orb--c"></div>'
|
||||
+ '</div>'
|
||||
+ '<div class="ambient-bg__grain"></div>';
|
||||
document.body.insertBefore(root, document.body.firstChild);
|
||||
|
||||
var canvas = root.querySelector('.ambient-bg__canvas');
|
||||
|
||||
if (reduceMotion || window.innerWidth < 900) {
|
||||
canvas.remove();
|
||||
return;
|
||||
}
|
||||
|
||||
var ctx = canvas.getContext('2d');
|
||||
var width = 0;
|
||||
var height = 0;
|
||||
var dpr = 1;
|
||||
var points = [];
|
||||
|
||||
function resize() {
|
||||
dpr = Math.min(window.devicePixelRatio || 1, 2);
|
||||
width = canvas.width = window.innerWidth * dpr;
|
||||
height = canvas.height = window.innerHeight * dpr;
|
||||
canvas.style.width = window.innerWidth + 'px';
|
||||
canvas.style.height = window.innerHeight + 'px';
|
||||
|
||||
var count = Math.min(70, Math.floor(window.innerWidth / 22));
|
||||
points = [];
|
||||
|
||||
for (var i = 0; i < count; i++) {
|
||||
points.push({
|
||||
x: Math.random() * width,
|
||||
y: Math.random() * height,
|
||||
vx: (Math.random() - 0.5) * 0.12 * dpr,
|
||||
vy: (Math.random() - 0.5) * 0.12 * dpr
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function loop() {
|
||||
ctx.clearRect(0, 0, width, height);
|
||||
|
||||
for (var i = 0; i < points.length; i++) {
|
||||
var point = points[i];
|
||||
point.x += point.vx;
|
||||
point.y += point.vy;
|
||||
if (point.x < 0 || point.x > width) point.vx *= -1;
|
||||
if (point.y < 0 || point.y > height) point.vy *= -1;
|
||||
}
|
||||
|
||||
for (var a = 0; a < points.length; a++) {
|
||||
for (var b = a + 1; b < points.length; b++) {
|
||||
var dx = points[a].x - points[b].x;
|
||||
var dy = points[a].y - points[b].y;
|
||||
var distance = Math.hypot(dx, dy);
|
||||
var maxDistance = 150 * dpr;
|
||||
|
||||
if (distance < maxDistance) {
|
||||
ctx.strokeStyle = 'rgba(79, 184, 255, ' + (0.16 * (1 - distance / maxDistance)) + ')';
|
||||
ctx.lineWidth = dpr;
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(points[a].x, points[a].y);
|
||||
ctx.lineTo(points[b].x, points[b].y);
|
||||
ctx.stroke();
|
||||
}
|
||||
}
|
||||
|
||||
ctx.fillStyle = 'rgba(120, 170, 255, 0.5)';
|
||||
ctx.beginPath();
|
||||
ctx.arc(points[a].x, points[a].y, 1.4 * dpr, 0, Math.PI * 2);
|
||||
ctx.fill();
|
||||
}
|
||||
|
||||
window.requestAnimationFrame(loop);
|
||||
}
|
||||
|
||||
resize();
|
||||
window.addEventListener('resize', resize);
|
||||
window.requestAnimationFrame(loop);
|
||||
}());
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
/**
|
||||
* Animated background from trivelta.
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
function alcastromol_animated_background_assets() {
|
||||
$dir = get_template_directory() . '/parts/animated-background';
|
||||
$uri = get_template_directory_uri() . '/parts/animated-background';
|
||||
|
||||
wp_enqueue_style(
|
||||
'alcastromol-animated-background',
|
||||
$uri . '/animated-background.css',
|
||||
array(),
|
||||
filemtime( $dir . '/animated-background.css' )
|
||||
);
|
||||
|
||||
wp_enqueue_script(
|
||||
'alcastromol-animated-background',
|
||||
$uri . '/animated-background.js',
|
||||
array(),
|
||||
filemtime( $dir . '/animated-background.js' ),
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
add_action( 'wp_enqueue_scripts', 'alcastromol_animated_background_assets' );
|
||||
@@ -0,0 +1,19 @@
|
||||
/* Full-viewport fluid trail. Clicks pass through to the page. */
|
||||
|
||||
.fluid-cursor {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
z-index: 2;
|
||||
width: 100vw;
|
||||
height: 100vh;
|
||||
overflow: hidden;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.fluid-cursor canvas {
|
||||
display: block;
|
||||
width: 100vw;
|
||||
height: 100vh;
|
||||
pointer-events: none;
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
/**
|
||||
* Fluid cursor from Cursify.
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
function alcastromol_fluid_cursor_assets() {
|
||||
$dir = get_template_directory() . '/parts/fluid-cursor';
|
||||
$uri = get_template_directory_uri() . '/parts/fluid-cursor';
|
||||
|
||||
wp_enqueue_style(
|
||||
'alcastromol-fluid-cursor',
|
||||
$uri . '/fluid-cursor.css',
|
||||
array(),
|
||||
filemtime( $dir . '/fluid-cursor.css' )
|
||||
);
|
||||
|
||||
wp_enqueue_script(
|
||||
'alcastromol-fluid-cursor',
|
||||
$uri . '/fluid-cursor.js',
|
||||
array(),
|
||||
filemtime( $dir . '/fluid-cursor.js' ),
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
add_action( 'wp_enqueue_scripts', 'alcastromol_fluid_cursor_assets' );
|
||||
@@ -0,0 +1,55 @@
|
||||
/* Enter starts hidden and transitions in after the first paint.
|
||||
A CSS animation would finish during head scripts (Tailwind CDN) before anything is visible. */
|
||||
|
||||
body {
|
||||
opacity: 0;
|
||||
transform: translateY(30px) scale(0.99);
|
||||
filter: blur(7px);
|
||||
transition:
|
||||
opacity 0.7s cubic-bezier(0.2, 0.7, 0.2, 1),
|
||||
transform 0.7s cubic-bezier(0.2, 0.7, 0.2, 1),
|
||||
filter 0.7s cubic-bezier(0.2, 0.7, 0.2, 1);
|
||||
}
|
||||
|
||||
body.is-entered {
|
||||
opacity: 1;
|
||||
transform: none;
|
||||
filter: none;
|
||||
}
|
||||
|
||||
body.is-leaving {
|
||||
opacity: 0;
|
||||
transform: translateY(-22px) scale(0.985);
|
||||
filter: blur(5px);
|
||||
transition:
|
||||
opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1),
|
||||
transform 0.4s cubic-bezier(0.4, 0, 0.2, 1),
|
||||
filter 0.4s;
|
||||
}
|
||||
|
||||
@media (max-width: 880px) {
|
||||
body {
|
||||
transform: translateY(16px);
|
||||
filter: none;
|
||||
}
|
||||
|
||||
body.is-leaving {
|
||||
filter: none;
|
||||
}
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
body {
|
||||
opacity: 1;
|
||||
transform: none;
|
||||
filter: none;
|
||||
transition: none;
|
||||
}
|
||||
|
||||
body.is-leaving {
|
||||
opacity: 1;
|
||||
transform: none;
|
||||
filter: none;
|
||||
transition: none;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
/* Cinematic page transition (from trivelta-html).
|
||||
WordPress prints internal links as absolute URLs, so same-origin navigations
|
||||
are included. External, in-page, admin, and modified clicks are left alone. */
|
||||
(function () {
|
||||
var reduceMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
|
||||
var leaveMs = 360;
|
||||
|
||||
function playEnter() {
|
||||
if (reduceMotion) {
|
||||
document.body.classList.add('is-entered');
|
||||
return;
|
||||
}
|
||||
|
||||
requestAnimationFrame(function () {
|
||||
requestAnimationFrame(function () {
|
||||
document.body.classList.add('is-entered');
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
if (/(?:^|[?&])(ct_builder|oxygen_iframe|ct_inner)=/.test(window.location.search)) {
|
||||
document.body.classList.add('is-entered');
|
||||
return;
|
||||
}
|
||||
|
||||
playEnter();
|
||||
|
||||
function shouldSkip(anchor, event) {
|
||||
if (!anchor) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (event.defaultPrevented || event.button) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ((anchor.target && anchor.target !== '_self') || anchor.hasAttribute('download')) {
|
||||
return true;
|
||||
}
|
||||
|
||||
var href = anchor.getAttribute('href');
|
||||
|
||||
if (!href || href.charAt(0) === '#' || /^(mailto:|tel:|javascript:)/i.test(href)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
var url;
|
||||
|
||||
try {
|
||||
url = new URL(anchor.href, window.location.href);
|
||||
} catch (error) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (url.origin !== window.location.origin) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (url.pathname.indexOf('/wp-admin') !== -1 || /\/wp-(login|comments-post)\.php$/.test(url.pathname)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (/\.(pdf|zip|rar|7z|docx?|xlsx?|pptx?|jpe?g|png|gif|webp|svg|mp[34]|wav)(\?|$)/i.test(url.pathname)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (url.pathname === window.location.pathname && url.search === window.location.search) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function go(url) {
|
||||
if (document.body.classList.contains('is-leaving')) {
|
||||
return;
|
||||
}
|
||||
|
||||
document.body.classList.add('is-leaving');
|
||||
window.setTimeout(function () {
|
||||
window.location.href = url;
|
||||
}, reduceMotion ? 0 : leaveMs);
|
||||
}
|
||||
|
||||
document.addEventListener('click', function (event) {
|
||||
var anchor = event.target.closest ? event.target.closest('a') : null;
|
||||
|
||||
if (shouldSkip(anchor, event)) {
|
||||
return;
|
||||
}
|
||||
|
||||
event.preventDefault();
|
||||
go(anchor.href);
|
||||
});
|
||||
|
||||
window.addEventListener('pageshow', function () {
|
||||
document.body.classList.remove('is-leaving');
|
||||
});
|
||||
}());
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/**
|
||||
* Cinematic page transition.
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
function alcastromol_page_transition_assets() {
|
||||
$dir = get_template_directory() . '/parts/page-transition';
|
||||
$uri = get_template_directory_uri() . '/parts/page-transition';
|
||||
|
||||
wp_enqueue_style(
|
||||
'alcastromol-page-transition',
|
||||
$uri . '/page-transition.css',
|
||||
array(),
|
||||
filemtime( $dir . '/page-transition.css' )
|
||||
);
|
||||
|
||||
wp_enqueue_script(
|
||||
'alcastromol-page-transition',
|
||||
$uri . '/page-transition.js',
|
||||
array(),
|
||||
filemtime( $dir . '/page-transition.js' ),
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
function alcastromol_page_transition_noscript() {
|
||||
echo '<noscript><style>body{opacity:1!important;transform:none!important;filter:none!important}</style></noscript>';
|
||||
}
|
||||
|
||||
add_action( 'wp_enqueue_scripts', 'alcastromol_page_transition_assets' );
|
||||
add_action( 'wp_head', 'alcastromol_page_transition_noscript', 20 );
|
||||
@@ -0,0 +1,22 @@
|
||||
/* Top scroll progress from trivelta (.tv-prog).
|
||||
Color: left #c9a24b, right #2f6bff. */
|
||||
|
||||
.scroll-progress {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
z-index: 10000;
|
||||
width: 100%;
|
||||
height: 2px;
|
||||
transform-origin: 0 50%;
|
||||
transform: scaleX(0);
|
||||
background: linear-gradient(90deg, #c9a24b, #2f6bff);
|
||||
opacity: 0.9;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.scroll-progress {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
/* Top scroll progress from trivelta: the bar fills as the page scrolls. */
|
||||
(function () {
|
||||
if (window.matchMedia('(prefers-reduced-motion: reduce)').matches) {
|
||||
return;
|
||||
}
|
||||
|
||||
var bar = document.createElement('div');
|
||||
bar.className = 'scroll-progress';
|
||||
bar.setAttribute('aria-hidden', 'true');
|
||||
document.body.appendChild(bar);
|
||||
|
||||
function onScroll() {
|
||||
var scrolled = window.scrollY || window.pageYOffset;
|
||||
var max = document.documentElement.scrollHeight - window.innerHeight;
|
||||
var progress = max > 0 ? Math.min(1, scrolled / max) : 0;
|
||||
|
||||
bar.style.transform = 'scaleX(' + progress + ')';
|
||||
}
|
||||
|
||||
window.addEventListener('scroll', onScroll, { passive: true });
|
||||
window.addEventListener('resize', onScroll);
|
||||
onScroll();
|
||||
}());
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
/**
|
||||
* Top scroll progress bar from trivelta.
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
function alcastromol_scroll_progress_assets() {
|
||||
$dir = get_template_directory() . '/parts/scroll-progress';
|
||||
$uri = get_template_directory_uri() . '/parts/scroll-progress';
|
||||
|
||||
wp_enqueue_style(
|
||||
'alcastromol-scroll-progress',
|
||||
$uri . '/scroll-progress.css',
|
||||
array(),
|
||||
filemtime( $dir . '/scroll-progress.css' )
|
||||
);
|
||||
|
||||
wp_enqueue_script(
|
||||
'alcastromol-scroll-progress',
|
||||
$uri . '/scroll-progress.js',
|
||||
array(),
|
||||
filemtime( $dir . '/scroll-progress.js' ),
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
add_action( 'wp_enqueue_scripts', 'alcastromol_scroll_progress_assets' );
|
||||
@@ -0,0 +1,22 @@
|
||||
/* Lenis smooth scroll (from trivelta-html). Native smooth scroll fights Lenis. */
|
||||
|
||||
html.lenis,
|
||||
html.lenis body {
|
||||
height: auto;
|
||||
}
|
||||
|
||||
.lenis.lenis-smooth {
|
||||
scroll-behavior: auto !important;
|
||||
}
|
||||
|
||||
.lenis.lenis-smooth [data-lenis-prevent] {
|
||||
overscroll-behavior: contain;
|
||||
}
|
||||
|
||||
.lenis.lenis-stopped {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.lenis.lenis-scrolling iframe {
|
||||
pointer-events: none;
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
/* Lenis smooth scroll from trivelta-html: lerp 0.09, wheel only.
|
||||
Same-page hashes use absolute URLs in WordPress, so those scroll too. */
|
||||
(function () {
|
||||
var reduceMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
|
||||
|
||||
if (reduceMotion || !window.Lenis) {
|
||||
return;
|
||||
}
|
||||
|
||||
var lenis = new window.Lenis({
|
||||
lerp: 0.09,
|
||||
smoothWheel: true,
|
||||
smoothTouch: false
|
||||
});
|
||||
|
||||
function raf(time) {
|
||||
lenis.raf(time);
|
||||
window.requestAnimationFrame(raf);
|
||||
}
|
||||
|
||||
window.requestAnimationFrame(raf);
|
||||
|
||||
function anchorOffset() {
|
||||
var header = document.querySelector('header');
|
||||
|
||||
if (!header) {
|
||||
return -70;
|
||||
}
|
||||
|
||||
var position = window.getComputedStyle(header).position;
|
||||
|
||||
if (position === 'fixed' || position === 'sticky') {
|
||||
return -Math.round(header.getBoundingClientRect().height);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
document.addEventListener('click', function (event) {
|
||||
if (event.defaultPrevented || event.button) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) {
|
||||
return;
|
||||
}
|
||||
|
||||
var anchor = event.target.closest ? event.target.closest('a') : null;
|
||||
|
||||
if (!anchor || (anchor.target && anchor.target !== '_self')) {
|
||||
return;
|
||||
}
|
||||
|
||||
var url;
|
||||
|
||||
try {
|
||||
url = new URL(anchor.href, window.location.href);
|
||||
} catch (error) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!url.hash || url.hash === '#') {
|
||||
return;
|
||||
}
|
||||
|
||||
if (url.origin !== window.location.origin || url.pathname !== window.location.pathname || url.search !== window.location.search) {
|
||||
return;
|
||||
}
|
||||
|
||||
var target = document.querySelector(url.hash);
|
||||
|
||||
if (!target) {
|
||||
return;
|
||||
}
|
||||
|
||||
event.preventDefault();
|
||||
lenis.scrollTo(target, {
|
||||
offset: anchorOffset(),
|
||||
duration: 1.1
|
||||
});
|
||||
});
|
||||
}());
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
/**
|
||||
* Lenis smooth scroll, same setup as trivelta-html.
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
function alcastromol_smooth_scroll_assets() {
|
||||
$dir = get_template_directory() . '/parts/smooth-scroll';
|
||||
$uri = get_template_directory_uri() . '/parts/smooth-scroll';
|
||||
|
||||
wp_enqueue_style(
|
||||
'alcastromol-smooth-scroll',
|
||||
$uri . '/smooth-scroll.css',
|
||||
array(),
|
||||
filemtime( $dir . '/smooth-scroll.css' )
|
||||
);
|
||||
|
||||
wp_enqueue_script(
|
||||
'lenis',
|
||||
'https://cdn.jsdelivr.net/npm/lenis@1.1.14/dist/lenis.min.js',
|
||||
array(),
|
||||
'1.1.14',
|
||||
true
|
||||
);
|
||||
|
||||
wp_enqueue_script(
|
||||
'alcastromol-smooth-scroll',
|
||||
$uri . '/smooth-scroll.js',
|
||||
array( 'lenis' ),
|
||||
filemtime( $dir . '/smooth-scroll.js' ),
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
add_action( 'wp_enqueue_scripts', 'alcastromol_smooth_scroll_assets' );
|
||||
@@ -0,0 +1,18 @@
|
||||
/* Spotlight overlay. Clicks pass through to the page. */
|
||||
|
||||
.spotlight-cursor {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
z-index: 9999;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.spotlight-cursor canvas {
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
pointer-events: none;
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
/* Spotlight cursor from Cursify.
|
||||
https://cursify.ui-layouts.com/components/spotlight-cursor */
|
||||
(function () {
|
||||
if (window.matchMedia('(prefers-reduced-motion: reduce)').matches) {
|
||||
return;
|
||||
}
|
||||
|
||||
var spotlightSize = 50;
|
||||
var spotlightIntensity = 0.8;
|
||||
var fadeSpeed = 0.1;
|
||||
var glowColor = '255, 255, 255';
|
||||
var pulseSpeed = 2000;
|
||||
|
||||
var root = document.createElement('div');
|
||||
root.className = 'spotlight-cursor';
|
||||
root.setAttribute('aria-hidden', 'true');
|
||||
|
||||
var canvas = document.createElement('canvas');
|
||||
root.appendChild(canvas);
|
||||
document.body.appendChild(root);
|
||||
|
||||
var ctx = canvas.getContext('2d');
|
||||
var spotlightPos = { x: window.innerWidth / 2, y: window.innerHeight / 2 };
|
||||
var targetPos = { x: spotlightPos.x, y: spotlightPos.y };
|
||||
|
||||
function resizeCanvas() {
|
||||
canvas.width = window.innerWidth;
|
||||
canvas.height = window.innerHeight;
|
||||
}
|
||||
|
||||
function lerp(start, end, factor) {
|
||||
return start + (end - start) * factor;
|
||||
}
|
||||
|
||||
function handleMouseMove(event) {
|
||||
targetPos.x = event.clientX;
|
||||
targetPos.y = event.clientY;
|
||||
}
|
||||
|
||||
function render() {
|
||||
spotlightPos.x = lerp(spotlightPos.x, targetPos.x, fadeSpeed);
|
||||
spotlightPos.y = lerp(spotlightPos.y, targetPos.y, fadeSpeed);
|
||||
|
||||
ctx.globalCompositeOperation = 'source-over';
|
||||
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
||||
|
||||
// color de fondo
|
||||
ctx.fillStyle = 'rgba(250, 250, 250, 0.05)';
|
||||
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
||||
|
||||
var pulseScale = 1 + 0.1 * Math.sin((Date.now() / pulseSpeed) * Math.PI * 2);
|
||||
var currentSpotlightSize = spotlightSize * pulseScale;
|
||||
var gradient = ctx.createRadialGradient(
|
||||
spotlightPos.x,
|
||||
spotlightPos.y,
|
||||
0,
|
||||
spotlightPos.x,
|
||||
spotlightPos.y,
|
||||
currentSpotlightSize
|
||||
);
|
||||
|
||||
gradient.addColorStop(0, 'rgba(' + glowColor + ', ' + spotlightIntensity + ')');
|
||||
gradient.addColorStop(0.5, 'rgba(' + glowColor + ', ' + (spotlightIntensity * 0.5) + ')');
|
||||
gradient.addColorStop(1, 'rgba(0, 0, 0, 0)');
|
||||
|
||||
ctx.globalCompositeOperation = 'destination-out';
|
||||
ctx.fillStyle = gradient;
|
||||
ctx.beginPath();
|
||||
ctx.arc(spotlightPos.x, spotlightPos.y, currentSpotlightSize, 0, Math.PI * 2);
|
||||
ctx.fill();
|
||||
|
||||
ctx.globalCompositeOperation = 'source-over';
|
||||
var glowGradient = ctx.createRadialGradient(
|
||||
spotlightPos.x,
|
||||
spotlightPos.y,
|
||||
0,
|
||||
spotlightPos.x,
|
||||
spotlightPos.y,
|
||||
currentSpotlightSize * 1.2
|
||||
);
|
||||
|
||||
glowGradient.addColorStop(0, 'rgba(' + glowColor + ', 0.2)');
|
||||
glowGradient.addColorStop(1, 'rgba(0, 0, 0, 0)');
|
||||
ctx.fillStyle = glowGradient;
|
||||
ctx.beginPath();
|
||||
ctx.arc(spotlightPos.x, spotlightPos.y, currentSpotlightSize * 1.2, 0, Math.PI * 2);
|
||||
ctx.fill();
|
||||
|
||||
window.requestAnimationFrame(render);
|
||||
}
|
||||
|
||||
resizeCanvas();
|
||||
window.addEventListener('resize', resizeCanvas);
|
||||
document.addEventListener('mousemove', handleMouseMove);
|
||||
render();
|
||||
}());
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
/**
|
||||
* Spotlight cursor from Cursify.
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
function alcastromol_spotlight_cursor_assets() {
|
||||
$dir = get_template_directory() . '/parts/spotlight-cursor';
|
||||
$uri = get_template_directory_uri() . '/parts/spotlight-cursor';
|
||||
|
||||
wp_enqueue_style(
|
||||
'alcastromol-spotlight-cursor',
|
||||
$uri . '/spotlight-cursor.css',
|
||||
array(),
|
||||
filemtime( $dir . '/spotlight-cursor.css' )
|
||||
);
|
||||
|
||||
wp_enqueue_script(
|
||||
'alcastromol-spotlight-cursor',
|
||||
$uri . '/spotlight-cursor.js',
|
||||
array(),
|
||||
filemtime( $dir . '/spotlight-cursor.js' ),
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
add_action( 'wp_enqueue_scripts', 'alcastromol_spotlight_cursor_assets' );
|
||||
Reference in New Issue
Block a user