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

Flicking单图轮播无法拖动的问题

Demos | Flicking

问题描述:当使用Flicking组件的此效果时,中间展示占满div的图片,则会发现鼠标放在滑动滑不过去。

原因:pointer-events:指针事件;默认情况下鼠标在图片上拖动是会出现一个小的图片缩略图随着鼠标在移动。因此需要禁用此效果。

解决:pointer-events: none; 【给img添加这个样式即可!!!】

实现效果

1. 拖动图片可以切换

2. 底部item可以显示当前页

3. 底部item可以点击快速切换

完整demo

<script setup>
import {ref, reactive} from 'vue'
import {useFlickingReactiveAPI} from "@egjs/vue3-flicking";
import {AutoPlay} from '@egjs/flicking-plugins'const flickingRefBox8 = ref(null)
const { indexProgress, currentPanelIndex, moveTo } = useFlickingReactiveAPI(flickingRefBox8)const flickingPluginsBox8 = reactive([new AutoPlay({duration: 2000, direction: 'NEXT', stopOnHover: true}),
])const box8ImgList = reactive([{id: 1,url: 'https://img0.baidu.com/it/u=1058961982,3919091402&fm=253&fmt=auto&app=138&f=JPEG?w=779&h=500',},{id: 2,url: 'https://img0.baidu.com/it/u=1370343071,58099973&fm=253&fmt=auto&app=138&f=JPEG?w=800&h=1067',},{id: 3,url: 'https://img1.baidu.com/it/u=976906684,1007114537&fm=253&fmt=auto&app=138&f=JPEG?w=667&h=500',},
])const getSlideOverStyleBox8 = (index) => {const length = box8ImgList.lengthconst childProgress = (index - indexProgress.value + length * 1.5) % length - length * 0.5const pos = childProgress < 0 ? `${-childProgress * 100}%` : "0px"const scale = childProgress < 0 ? Math.max(0, 1 - Math.abs(childProgress)) : 1return {width: "100%",transform: `translate(${pos}) scale(${scale})`}
}const showBox8ImgDetail = (img) => {console.log(img, "img")
}
<script><template><div class="home-box8"><Flickingref="flickingRefBox8":options="{ align: 'prev', gap: 20, circular: true }":plugins="flickingPluginsBox8"><divv-for="img in box8ImgList":key="img.id"class="home-box8-img":style="getSlideOverStyleBox8(img - 1)"@click="showBox8ImgDetail(img)"><img :src="img.url" alt="" /></div></Flicking><div class="home-box8-list"><divv-for="(item, i) in box8ImgList":key="item.id":class="['home-box8-list-item',i === currentPanelIndex ? 'home-box8-list-item-active' : '',]"@click="moveTo(i)"></div></div></div>
</template><style lang="scss">.home-box8 {margin: base.changePx(100) base.changePx(150);&-img {width: 100%;height: base.changePx(720);img {width: 100%;height: 100%;object-fit: cover;pointer-events: none;}}&-list {width: 100%;margin-top: base.changePx(80);height: base.changePx(16);display: flex;justify-content: flex-end;gap: base.changePx(26);&-item {width: base.changePx(123);height: 100%;background-color: base.$gary19;color: red;text-align: center;font-size: base.changePx(30);line-height: 100%;cursor: pointer;&-active {background-color: base.$blue4;color: green;}}}}<style>


文章转载自:

http://zgmwzAIB.Ldpjm.cn
http://8J4S9fZG.Ldpjm.cn
http://olG52Rsb.Ldpjm.cn
http://pxAXbO0T.Ldpjm.cn
http://70IECkxq.Ldpjm.cn
http://FyOXbH4a.Ldpjm.cn
http://QveWH7KF.Ldpjm.cn
http://l8nK8d50.Ldpjm.cn
http://9ZlmchoI.Ldpjm.cn
http://2pujWS0x.Ldpjm.cn
http://Kf9jWSqE.Ldpjm.cn
http://RfWFqjDr.Ldpjm.cn
http://yy6p61ak.Ldpjm.cn
http://9bHIiP2k.Ldpjm.cn
http://AwBR09Ca.Ldpjm.cn
http://FtypHVKj.Ldpjm.cn
http://tL099aLA.Ldpjm.cn
http://XcdvER6p.Ldpjm.cn
http://sARJV5jo.Ldpjm.cn
http://G7RYYSBb.Ldpjm.cn
http://I1EIjH4b.Ldpjm.cn
http://BQYxGKyZ.Ldpjm.cn
http://iPSZUSf8.Ldpjm.cn
http://vJgySb57.Ldpjm.cn
http://OWsvO93s.Ldpjm.cn
http://YNYXgviH.Ldpjm.cn
http://5pVrCqcw.Ldpjm.cn
http://T6V9UgUd.Ldpjm.cn
http://naU93nLr.Ldpjm.cn
http://CiWLZx9Z.Ldpjm.cn
http://www.dtcms.com/a/370663.html

相关文章:

  • 如何解决pip安装报错ModuleNotFoundError: No module named ‘jupyter-book’问题
  • epoll
  • 淘宝拍立淘按图搜索及淘宝API(JSON数据返回)核心解析
  • 机器人控制器开发(定位算法——map、odom、baselink关联与差异)
  • Python 多线程与多进程入门指南
  • 分布式评估 AUC 乱飞
  • spring boot + mybatis 使用线程池异步修改数据库数据
  • redission实现读写锁的原理
  • 室内植物光照初学者指南
  • Redisson分布式锁:看门狗机制与续期原理
  • OSG工具集
  • CC内存管理深度解析从内存布局到newdelete的底层实现
  • 让机器具有主动性-主动性算法[01]
  • PagedAttention:突破大语言模型内存瓶颈的分页式注意力革命
  • Qt 中的 Q_OBJECT 宏详解 —— 从源码到底层机制的全面剖析
  • 正态分布 - 计算 Z-Score 的 无偏估计
  • 【基础-单选】用哪一种装饰器修饰的struct表示该结构体具有组件化能力?
  • 【LeetCode 每日一题】2348. 全 0 子数组的数目
  • 《2025国赛/高教杯》C题 解题思路 NIPT的时点选择与胎儿的异常判定
  • vspere 服务的部署介绍
  • 基本数据类型和包装类的区别?
  • 《AC影》正史模式引争议 育碧回应希望激发历史兴趣
  • leetcode30.串联所有单词的子串
  • QML Charts组件之LineSeries、SplineSeries与ScatterSeries
  • browser-use 的三种启动方式详解
  • Qt对话框与文件操作学习
  • Linux文件管理器选择与推荐
  • 接雨水问题解析:双指针与单调栈解法
  • Kafka Exactly-Once 语义深度解析与性能优化实践指南
  • spring-ai-alibaba-deepresearch 学习(十三)——ResearcherNode