2019年4月12日 layer版本 layer-v3.1.1
layer.photos 方法在使用过程中发现没有通过鼠标中键(滚轴)实现图片缩放功,故通过搜索引擎找到如下方法
需要引用 jquery
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26$(document).on("mousewheel DOMMouseScroll", ".layui-layer-phimg img", function (e) { var delta = (e.originalEvent.wheelDelta && (e.originalEvent.wheelDelta > 0 ? 1 : -1)) || // chrome & ie (e.originalEvent.detail && (e.originalEvent.detail > 0 ? -1 : 1)); // firefox var imagep = $(".layui-layer-phimg").parent().parent(); var image = $(".layui-layer-phimg").parent(); var h = image.height(); var w = image.width(); if (delta > 0) { if (h < (window.innerHeight)) { h = h * 1.05; w = w * 1.05; } } else if (delta < 0) { if (h > 100) { h = h * 0.95; w = w * 0.95; } } imagep.css("top", (window.innerHeight - h) / 2); imagep.css("left", (window.innerWidth - w) / 2); image.height(h); image.width(w); imagep.height(h); imagep.width(w); });
此方法可以实现鼠标中键(滚轴)缩放,但是在实际项目中还是相册功能不符合:切换图片的箭头,在图片内显示,也即是说箭头总是跟随图片的变化而变化。
最后
以上就是精明薯片最近收集整理的关于layer.photos 相册(图片查看器)实现缩放的全部内容,更多相关layer.photos内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复