mAi: #7 - smartin3.de Mobile: 3D-Animation-Touch auf Wrapper begrenzen
Touchmove-Listener von .hero auf .text3d-wrapper verschoben, sodass nur Touches direkt auf der animierten Text-Komponente die Animation triggern. preventDefault() entfernt + touch-action: pan-y auf den Wrapper — vertical scroll funktioniert jetzt sowohl außerhalb als auch innerhalb des Animations-Bereichs ungestört. Desktop-mousemove unverändert.
This commit is contained in:
@@ -93,6 +93,7 @@
|
||||
margin: 0 auto 40px;
|
||||
display: flex; justify-content: center;
|
||||
padding: 60px 40px;
|
||||
touch-action: pan-y;
|
||||
}
|
||||
|
||||
.text3d {
|
||||
@@ -670,8 +671,9 @@
|
||||
// Interactive 3D text
|
||||
(function() {
|
||||
var hero = document.querySelector('.hero');
|
||||
var wrapper = document.querySelector('.text3d-wrapper');
|
||||
var text = document.querySelector('.text3d');
|
||||
if (!hero || !text) return;
|
||||
if (!hero || !wrapper || !text) return;
|
||||
|
||||
function handleMove(x, y) {
|
||||
var w = window.innerWidth;
|
||||
@@ -684,10 +686,9 @@
|
||||
}
|
||||
|
||||
hero.addEventListener('mousemove', function(e) { handleMove(e.clientX, e.clientY); });
|
||||
hero.addEventListener('touchmove', function(e) {
|
||||
e.preventDefault();
|
||||
wrapper.addEventListener('touchmove', function(e) {
|
||||
handleMove(e.touches[0].clientX, e.touches[0].clientY);
|
||||
}, {passive: false});
|
||||
}, {passive: true});
|
||||
hero.addEventListener('mouseleave', function() {
|
||||
text.style.animation = '';
|
||||
text.style.transform = '';
|
||||
|
||||
Reference in New Issue
Block a user