mirror of
https://github.com/anatolykopyl/vue-three-d-mockup.git
synced 2026-03-26 04:45:09 +00:00
Handle touches
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "vue-three-d-mockup",
|
||||
"version": "0.2.0",
|
||||
"version": "0.2.1",
|
||||
"description": "📱 A 3D phone mockup component to showcase your apps",
|
||||
"author": "Anatoly Kopyl <akopyl@radner.ru>",
|
||||
"keywords": ["vue", "mockup-generator", "threejs", "design", "mockup"],
|
||||
|
||||
@@ -4,6 +4,10 @@
|
||||
@mouseenter="handleMouseEnter"
|
||||
@mouseleave="handleMouseLeave"
|
||||
@mousemove="handleMouseMove"
|
||||
|
||||
@touchstart="handleMouseEnter"
|
||||
@touchend="handleMouseLeave"
|
||||
@touchmove="handleTouchMove"
|
||||
/>
|
||||
</template>
|
||||
|
||||
@@ -235,6 +239,13 @@ export default {
|
||||
mouseY = -(event.clientY - rect.top - rect.height / 2);
|
||||
}
|
||||
|
||||
function handleTouchMove(event) {
|
||||
event.preventDefault();
|
||||
const rect = container.value.getBoundingClientRect();
|
||||
mouseX = event.touches[0].clientX - rect.left - rect.width / 2;
|
||||
mouseY = -(event.touches[0].clientY - rect.top - rect.height / 2);
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
init();
|
||||
animate(0);
|
||||
@@ -245,6 +256,7 @@ export default {
|
||||
handleMouseEnter,
|
||||
handleMouseLeave,
|
||||
handleMouseMove,
|
||||
handleTouchMove,
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user