-
Notifications
You must be signed in to change notification settings - Fork 379
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Dialog): Dialog组件支持自定义弹窗打开/关闭动画原点 (#2056)
Co-authored-by: lion <[email protected]>
- Loading branch information
Showing
6 changed files
with
104 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
export const enum DialogPosition { | ||
auto = 'auto', | ||
center = 'center', | ||
} | ||
|
||
export type IDialogPositionType = keyof typeof DialogPosition; | ||
|
||
/** | ||
* 根据传入的 position 参数,计算出弹窗的 transformOrigin 属性值 | ||
* @param position 弹窗位置,可选值为auto、center | ||
* @param el 弹窗元素 | ||
* @returns 返回 transformOrigin 属性值 | ||
*/ | ||
export const getPositionTransformOrigin = ( | ||
position?: IDialogPositionType, | ||
_el?: HTMLDivElement // 后续增加其他位置信息,需要使用 el 计算位置 | ||
) => { | ||
switch (position) { | ||
case DialogPosition.center: | ||
return 'center center 0'; | ||
case DialogPosition.auto: | ||
default: | ||
return undefined; | ||
} | ||
}; |