Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Miykael_xxm
amazeui
提交
7079f049
A
amazeui
项目概览
Miykael_xxm
/
amazeui
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
A
amazeui
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
7079f049
编写于
10月 10, 2014
作者:
M
Minwe LUO
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #121 from allmobilize/codename-h
Improve PureView & OffCanvas
上级
319bc506
afd69a7c
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
52 addition
and
38 deletion
+52
-38
js/ui.offcanvas.js
js/ui.offcanvas.js
+40
-30
less/ui.offcanvas.less
less/ui.offcanvas.less
+9
-7
less/ui.pureview.less
less/ui.pureview.less
+3
-1
未找到文件。
js/ui.offcanvas.js
浏览文件 @
7079f049
define
(
function
(
require
,
exports
,
module
)
{
'
use strict
'
;
require
(
'
zepto.outerdemension
'
);
require
(
'
zepto.extend.data
'
);
require
(
'
core
'
);
...
...
@@ -21,18 +23,19 @@ define(function(require, exports, module) {
};
OffCanvas
.
DEFAULTS
=
{
duration
:
300
,
effect
:
'
overlay
'
// {push|overlay}, push is too expensive
};
OffCanvas
.
prototype
.
open
=
function
(
relatedElement
)
{
var
_self
=
this
,
$element
=
this
.
$element
,
openEvent
=
$
.
Event
(
'
open:offcanvas:amui
'
);
$element
=
this
.
$element
;
if
(
!
$element
.
length
||
$element
.
hasClass
(
'
am-active
'
))
return
;
var
effect
=
this
.
options
.
effect
,
$html
=
$
(
'
html
'
),
$body
=
$
(
'
body
'
),
$bar
=
$element
.
find
(
'
.am-offcanvas-bar
'
).
first
(),
dir
=
$bar
.
hasClass
(
'
am-offcanvas-bar-flip
'
)
?
-
1
:
1
;
...
...
@@ -42,23 +45,23 @@ define(function(require, exports, module) {
$element
.
addClass
(
'
am-active
'
);
$
html
.
css
({
'
width
'
:
'
100%
'
,
'
height
'
:
$win
.
height
()}).
addClass
(
'
am-offcanvas-page
'
);
$
body
.
css
({
width
:
window
.
innerWidth
,
height
:
$win
.
height
()}).
addClass
(
'
am-offcanvas-page
'
);
if
(
!
(
effect
===
'
overlay
'
))
{
$
html
.
css
({
'
margin-left
'
:
$bar
.
outerWidth
()
*
dir
}).
width
();
// .width() -
force redraw
$
body
.
css
({
'
margin-left
'
:
$bar
.
outerWidth
()
*
dir
}).
width
();
//
force redraw
}
$html
.
css
(
'
margin-top
'
,
scrollPos
.
y
*
-
1
);
UI
.
utils
.
debounce
(
function
()
{
setTimeout
(
function
()
{
$bar
.
addClass
(
'
am-offcanvas-bar-active
'
).
width
();
},
0
)
()
;
},
0
);
$doc
.
trigger
(
openEvent
);
$doc
.
trigger
(
'
open:offcanvas:amui
'
);
$element
.
off
(
'
.offcanvas.amui
'
).
on
(
'
click.offcanvas.amui swipe
Right.offcanvas.amui swipeLeft.offcanvas.amui
'
,
function
(
e
)
{
$element
.
off
(
'
.offcanvas.amui
'
).
on
(
'
click.offcanvas.amui swipe
.offcanvas.amui
'
,
$
.
proxy
(
function
(
e
)
{
var
$target
=
$
(
e
.
target
);
if
(
!
e
.
type
.
match
(
/swipe/
))
{
if
(
$target
.
hasClass
(
'
am-offcanvas-bar
'
))
return
;
if
(
$target
.
parents
(
'
.am-offcanvas-bar
'
).
first
().
length
)
return
;
...
...
@@ -67,48 +70,55 @@ define(function(require, exports, module) {
// https://developer.mozilla.org/zh-CN/docs/DOM/event.stopImmediatePropagation
e
.
stopImmediatePropagation
();
_self
.
close
();
});
this
.
close
();
}
,
this
)
);
$
doc
.
on
(
'
keydown.offcanvas.amui
'
,
function
(
e
)
{
$
html
.
on
(
'
keydown.offcanvas.amui
'
,
$
.
proxy
(
function
(
e
)
{
if
(
e
.
keyCode
===
27
)
{
// ESC
_self
.
close
();
this
.
close
();
}
});
}
,
this
)
);
};
OffCanvas
.
prototype
.
close
=
function
(
relatedElement
)
{
var
$html
=
$
(
'
html
'
),
$body
=
$
(
'
body
'
),
$element
=
this
.
$element
,
$bar
=
$element
.
find
(
'
.am-offcanvas-bar
'
).
first
();
if
(
!
$element
.
length
||
!
$element
.
hasClass
(
'
am-active
'
))
return
;
$element
.
trigger
(
'
close:offcanvas:amui
'
);
if
(
UI
.
support
.
transition
)
{
$html
.
one
(
UI
.
support
.
transition
.
end
,
function
()
{
$html
.
removeClass
(
'
am-offcanvas-page
'
).
css
({
'
width
'
:
''
,
'
height
'
:
''
,
'
margin-top
'
:
''
});
$element
.
removeClass
(
'
am-active
'
);
window
.
scrollTo
(
scrollPos
.
x
,
scrollPos
.
y
);
}).
css
(
'
margin-left
'
,
''
);
$doc
.
trigger
(
'
close:offcanvas:amui
'
);
UI
.
utils
.
debounce
(
function
()
{
$bar
.
removeClass
(
'
am-offcanvas-bar-active
'
);
},
0
)();
}
else
{
$html
.
removeClass
(
'
am-offcanvas-page
'
).
attr
(
'
style
'
,
''
);
function
complete
()
{
$body
.
removeClass
(
'
am-offcanvas-page
'
).
css
({
width
:
''
,
height
:
''
,
'
margin-left
'
:
''
,
'
margin-right
'
:
''
});
$element
.
removeClass
(
'
am-active
'
);
$bar
.
removeClass
(
'
am-offcanvas-bar-active
'
);
$html
.
css
(
'
margin-top
'
,
''
);
window
.
scrollTo
(
scrollPos
.
x
,
scrollPos
.
y
);
$doc
.
trigger
(
'
closed:offcanvas:amui
'
);
}
if
(
UI
.
support
.
transition
)
{
setTimeout
(
function
(){
$bar
.
removeClass
(
'
am-offcanvas-bar-active
'
);
},
0
);
$body
.
css
(
'
margin-left
'
,
''
).
one
(
UI
.
support
.
transition
.
end
,
function
()
{
complete
();
}).
emulateTransitionEnd
(
this
.
options
.
duration
);
}
else
{
complete
()
}
$element
.
off
(
'
.offcanvas.amui
'
);
$html
.
off
(
'
.offcanvas.amui
'
);
};
OffCanvas
.
prototype
.
events
=
function
()
{
$doc
.
on
(
'
click.offcanvas.amui
'
,
'
[data-am-dismiss="offcanvas"]
'
,
$
.
proxy
(
function
(
e
)
{
console
.
log
(
'
evbvvvv
'
);
e
.
preventDefault
();
this
.
close
();
},
this
));
...
...
@@ -141,8 +151,8 @@ define(function(require, exports, module) {
$doc
.
on
(
'
click.offcanvas.amui
'
,
'
[data-am-offcanvas]
'
,
function
(
e
)
{
e
.
preventDefault
();
var
$this
=
$
(
this
),
options
=
UI
.
utils
.
parseOptions
(
$this
.
attr
(
'
data-am-o
ffcanvas
'
)),
$target
=
$
(
options
.
target
||
(
this
.
href
&&
this
.
href
.
replace
(
/.*
(?=
#
[^\s]
+$
)
/
,
''
)))
;
options
=
UI
.
utils
.
parseOptions
(
$this
.
data
(
'
amO
ffcanvas
'
)),
$target
=
$
(
options
.
target
||
(
this
.
href
&&
this
.
href
.
replace
(
/.*
(?=
#
[^\s]
+$
)
/
,
''
)))
,
option
=
$target
.
data
(
'
am.offcanvas
'
)
?
'
open
'
:
options
;
Plugin
.
call
(
$target
,
option
,
this
);
...
...
less/ui.offcanvas.less
浏览文件 @
7079f049
...
...
@@ -36,10 +36,6 @@
&.am-active {
display: block;
.am-offcanvas-bar.am-offcanvas-bar-active {
.translate3d(0, 0, 0);
}
}
}
...
...
@@ -54,7 +50,9 @@
.am-offcanvas-page {
position: fixed; /* 1 */
.transition(margin-left 0.3s ease-in-out); /* 2 */
/* 2 */
-webkit-transition: margin-left 0.3s ease-in-out;
transition: margin-left 0.3s ease-in-out;
}
...
...
@@ -65,7 +63,7 @@
top: 0;
bottom: 0;
left: 0;
.translate
3d(-@offcanvas-bar-width, 0
, 0);
.translate
(-100%
, 0);
z-index: @z-index-offcanvas + 1;
width: @offcanvas-bar-width;
max-width: 100%;
...
...
@@ -92,13 +90,17 @@
.hook-offcanvas-bar;
}
.am-offcanvas.am-active .am-offcanvas-bar.am-offcanvas-bar-active {
.translate(0, 0);
}
/* .am-offcanvas-bar-flip */
.am-offcanvas-bar-flip {
left: auto;
right: 0;
.translate
3d(100%, 0
, 0);
.translate
(100%
, 0);
&:after {
right: auto;
left: 0;
...
...
less/ui.pureview.less
浏览文件 @
7079f049
...
...
@@ -107,10 +107,12 @@
}
img {
position: relative;
display: block;
// width: 100%;
max-width: 100%;
max-height: 100%;
//max-width:100%;
//height:auto;
opacity: 0;
z-index: 2;
-webkit-user-drag: none;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录