Initial commit xmarticaims
This commit is contained in:
@@ -0,0 +1,95 @@
|
||||
#soluciones .practice-card-list {
|
||||
perspective: 1200px;
|
||||
perspective-origin: center;
|
||||
}
|
||||
|
||||
#soluciones .practice-card-link {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
z-index: 3;
|
||||
display: block;
|
||||
border-radius: inherit;
|
||||
text-decoration: none;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
/* Keep the full-card link above the text layers introduced by the spotlight. */
|
||||
body.front-page #primary #soluciones .practice-card-link {
|
||||
position: absolute;
|
||||
z-index: 30;
|
||||
}
|
||||
|
||||
#soluciones .practice-card-link:focus-visible {
|
||||
outline: 2px solid #fff;
|
||||
outline-offset: -4px;
|
||||
}
|
||||
|
||||
#soluciones [data-practice-card-tilt]:focus-within {
|
||||
border-color: #fff;
|
||||
background-color: rgba(14, 27, 45, 0.2);
|
||||
-webkit-backdrop-filter: blur(18px) saturate(125%);
|
||||
backdrop-filter: blur(18px) saturate(125%);
|
||||
box-shadow:
|
||||
inset 0 1px 0 rgba(255, 255, 255, 0.22),
|
||||
0 18px 46px rgba(0, 172, 255, 0.16);
|
||||
}
|
||||
|
||||
#soluciones [data-practice-card-tilt] {
|
||||
position: relative;
|
||||
background-color: #0e1b2d;
|
||||
background-image: linear-gradient(121.587deg, rgba(79, 172, 217, 0.5) 3.4209%, rgba(0, 0, 0, 0.5) 122.06%);
|
||||
-webkit-backdrop-filter: blur(0) saturate(100%);
|
||||
backdrop-filter: blur(0) saturate(100%);
|
||||
box-shadow: none;
|
||||
transform-style: preserve-3d;
|
||||
transform-origin: center;
|
||||
backface-visibility: hidden;
|
||||
z-index: 1;
|
||||
transition:
|
||||
border-color 260ms ease,
|
||||
box-shadow 260ms ease,
|
||||
background-color 260ms ease,
|
||||
-webkit-backdrop-filter 260ms ease,
|
||||
backdrop-filter 260ms ease;
|
||||
}
|
||||
|
||||
body.front-page #soluciones.home-solutions--ims [data-practice-card-tilt] {
|
||||
border: 1px solid transparent;
|
||||
background:
|
||||
linear-gradient(121.587deg, rgba(16, 31, 51, 0.98) 3.4209%, rgba(8, 15, 26, 0.98) 122.06%) padding-box,
|
||||
linear-gradient(121.587deg, #ffcd11 3.4209%, #ffffff 122.06%) border-box;
|
||||
}
|
||||
|
||||
body.front-page #soluciones.home-solutions--ims [data-practice-card-tilt]:focus-within,
|
||||
body.front-page #soluciones.home-solutions--ims [data-practice-card-tilt]:hover,
|
||||
body.front-page #soluciones.home-solutions--ims [data-practice-card-tilt].is-tilting {
|
||||
border-color: transparent;
|
||||
background:
|
||||
linear-gradient(121.587deg, rgba(16, 31, 51, 0.9) 3.4209%, rgba(8, 15, 26, 0.9) 122.06%) padding-box,
|
||||
linear-gradient(121.587deg, #ffcd11 3.4209%, #ffffff 122.06%) border-box;
|
||||
box-shadow:
|
||||
inset 0 1px 0 rgba(255, 255, 255, 0.18),
|
||||
0 18px 46px rgba(255, 205, 17, 0.14);
|
||||
}
|
||||
|
||||
#soluciones [data-practice-card-tilt].practice-card-tilt-ready {
|
||||
will-change: transform;
|
||||
}
|
||||
|
||||
#soluciones [data-practice-card-tilt]:hover,
|
||||
#soluciones [data-practice-card-tilt].is-tilting {
|
||||
z-index: 3;
|
||||
border-color: #fff;
|
||||
background-color: rgba(14, 27, 45, 0.2);
|
||||
-webkit-backdrop-filter: blur(18px) saturate(125%);
|
||||
backdrop-filter: blur(18px) saturate(125%);
|
||||
box-shadow:
|
||||
inset 0 1px 0 rgba(255, 255, 255, 0.22),
|
||||
0 18px 46px rgba(0, 172, 255, 0.16);
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce), (hover: none), (pointer: coarse) {
|
||||
#soluciones [data-practice-card-tilt] {
|
||||
transform: none !important;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
import { animate } from '../../assets/vendor/animejs/modules/animation/index.js';
|
||||
import { remove, set } from '../../assets/vendor/animejs/modules/utils/index.js';
|
||||
|
||||
const cards = document.querySelectorAll('#soluciones [data-practice-card-tilt]');
|
||||
const canTilt = window.matchMedia('(hover: hover) and (pointer: fine)').matches;
|
||||
const reduceMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
|
||||
|
||||
if (cards.length && canTilt && !reduceMotion) {
|
||||
cards.forEach((card) => {
|
||||
const maxRotation = 6;
|
||||
let frame = 0;
|
||||
let pointerX = 0;
|
||||
let pointerY = 0;
|
||||
|
||||
set(card, { rotateX: 0, rotateY: 0, scale: 1 });
|
||||
card.classList.add('practice-card-tilt-ready');
|
||||
|
||||
const renderTilt = () => {
|
||||
frame = 0;
|
||||
const bounds = card.getBoundingClientRect();
|
||||
const normalizedX = ((pointerX - bounds.left) / bounds.width) * 2 - 1;
|
||||
const normalizedY = ((pointerY - bounds.top) / bounds.height) * 2 - 1;
|
||||
const rotateX = normalizedY * -maxRotation;
|
||||
const rotateY = normalizedX * maxRotation;
|
||||
|
||||
remove(card);
|
||||
animate(card, {
|
||||
rotateX,
|
||||
rotateY,
|
||||
scale: 1.018,
|
||||
duration: 360,
|
||||
ease: 'out(3)',
|
||||
});
|
||||
};
|
||||
|
||||
card.addEventListener('pointerenter', () => {
|
||||
card.classList.add('is-tilting');
|
||||
});
|
||||
|
||||
card.addEventListener('pointermove', (event) => {
|
||||
pointerX = event.clientX;
|
||||
pointerY = event.clientY;
|
||||
|
||||
if (!frame) {
|
||||
frame = window.requestAnimationFrame(renderTilt);
|
||||
}
|
||||
});
|
||||
|
||||
card.addEventListener('pointerleave', () => {
|
||||
if (frame) {
|
||||
window.cancelAnimationFrame(frame);
|
||||
frame = 0;
|
||||
}
|
||||
|
||||
card.classList.remove('is-tilting');
|
||||
remove(card);
|
||||
animate(card, {
|
||||
rotateX: 0,
|
||||
rotateY: 0,
|
||||
scale: 1,
|
||||
duration: 700,
|
||||
ease: 'out(4)',
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
/**
|
||||
* Anime.js pointer tilt for the front-page practice cards.
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
function xmartica_practice_card_tilt_assets() {
|
||||
if ( ! is_front_page() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$dir = get_template_directory() . '/parts/practice-card-tilt';
|
||||
$uri = get_template_directory_uri() . '/parts/practice-card-tilt';
|
||||
|
||||
wp_enqueue_style(
|
||||
'xmartica-practice-card-tilt',
|
||||
$uri . '/practice-card-tilt.css',
|
||||
array(),
|
||||
filemtime( $dir . '/practice-card-tilt.css' )
|
||||
);
|
||||
|
||||
wp_enqueue_script(
|
||||
'xmartica-practice-card-tilt',
|
||||
$uri . '/practice-card-tilt.js',
|
||||
array(),
|
||||
filemtime( $dir . '/practice-card-tilt.js' ),
|
||||
true
|
||||
);
|
||||
}
|
||||
add_action( 'wp_enqueue_scripts', 'xmartica_practice_card_tilt_assets' );
|
||||
|
||||
function xmartica_practice_card_tilt_module_tag( $tag, $handle, $src ) {
|
||||
if ( 'xmartica-practice-card-tilt' !== $handle ) {
|
||||
return $tag;
|
||||
}
|
||||
|
||||
return '<script type="module" src="' . esc_url( $src ) . '"></script>';
|
||||
}
|
||||
add_filter( 'script_loader_tag', 'xmartica_practice_card_tilt_module_tag', 10, 3 );
|
||||
Reference in New Issue
Block a user