first commit
This commit is contained in:
+21
@@ -0,0 +1,21 @@
|
||||
"use strict";
|
||||
var uni_modules_wotDesignUni_components_common_props = require("../common/props.js");
|
||||
const transitionProps = {
|
||||
...uni_modules_wotDesignUni_components_common_props.baseProps,
|
||||
show: uni_modules_wotDesignUni_components_common_props.makeBooleanProp(false),
|
||||
duration: {
|
||||
type: [Object, Number, Boolean],
|
||||
default: 300
|
||||
},
|
||||
lazyRender: uni_modules_wotDesignUni_components_common_props.makeBooleanProp(false),
|
||||
name: [String, Array],
|
||||
destroy: uni_modules_wotDesignUni_components_common_props.makeBooleanProp(true),
|
||||
enterClass: uni_modules_wotDesignUni_components_common_props.makeStringProp(""),
|
||||
enterActiveClass: uni_modules_wotDesignUni_components_common_props.makeStringProp(""),
|
||||
enterToClass: uni_modules_wotDesignUni_components_common_props.makeStringProp(""),
|
||||
leaveClass: uni_modules_wotDesignUni_components_common_props.makeStringProp(""),
|
||||
leaveActiveClass: uni_modules_wotDesignUni_components_common_props.makeStringProp(""),
|
||||
leaveToClass: uni_modules_wotDesignUni_components_common_props.makeStringProp(""),
|
||||
disableTouchMove: uni_modules_wotDesignUni_components_common_props.makeBooleanProp(false)
|
||||
};
|
||||
exports.transitionProps = transitionProps;
|
||||
+195
@@ -0,0 +1,195 @@
|
||||
"use strict";
|
||||
var common_vendor = require("../../../../common/vendor.js");
|
||||
var uni_modules_wotDesignUni_components_common_util = require("../common/util.js");
|
||||
var uni_modules_wotDesignUni_components_wdTransition_types = require("./types.js");
|
||||
var uni_modules_wotDesignUni_components_common_AbortablePromise = require("../common/AbortablePromise.js");
|
||||
require("../common/props.js");
|
||||
const __default__ = {
|
||||
name: "wd-transition",
|
||||
options: {
|
||||
addGlobalClass: true,
|
||||
virtualHost: true,
|
||||
styleIsolation: "shared"
|
||||
}
|
||||
};
|
||||
const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
|
||||
...__default__,
|
||||
props: uni_modules_wotDesignUni_components_wdTransition_types.transitionProps,
|
||||
emits: ["click", "before-enter", "enter", "before-leave", "leave", "after-leave", "after-enter"],
|
||||
setup(__props, { emit }) {
|
||||
const props = __props;
|
||||
const getClassNames = (name) => {
|
||||
let enter2 = `${props.enterClass} ${props.enterActiveClass}`;
|
||||
let enterTo = `${props.enterToClass} ${props.enterActiveClass}`;
|
||||
let leave2 = `${props.leaveClass} ${props.leaveActiveClass}`;
|
||||
let leaveTo = `${props.leaveToClass} ${props.leaveActiveClass}`;
|
||||
if (Array.isArray(name)) {
|
||||
for (let index = 0; index < name.length; index++) {
|
||||
enter2 = `wd-${name[index]}-enter wd-${name[index]}-enter-active ${enter2}`;
|
||||
enterTo = `wd-${name[index]}-enter-to wd-${name[index]}-enter-active ${enterTo}`;
|
||||
leave2 = `wd-${name[index]}-leave wd-${name[index]}-leave-active ${leave2}`;
|
||||
leaveTo = `wd-${name[index]}-leave-to wd-${name[index]}-leave-active ${leaveTo}`;
|
||||
}
|
||||
} else if (name) {
|
||||
enter2 = `wd-${name}-enter wd-${name}-enter-active ${enter2}`;
|
||||
enterTo = `wd-${name}-enter-to wd-${name}-enter-active ${enterTo}`;
|
||||
leave2 = `wd-${name}-leave wd-${name}-leave-active ${leave2}`;
|
||||
leaveTo = `wd-${name}-leave-to wd-${name}-leave-active ${leaveTo}`;
|
||||
}
|
||||
return {
|
||||
enter: enter2,
|
||||
"enter-to": enterTo,
|
||||
leave: leave2,
|
||||
"leave-to": leaveTo
|
||||
};
|
||||
};
|
||||
const inited = common_vendor.ref(false);
|
||||
const display = common_vendor.ref(false);
|
||||
const status = common_vendor.ref("");
|
||||
const transitionEnded = common_vendor.ref(false);
|
||||
const currentDuration = common_vendor.ref(300);
|
||||
const classes = common_vendor.ref("");
|
||||
const enterPromise = common_vendor.ref(null);
|
||||
const enterLifeCyclePromises = common_vendor.ref(null);
|
||||
const leaveLifeCyclePromises = common_vendor.ref(null);
|
||||
const style = common_vendor.computed$1(() => {
|
||||
return `-webkit-transition-duration:${currentDuration.value}ms;transition-duration:${currentDuration.value}ms;${display.value || !props.destroy ? "" : "display: none;"}${props.customStyle}`;
|
||||
});
|
||||
const rootClass = common_vendor.computed$1(() => {
|
||||
return `wd-transition ${props.customClass} ${classes.value}`;
|
||||
});
|
||||
const isShow = common_vendor.computed$1(() => {
|
||||
return !props.lazyRender || inited.value;
|
||||
});
|
||||
common_vendor.onBeforeMount(() => {
|
||||
if (props.show) {
|
||||
enter();
|
||||
}
|
||||
});
|
||||
common_vendor.watch(
|
||||
() => props.show,
|
||||
(newVal) => {
|
||||
handleShow(newVal);
|
||||
},
|
||||
{ deep: true }
|
||||
);
|
||||
function handleClick() {
|
||||
emit("click");
|
||||
}
|
||||
function handleShow(value) {
|
||||
if (value) {
|
||||
handleAbortPromise();
|
||||
enter();
|
||||
} else {
|
||||
leave();
|
||||
}
|
||||
}
|
||||
function handleAbortPromise() {
|
||||
uni_modules_wotDesignUni_components_common_util.isPromise(enterPromise.value) && enterPromise.value.abort();
|
||||
uni_modules_wotDesignUni_components_common_util.isPromise(enterLifeCyclePromises.value) && enterLifeCyclePromises.value.abort();
|
||||
uni_modules_wotDesignUni_components_common_util.isPromise(leaveLifeCyclePromises.value) && leaveLifeCyclePromises.value.abort();
|
||||
enterPromise.value = null;
|
||||
enterLifeCyclePromises.value = null;
|
||||
leaveLifeCyclePromises.value = null;
|
||||
}
|
||||
function enter() {
|
||||
enterPromise.value = new uni_modules_wotDesignUni_components_common_AbortablePromise.AbortablePromise(async (resolve) => {
|
||||
try {
|
||||
const classNames = getClassNames(props.name);
|
||||
const duration = uni_modules_wotDesignUni_components_common_util.isObj(props.duration) ? props.duration.enter : props.duration;
|
||||
status.value = "enter";
|
||||
emit("before-enter");
|
||||
enterLifeCyclePromises.value = uni_modules_wotDesignUni_components_common_util.pause();
|
||||
await enterLifeCyclePromises.value;
|
||||
emit("enter");
|
||||
classes.value = classNames.enter;
|
||||
currentDuration.value = duration;
|
||||
enterLifeCyclePromises.value = uni_modules_wotDesignUni_components_common_util.pause();
|
||||
await enterLifeCyclePromises.value;
|
||||
inited.value = true;
|
||||
display.value = true;
|
||||
enterLifeCyclePromises.value = uni_modules_wotDesignUni_components_common_util.pause();
|
||||
await enterLifeCyclePromises.value;
|
||||
enterLifeCyclePromises.value = null;
|
||||
transitionEnded.value = false;
|
||||
classes.value = classNames["enter-to"];
|
||||
resolve();
|
||||
} catch (error) {
|
||||
}
|
||||
});
|
||||
}
|
||||
async function leave() {
|
||||
if (!enterPromise.value) {
|
||||
transitionEnded.value = false;
|
||||
return onTransitionEnd();
|
||||
}
|
||||
try {
|
||||
await enterPromise.value;
|
||||
if (!display.value)
|
||||
return;
|
||||
const classNames = getClassNames(props.name);
|
||||
const duration = uni_modules_wotDesignUni_components_common_util.isObj(props.duration) ? props.duration.leave : props.duration;
|
||||
status.value = "leave";
|
||||
emit("before-leave");
|
||||
currentDuration.value = duration;
|
||||
leaveLifeCyclePromises.value = uni_modules_wotDesignUni_components_common_util.pause();
|
||||
await leaveLifeCyclePromises.value;
|
||||
emit("leave");
|
||||
classes.value = classNames.leave;
|
||||
leaveLifeCyclePromises.value = uni_modules_wotDesignUni_components_common_util.pause();
|
||||
await leaveLifeCyclePromises.value;
|
||||
transitionEnded.value = false;
|
||||
classes.value = classNames["leave-to"];
|
||||
leaveLifeCyclePromises.value = setPromise(currentDuration.value);
|
||||
await leaveLifeCyclePromises.value;
|
||||
leaveLifeCyclePromises.value = null;
|
||||
onTransitionEnd();
|
||||
enterPromise.value = null;
|
||||
} catch (error) {
|
||||
}
|
||||
}
|
||||
function setPromise(duration) {
|
||||
return new uni_modules_wotDesignUni_components_common_AbortablePromise.AbortablePromise((resolve) => {
|
||||
const timer = setTimeout(() => {
|
||||
clearTimeout(timer);
|
||||
resolve();
|
||||
}, duration);
|
||||
});
|
||||
}
|
||||
function onTransitionEnd() {
|
||||
if (transitionEnded.value)
|
||||
return;
|
||||
transitionEnded.value = true;
|
||||
if (status.value === "leave") {
|
||||
emit("after-leave");
|
||||
} else if (status.value === "enter") {
|
||||
emit("after-enter");
|
||||
}
|
||||
if (!props.show && display.value) {
|
||||
display.value = false;
|
||||
}
|
||||
}
|
||||
function noop() {
|
||||
}
|
||||
return (_ctx, _cache) => {
|
||||
return common_vendor.e({
|
||||
a: common_vendor.unref(isShow) && _ctx.disableTouchMove
|
||||
}, common_vendor.unref(isShow) && _ctx.disableTouchMove ? {
|
||||
b: common_vendor.n(common_vendor.unref(rootClass)),
|
||||
c: common_vendor.s(common_vendor.unref(style)),
|
||||
d: common_vendor.o(onTransitionEnd),
|
||||
e: common_vendor.o(handleClick),
|
||||
f: common_vendor.o(noop)
|
||||
} : common_vendor.unref(isShow) && !_ctx.disableTouchMove ? {
|
||||
h: common_vendor.n(common_vendor.unref(rootClass)),
|
||||
i: common_vendor.s(common_vendor.unref(style)),
|
||||
j: common_vendor.o(onTransitionEnd),
|
||||
k: common_vendor.o(handleClick)
|
||||
} : {}, {
|
||||
g: common_vendor.unref(isShow) && !_ctx.disableTouchMove
|
||||
});
|
||||
};
|
||||
}
|
||||
});
|
||||
var Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-433f2aff"], ["__file", "D:/\u7F51\u6291\u4E91Time/\u79C1\u6D3B/2000\u7B97\u5366/src/uni_modules/wot-design-uni/components/wd-transition/wd-transition.vue"]]);
|
||||
wx.createComponent(Component);
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {}
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
<view wx:if="{{a}}" class="{{['data-v-433f2aff', b]}}" style="{{c}}" bindtransitionend="{{d}}" bindtap="{{e}}" catchtouchmove="{{f}}"><slot/></view><view wx:elif="{{g}}" class="{{['data-v-433f2aff', h]}}" style="{{i}}" bindtransitionend="{{j}}" bindtap="{{k}}"><slot/></view>
|
||||
+106
@@ -0,0 +1,106 @@
|
||||
/**
|
||||
* 这里是uni-app内置的常用样式变量
|
||||
*
|
||||
* uni-app 官方扩展插件及插件市场(https://ext.dcloud.net.cn)上很多三方插件均使用了这些样式变量
|
||||
* 如果你是插件开发者,建议你使用scss预处理,并在插件代码中直接使用这些变量(无需 import 这个文件),方便用户通过搭积木的方式开发整体风格一致的App
|
||||
*
|
||||
*/
|
||||
/**
|
||||
* 如果你是App开发者(插件使用者),你可以通过修改这些变量来定制自己的插件主题,实现自定义主题功能
|
||||
*
|
||||
* 如果你的项目同样使用了scss预处理,你也可以直接在你的 scss 代码中使用如下变量,同时无需 import 这个文件
|
||||
*/
|
||||
/* 颜色变量 */
|
||||
/* 行为相关颜色 */
|
||||
/* 文字基本颜色 */
|
||||
/* 背景颜色 */
|
||||
/* 边框颜色 */
|
||||
/* 尺寸变量 */
|
||||
/* 文字尺寸 */
|
||||
/* 图片尺寸 */
|
||||
/* Border Radius */
|
||||
/* 水平间距 */
|
||||
/* 垂直间距 */
|
||||
/* 透明度 */
|
||||
/* 文章场景相关 */
|
||||
.wd-transition.data-v-433f2aff {
|
||||
transition-timing-function: ease;
|
||||
}
|
||||
.wd-fade-enter.data-v-433f2aff,
|
||||
.wd-fade-leave-to.data-v-433f2aff {
|
||||
opacity: 0;
|
||||
}
|
||||
.wd-fade-enter-active.data-v-433f2aff,
|
||||
.wd-fade-leave-active.data-v-433f2aff {
|
||||
transition-property: opacity;
|
||||
}
|
||||
.wd-fade-up-enter.data-v-433f2aff,
|
||||
.wd-fade-up-leave-to.data-v-433f2aff {
|
||||
transform: translate3d(0, 100%, 0);
|
||||
opacity: 0;
|
||||
}
|
||||
.wd-fade-down-enter.data-v-433f2aff,
|
||||
.wd-fade-down-leave-to.data-v-433f2aff {
|
||||
transform: translate3d(0, -100%, 0);
|
||||
opacity: 0;
|
||||
}
|
||||
.wd-fade-left-enter.data-v-433f2aff,
|
||||
.wd-fade-left-leave-to.data-v-433f2aff {
|
||||
transform: translate3d(-100%, 0, 0);
|
||||
opacity: 0;
|
||||
}
|
||||
.wd-fade-right-enter.data-v-433f2aff,
|
||||
.wd-fade-right-leave-to.data-v-433f2aff {
|
||||
transform: translate3d(100%, 0, 0);
|
||||
opacity: 0;
|
||||
}
|
||||
.wd-slide-up-enter.data-v-433f2aff,
|
||||
.wd-slide-up-leave-to.data-v-433f2aff {
|
||||
transform: translate3d(0, 100%, 0);
|
||||
}
|
||||
.wd-slide-down-enter.data-v-433f2aff,
|
||||
.wd-slide-down-leave-to.data-v-433f2aff {
|
||||
transform: translate3d(0, -100%, 0);
|
||||
}
|
||||
.wd-slide-left-enter.data-v-433f2aff,
|
||||
.wd-slide-left-leave-to.data-v-433f2aff {
|
||||
transform: translate3d(-100%, 0, 0);
|
||||
}
|
||||
.wd-slide-right-enter.data-v-433f2aff,
|
||||
.wd-slide-right-leave-to.data-v-433f2aff {
|
||||
transform: translate3d(100%, 0, 0);
|
||||
}
|
||||
.wd-zoom-in-enter.data-v-433f2aff,
|
||||
.wd-zoom-in-leave-to.data-v-433f2aff {
|
||||
opacity: 0;
|
||||
transform: scale(0.8);
|
||||
}
|
||||
.wd-zoom-out-enter.data-v-433f2aff,
|
||||
.wd-zoom-out-leave-to.data-v-433f2aff {
|
||||
transform: scale(1.2);
|
||||
opacity: 0;
|
||||
}
|
||||
.wd-zoom-in-enter-active.data-v-433f2aff,
|
||||
.wd-zoom-in-leave-active.data-v-433f2aff,
|
||||
.wd-zoom-out-enter-active.data-v-433f2aff,
|
||||
.wd-zoom-out-leave-active.data-v-433f2aff,
|
||||
.wd-fade-up-enter-active.data-v-433f2aff,
|
||||
.wd-fade-up-leave-active.data-v-433f2aff,
|
||||
.wd-fade-down-enter-active.data-v-433f2aff,
|
||||
.wd-fade-down-leave-active.data-v-433f2aff,
|
||||
.wd-fade-left-enter-active.data-v-433f2aff,
|
||||
.wd-fade-left-leave-active.data-v-433f2aff,
|
||||
.wd-fade-right-enter-active.data-v-433f2aff,
|
||||
.wd-fade-right-leave-active.data-v-433f2aff {
|
||||
transition-property: opacity, transform;
|
||||
}
|
||||
.wd-slide-up-enter-active.data-v-433f2aff,
|
||||
.wd-slide-up-leave-active.data-v-433f2aff,
|
||||
.wd-slide-down-enter-active.data-v-433f2aff,
|
||||
.wd-slide-down-leave-active.data-v-433f2aff,
|
||||
.wd-slide-left-enter-active.data-v-433f2aff,
|
||||
.wd-slide-left-leave-active.data-v-433f2aff,
|
||||
.wd-slide-right-enter-active.data-v-433f2aff,
|
||||
.wd-slide-right-leave-active.data-v-433f2aff {
|
||||
transition-property: transform;
|
||||
}
|
||||
Reference in New Issue
Block a user