Initial commit xmarticaims
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
#tecnologias .platform-marquee__group {
|
||||
perspective: 900px;
|
||||
perspective-origin: center;
|
||||
}
|
||||
|
||||
#tecnologias .platform-marquee__card {
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
overflow: hidden;
|
||||
transform-style: preserve-3d;
|
||||
transform-origin: center;
|
||||
backface-visibility: hidden;
|
||||
background:
|
||||
linear-gradient(#f8fdff, #f8fdff) padding-box,
|
||||
linear-gradient(135deg, #00acff 0%, rgba(79, 172, 217, 0.22) 35%, rgba(79, 172, 217, 0.3) 68%, #00acff 100%) border-box;
|
||||
box-shadow: 0 8px 24px rgba(18, 69, 100, 0.08);
|
||||
}
|
||||
|
||||
#tecnologias .platform-marquee__card.platform-card-tilt-ready {
|
||||
will-change: transform;
|
||||
}
|
||||
|
||||
#tecnologias .platform-marquee__card:hover,
|
||||
#tecnologias .platform-marquee__card.is-platform-tilting {
|
||||
z-index: 4;
|
||||
}
|
||||
|
||||
body.front-page #tecnologias.home-platforms--ims .platform-marquee__card {
|
||||
background:
|
||||
linear-gradient(#142035, #142035) padding-box,
|
||||
linear-gradient(135deg, #ffcd11 0%, rgba(255, 205, 17, 0.32) 42%, rgba(255, 255, 255, 0.7) 100%) border-box;
|
||||
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.16);
|
||||
}
|
||||
|
||||
#tecnologias .platform-marquee__logo {
|
||||
position: relative;
|
||||
z-index: 3;
|
||||
transform: translateZ(18px);
|
||||
transition: transform 260ms ease;
|
||||
}
|
||||
|
||||
#tecnologias .platform-marquee__card:hover .platform-marquee__logo,
|
||||
#tecnologias .platform-marquee__card.is-platform-tilting .platform-marquee__logo {
|
||||
transform: translateZ(28px) scale(1.035);
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce), (hover: none), (pointer: coarse) {
|
||||
#tecnologias .platform-marquee__card {
|
||||
transform: none !important;
|
||||
}
|
||||
|
||||
#tecnologias .platform-marquee__logo {
|
||||
transform: none;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
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('#tecnologias .platform-marquee__card');
|
||||
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 = 7;
|
||||
let bounds = null;
|
||||
let frame = 0;
|
||||
let pointerX = 0;
|
||||
let pointerY = 0;
|
||||
|
||||
set(card, { rotateX: 0, rotateY: 0, scale: 1 });
|
||||
card.classList.add('platform-card-tilt-ready');
|
||||
|
||||
const renderTilt = () => {
|
||||
frame = 0;
|
||||
|
||||
if (!bounds) {
|
||||
return;
|
||||
}
|
||||
|
||||
const normalizedX = Math.max(-1, Math.min(1, ((pointerX - bounds.left) / bounds.width) * 2 - 1));
|
||||
const normalizedY = Math.max(-1, Math.min(1, ((pointerY - bounds.top) / bounds.height) * 2 - 1));
|
||||
|
||||
remove(card);
|
||||
animate(card, {
|
||||
rotateX: normalizedY * -maxRotation,
|
||||
rotateY: normalizedX * maxRotation,
|
||||
scale: 1.055,
|
||||
duration: 320,
|
||||
ease: 'out(3)',
|
||||
});
|
||||
};
|
||||
|
||||
card.addEventListener('pointerenter', (event) => {
|
||||
bounds = card.getBoundingClientRect();
|
||||
pointerX = event.clientX;
|
||||
pointerY = event.clientY;
|
||||
card.classList.add('is-platform-tilting');
|
||||
renderTilt();
|
||||
});
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
bounds = null;
|
||||
card.classList.remove('is-platform-tilting');
|
||||
remove(card);
|
||||
animate(card, {
|
||||
rotateX: 0,
|
||||
rotateY: 0,
|
||||
scale: 1,
|
||||
duration: 620,
|
||||
ease: 'out(4)',
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
/**
|
||||
* Anime.js tilt interaction for the front-page platform cards.
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
function xmartica_platform_card_tilt_assets() {
|
||||
if ( ! is_front_page() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$dir = get_template_directory() . '/parts/platform-card-tilt';
|
||||
$uri = get_template_directory_uri() . '/parts/platform-card-tilt';
|
||||
|
||||
wp_enqueue_style(
|
||||
'xmartica-platform-card-tilt',
|
||||
$uri . '/platform-card-tilt.css',
|
||||
array(),
|
||||
filemtime( $dir . '/platform-card-tilt.css' )
|
||||
);
|
||||
|
||||
wp_enqueue_script(
|
||||
'xmartica-platform-card-tilt',
|
||||
$uri . '/platform-card-tilt.js',
|
||||
array(),
|
||||
filemtime( $dir . '/platform-card-tilt.js' ),
|
||||
true
|
||||
);
|
||||
}
|
||||
add_action( 'wp_enqueue_scripts', 'xmartica_platform_card_tilt_assets' );
|
||||
|
||||
function xmartica_platform_card_tilt_module_tag( $tag, $handle, $src ) {
|
||||
if ( 'xmartica-platform-card-tilt' !== $handle ) {
|
||||
return $tag;
|
||||
}
|
||||
|
||||
return '<script type="module" src="' . esc_url( $src ) . '"></script>';
|
||||
}
|
||||
add_filter( 'script_loader_tag', 'xmartica_platform_card_tilt_module_tag', 10, 3 );
|
||||
Reference in New Issue
Block a user