优化 layer 移动端定位 (#1376)

* 优化 layer 移动端定位

* update code
pull/1378/head
morning-star 1 year ago committed by GitHub
parent c7d6cf90c9
commit 6aa349b640
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -24,6 +24,7 @@
<button class="layui-btn" lay-on="test7">Prompt</button> <button class="layui-btn" lay-on="test7">Prompt</button>
<button class="layui-btn" lay-on="test8">Tab</button> <button class="layui-btn" lay-on="test8">Tab</button>
<button class="layui-btn" lay-on="test9">Photo</button> <button class="layui-btn" lay-on="test9">Photo</button>
<button class="layui-btn" lay-on="test10">Drawer</button>
<button class="layui-btn" lay-on="testTime">自动关闭</button> <button class="layui-btn" lay-on="testTime">自动关闭</button>
<a href="https://layui.dev/docs/2.8/layer/" target="_blank" class="layui-btn">更多例子</a> <a href="https://layui.dev/docs/2.8/layer/" target="_blank" class="layui-btn">更多例子</a>
</div> </div>
@ -215,6 +216,19 @@ layui.use(['layer', 'util'], function(layer, util){
} }
}); });
} }
,test10: function(){
layer.open({
title:'drawer',
type: 1,
offset: 'b',
anim: 'slideUp', // 从下往上
area: ['100%', '160px'],
shade: 0.1,
shadeClose: true,
content: $('#test11111'),
maxmin: true,
});
}
}); });
// 相册层 // 相册层

@ -1719,6 +1719,23 @@ layer.photos = function(options, loop, key){
ready.run = function(_$){ ready.run = function(_$){
$ = _$; $ = _$;
win = $(window); win = $(window);
// 移动端兼容性处理
// https://gitee.com/layui/layui/issues/I81WGC
// https://github.com/jquery/jquery/issues/1729
var agent = navigator.userAgent.toLowerCase();
var isMobile = /android|iphone|ipod|ipad|ios/.test(agent)
var _win = $(window);
if(isMobile){
$.each({Height: "height", Width: "width"}, function(propSuffix, funcName){
var propName = 'inner' + propSuffix;
win[funcName] = function(){
return propName in window
? window[propName]
: _win[funcName]()
}
})
}
doms.html = $('html'); doms.html = $('html');
layer.open = function(deliver){ layer.open = function(deliver){
var o = new Class(deliver); var o = new Class(deliver);

Loading…
Cancel
Save