Merge 'master' into dev-yzy

This commit is contained in:
2022-01-21 20:04:13 +08:00
17 changed files with 712 additions and 162 deletions
+37
View File
@@ -1,3 +1,4 @@
@import "../../app.scss";
view.mask {
position: fixed;
@@ -5,4 +6,40 @@ view.mask {
height: 100%;
background-color: rgba($color: #000000, $alpha: .2);
z-index: 1;
}
view.mask.block {
display: block;
}
view.mask.none {
display: none;
}
view.mask.show {
animation: show .1s cubic-bezier(0, 0, 1, 1) both;
opacity: 1;
}
view.mask.hide {
animation: hide .1s cubic-bezier(0, 0, 1, 1) both;
opacity: 0;
}
@keyframes show{
from {
opacity: 0;
}
to {
opacity: 1;
}
}
@keyframes hide{
from {
opacity: 1;
}
to {
opacity: 0;
}
}
+82 -12
View File
@@ -1,6 +1,40 @@
import { Modular, Manager } from "../../core/Module";
class Mask<M extends Manager> extends Modular<M> {
/**
* 蒙版事件
*/
type IMaskEvent = {
/**
* 蒙版显示事件
*/
show: void;
/**
* 蒙版隐藏事件
*/
hide: void;
/**
* 蒙版状态改变事件
*/
change: boolean;
/**
* 蒙版点击事件
*/
click: void;
}
/**
* 蒙版 Modular
*/
class Mask<M extends Manager> extends Modular<M, {}, IMaskEvent> {
/**
* 动画运行时间
*/
public static readonly animateTime: number = 100;
public data? = {
@@ -9,35 +43,71 @@ class Mask<M extends Manager> extends Modular<M> {
*/
zIndex: 1,
/**
* 蒙版是否显示
*/
isDisplay: false,
/**
* 蒙版是否显示
*/
isShow: false
};
/**
* 当点击时是否自动关闭蒙版
*/
public autoCloseOnClick: boolean = true;
/**
* 消失动画计时器
*/
private disappearTimer?: number;
public override onLoad() {
this.setFunc(this.handleClickMask, "handleClickMask");
this.on("show", this.showMask);
this.on("hide", this.hideMask);
}
/**
* 显示蒙版
*/
public showMask() {
this.setData({ isShow: true });
private showMask = () => {
this.disappearTimer && clearTimeout(this.disappearTimer);
this.setData({
isShow: true,
isDisplay: true
});
this.emit("change", true);
}
/**
* 隐藏蒙版
*/
public hideMask() {
this.setData({ isShow: false });
}
public override onLoad() {
this.setFunc(this.handleClickMask, "handleClickMask");
// Do something
}
private hideMask = () => {
this.setData({
isShow: false
});
this.disappearTimer = setTimeout(() => {
this.setData({
isDisplay: false
});
}, Mask.animateTime);
this.emit("change", false);
}
/**
* 处理蒙版点击事件
*/
private handleClickMask() {
this.hideMask();
if (this.autoCloseOnClick) this.emit("hide", void 0);
this.emit("click", void 0);
}
}