51 lines
1.6 KiB
JavaScript
51 lines
1.6 KiB
JavaScript
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
var props_1 = require("./props");
|
|
var compareVersion_1 = require("../_util/compareVersion");
|
|
var SDKVersion = my.SDKVersion;
|
|
var isOldVersion = (0, compareVersion_1.compareVersion)(SDKVersion, '2.0.0') < 0;
|
|
var component2 = my.canIUse('component2');
|
|
Component({
|
|
props: props_1.PopupDefaultProps,
|
|
data: {
|
|
closing: false,
|
|
isOldVersion: isOldVersion,
|
|
},
|
|
didUpdate: function (prevProps) {
|
|
if (component2) {
|
|
return;
|
|
}
|
|
var _a = this.props, visible = _a.visible, duration = _a.duration, animation = _a.animation;
|
|
if (prevProps.visible && !visible) {
|
|
if (animation && duration > 0) {
|
|
this.setData({ closing: true });
|
|
}
|
|
}
|
|
},
|
|
deriveDataFromProps: function (nextProps) {
|
|
var visible = nextProps.visible, duration = nextProps.duration, animation = nextProps.animation;
|
|
if (this.props.visible && !visible) {
|
|
if (animation && duration > 0) {
|
|
this.setData({ closing: true });
|
|
}
|
|
}
|
|
},
|
|
methods: {
|
|
onTapMask: function () {
|
|
var closing = this.data.closing;
|
|
if (closing) {
|
|
return;
|
|
}
|
|
var onClose = this.props.onClose;
|
|
if (onClose) {
|
|
onClose();
|
|
}
|
|
},
|
|
onAnimationEnd: function () {
|
|
var closing = this.data.closing;
|
|
if (closing) {
|
|
this.setData({ closing: false });
|
|
}
|
|
},
|
|
},
|
|
}); |