Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
wanjj_1210
ant-design
提交
7ae96687
A
ant-design
项目概览
wanjj_1210
/
ant-design
与 Fork 源项目一致
从无法访问的项目Fork
通知
10
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
A
ant-design
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
7ae96687
编写于
1月 12, 2016
作者:
B
Benjy Cui
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: cyclic reference in Modal
上级
997db86d
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
78 addition
and
75 deletion
+78
-75
components/modal/Modal.jsx
components/modal/Modal.jsx
+76
-0
components/modal/confirm.jsx
components/modal/confirm.jsx
+1
-1
components/modal/index.jsx
components/modal/index.jsx
+1
-74
未找到文件。
components/modal/Modal.jsx
0 → 100644
浏览文件 @
7ae96687
import
React
from
'
react
'
;
import
Dialog
from
'
rc-dialog
'
;
import
{
Dom
}
from
'
rc-util
'
;
import
Button
from
'
../button
'
;
function
noop
()
{}
let
mousePosition
;
let
mousePositionEventBinded
;
let
AntModal
=
React
.
createClass
({
getDefaultProps
()
{
return
{
prefixCls
:
'
ant-modal
'
,
onOk
:
noop
,
onCancel
:
noop
,
okText
:
'
确定
'
,
cancelText
:
'
取消
'
,
width
:
520
,
transitionName
:
'
zoom
'
,
maskAnimation
:
'
fade
'
,
confirmLoading
:
false
,
visible
:
false
};
},
handleCancel
()
{
this
.
props
.
onCancel
();
},
handleOk
()
{
this
.
props
.
onOk
();
},
componentDidMount
()
{
if
(
mousePositionEventBinded
)
{
return
;
}
// 只有点击事件支持从鼠标位置动画展开
Dom
.
addEventListener
(
document
.
body
,
'
click
'
,
function
onDocumentMousemove
(
e
)
{
mousePosition
=
{
x
:
e
.
pageX
,
y
:
e
.
pageY
};
// 20ms 内发生过点击事件,则从点击位置动画展示
// 否则直接 zoom 展示
// 这样可以兼容非点击方式展开
setTimeout
(()
=>
mousePosition
=
null
,
20
);
});
mousePositionEventBinded
=
true
;
},
render
()
{
let
props
=
this
.
props
;
let
defaultFooter
=
[
<
Button
key
=
"cancel"
type
=
"ghost"
size
=
"large"
onClick
=
{
this
.
handleCancel
}
>
{
props
.
cancelText
}
</
Button
>,
<
Button
key
=
"confirm"
type
=
"primary"
size
=
"large"
loading
=
{
props
.
confirmLoading
}
onClick
=
{
this
.
handleOk
}
>
{
props
.
okText
}
</
Button
>
];
let
footer
=
props
.
footer
||
defaultFooter
;
return
<
Dialog
onClose
=
{
this
.
handleCancel
}
footer
=
{
footer
}
{
...
props
}
visible
=
{
props
.
visible
}
mousePosition
=
{
mousePosition
}
/>;
}
});
export
default
AntModal
;
components/modal/confirm.jsx
浏览文件 @
7ae96687
import
React
from
'
react
'
;
import
ReactDOM
from
'
react-dom
'
;
import
Dialog
from
'
./
index
'
;
import
Dialog
from
'
./
modal
'
;
import
Icon
from
'
../icon
'
;
import
Button
from
'
../button
'
;
...
...
components/modal/index.jsx
浏览文件 @
7ae96687
import
React
from
'
react
'
;
import
Dialog
from
'
rc-dialog
'
;
import
{
Dom
}
from
'
rc-util
'
;
import
AntModal
from
'
./Modal
'
;
import
confirm
from
'
./confirm
'
;
import
Button
from
'
../button
'
;
function
noop
()
{}
let
mousePosition
;
let
mousePositionEventBinded
;
let
AntModal
=
React
.
createClass
({
getDefaultProps
()
{
return
{
prefixCls
:
'
ant-modal
'
,
onOk
:
noop
,
onCancel
:
noop
,
okText
:
'
确定
'
,
cancelText
:
'
取消
'
,
width
:
520
,
transitionName
:
'
zoom
'
,
maskAnimation
:
'
fade
'
,
confirmLoading
:
false
,
visible
:
false
};
},
handleCancel
()
{
this
.
props
.
onCancel
();
},
handleOk
()
{
this
.
props
.
onOk
();
},
componentDidMount
()
{
if
(
mousePositionEventBinded
)
{
return
;
}
// 只有点击事件支持从鼠标位置动画展开
Dom
.
addEventListener
(
document
.
body
,
'
click
'
,
function
onDocumentMousemove
(
e
)
{
mousePosition
=
{
x
:
e
.
pageX
,
y
:
e
.
pageY
};
// 20ms 内发生过点击事件,则从点击位置动画展示
// 否则直接 zoom 展示
// 这样可以兼容非点击方式展开
setTimeout
(()
=>
mousePosition
=
null
,
20
);
});
mousePositionEventBinded
=
true
;
},
render
()
{
let
props
=
this
.
props
;
let
defaultFooter
=
[
<
Button
key
=
"cancel"
type
=
"ghost"
size
=
"large"
onClick
=
{
this
.
handleCancel
}
>
{
props
.
cancelText
}
</
Button
>,
<
Button
key
=
"confirm"
type
=
"primary"
size
=
"large"
loading
=
{
props
.
confirmLoading
}
onClick
=
{
this
.
handleOk
}
>
{
props
.
okText
}
</
Button
>
];
let
footer
=
props
.
footer
||
defaultFooter
;
return
<
Dialog
onClose
=
{
this
.
handleCancel
}
footer
=
{
footer
}
{
...
props
}
visible
=
{
props
.
visible
}
mousePosition
=
{
mousePosition
}
/>;
}
});
AntModal
.
info
=
function
(
props
)
{
props
.
iconClassName
=
'
info-circle
'
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录