当前位置: 首页 > news >正文

vue 3D 翻页效果

<template><view class="swipe-container" @touchstart="onTouchStart" @touchmove="onTouchMove" @touchend="onTouchEnd"><view class="page">初始页</view></view>
</template><script>export default {data() {return {startX: 0, // 触摸开始的 X 坐标moveX: 0, // 当前移动的 X 坐标threshold: 100, // 滑动阈值};},methods: {onTouchStart(event) {this.startX = event.touches[0].clientX;},onTouchMove(event) {this.moveX = event.touches[0].clientX - this.startX;},onTouchEnd() {const page = document.getElementsByClassName("page")[0];if (this.moveX > this.threshold) {console.log("向右滑动");page.style.transformOrigin = 'right';const animation = page.animate([{transform: 'rotateY(0deg)'},{transform: 'rotateY(90deg)'}], {duration: 1000,iterations: 1, //循环一次//fill: 'forwards'});//动态加载数据animation.onfinish = () => {//animation.reverse();console.log('动画完成!');//数据渲染到.page元素中};} else if (this.moveX < -this.threshold) {console.log("向左滑动");page.style.transformOrigin = 'left';const animation = page.animate([{transform: 'rotateY(0deg)'},{transform: 'rotateY(-90deg)'}], {duration: 1000,iterations: 1, //循环一次//fill: 'forwards' // 动画结束后保持最终状态});//动态加载数据animation.onfinish = () => {//animation.reverse();console.log('动画完成2');//数据渲染到.page元素中};}this.moveX = 0; // 重置移动距离},}}
</script><style scoped lang="scss">.swipe-container {width: 100%;height: 500px;display: flex;justify-content: center;align-items: center;perspective: 1000px;}.swipe-container .page {width: 100%;height: 100%;/* 保留 3D 变换 */transform-style: preserve-3d;background-color: red;/* 提示浏览器使用硬件加速 */will-change: transform;}
</style>

http://www.lryc.cn/news/542483.html

相关文章:

  • 【系列专栏】银行信息系统研发外包风险管控-08
  • [ComfyUI] 【AI】如何获得一张人物图片的优质描述
  • 深度学习基础--ResNet网络的讲解,ResNet50的复现(pytorch)以及用复现的ResNet50做鸟类图像分类
  • stack,queue,priority_queue学习知识点
  • css特异性,继承性
  • 力扣hot100刷题——11~20
  • R语言Stan贝叶斯空间条件自回归CAR模型分析死亡率多维度数据可视化
  • 速通HTML
  • 安装 Milvus Java SDK
  • 云手机如何进行经纬度修改
  • 牛客周赛 Round 82(思维、差分、树状数组、大根堆、前后缀、递归)
  • MQTT实现智能家居------2、写MQTT程序的思路
  • 大模型面试问题准备
  • C语言:二维数组在内存中是怎么存储的
  • AI时代前端开发技能变革与ScriptEcho:拥抱AI,提升效率
  • 计算机毕业设计SpringBoot+Vue.js美容院管理系统(源码+文档+PPT+讲解)
  • 【LeetCodehHot100_0x01】
  • Qt::MouseButtons解析
  • 跨域问题解释及前后端解决方案(SpringBoot)
  • 4-知识图谱的抽取与构建-4_2实体识别与分类
  • 腾讯云大模型知识引擎×DeepSeek赋能文旅
  • TMDS视频编解码算法
  • C++程序员内功修炼——Linux C/C++编程技术汇总
  • 【数据结构】链表中快指针和慢指针
  • 6_zookeeper集群配置
  • Docker核心概念
  • LD_PRELOAD 绕过 disable_function 学习
  • 如何用JAVA实现布隆过滤器?
  • 游戏开发 游戏开始界面
  • Python解析 Flink Job 依赖的checkpoint 路径