mirror of https://github.com/layui/layui
优化 layer.photo 移动端滑动切换图片
parent
462ed13f18
commit
16121389da
|
@ -1601,6 +1601,26 @@ layer.photos = function(options, loop, key){
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 滑动切换图片事件,仅限 layui 中
|
||||||
|
if(window.layui || window.lay){
|
||||||
|
var lay = window.layui.lay || window.lay;
|
||||||
|
var touchEndCallback = function(e, state){
|
||||||
|
var threshold = 40;
|
||||||
|
var shouldSwipe = Math.abs(state.deltaX) > threshold;
|
||||||
|
if(!shouldSwipe) return;
|
||||||
|
if(state.direction === 'left'){
|
||||||
|
dict.imgnext(true);
|
||||||
|
}else if(state.direction === 'right'){
|
||||||
|
dict.imgprev(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$.each([that.shadeo, dict.main], function(i, elem){
|
||||||
|
lay.touchSwipe(elem, {
|
||||||
|
onTouchEnd: touchEndCallback
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// 图片预加载
|
// 图片预加载
|
||||||
|
@ -1761,7 +1781,7 @@ ready.run = function(_$){
|
||||||
// 加载方式
|
// 加载方式
|
||||||
window.layui && layui.define ? (
|
window.layui && layui.define ? (
|
||||||
layer.ready(),
|
layer.ready(),
|
||||||
layui.define('jquery', function(exports){ // layui
|
layui.define(['jquery','lay'], function(exports){ // layui
|
||||||
layer.path = layui.cache.dir;
|
layer.path = layui.cache.dir;
|
||||||
ready.run(layui.$);
|
ready.run(layui.$);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue