From 6aa349b6402daa5d16c0cd72563721b1f6223ea7 Mon Sep 17 00:00:00 2001
From: morning-star <1453017105@qq.com>
Date: Tue, 19 Sep 2023 00:59:22 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=20layer=20=E7=A7=BB=E5=8A=A8?=
=?UTF-8?q?=E7=AB=AF=E5=AE=9A=E4=BD=8D=20(#1376)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
* 优化 layer 移动端定位
* update code
---
examples/layer.html | 14 ++++++++++++++
src/modules/layer.js | 17 +++++++++++++++++
2 files changed, 31 insertions(+)
diff --git a/examples/layer.html b/examples/layer.html
index ab878860..20a3e144 100644
--- a/examples/layer.html
+++ b/examples/layer.html
@@ -24,6 +24,7 @@
+
更多例子
@@ -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,
+ });
+ }
});
// 相册层
diff --git a/src/modules/layer.js b/src/modules/layer.js
index fe2aab1f..322192b1 100644
--- a/src/modules/layer.js
+++ b/src/modules/layer.js
@@ -1719,6 +1719,23 @@ layer.photos = function(options, loop, key){
ready.run = function(_$){
$ = _$;
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');
layer.open = function(deliver){
var o = new Class(deliver);