mirror of
https://gitee.com/beecue/fastbee.git
synced 2025-12-18 00:45:55 +08:00
智慧宿舍系统小程序
This commit is contained in:
@@ -0,0 +1,77 @@
|
||||
'use strict';
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
exports.setContentAnimate = void 0;
|
||||
var version_1 = require('../common/version');
|
||||
var utils_1 = require('../common/utils');
|
||||
function useAnimate(context, expanded, mounted, height) {
|
||||
var selector = '.van-collapse-item__wrapper';
|
||||
if (expanded) {
|
||||
context.animate(
|
||||
selector,
|
||||
[
|
||||
{ height: 0, ease: 'ease-in-out', offset: 0 },
|
||||
{ height: height + 'px', ease: 'ease-in-out', offset: 1 },
|
||||
{ height: 'auto', ease: 'ease-in-out', offset: 1 },
|
||||
],
|
||||
mounted ? 300 : 0,
|
||||
function () {
|
||||
context.clearAnimation(selector);
|
||||
}
|
||||
);
|
||||
return;
|
||||
}
|
||||
context.animate(
|
||||
selector,
|
||||
[
|
||||
{ height: height + 'px', ease: 'ease-in-out', offset: 0 },
|
||||
{ height: 0, ease: 'ease-in-out', offset: 1 },
|
||||
],
|
||||
300,
|
||||
function () {
|
||||
context.clearAnimation(selector);
|
||||
}
|
||||
);
|
||||
}
|
||||
function useAnimation(context, expanded, mounted, height) {
|
||||
var animation = wx.createAnimation({
|
||||
duration: 0,
|
||||
timingFunction: 'ease-in-out',
|
||||
});
|
||||
if (expanded) {
|
||||
if (height === 0) {
|
||||
animation.height('auto').top(1).step();
|
||||
} else {
|
||||
animation
|
||||
.height(height)
|
||||
.top(1)
|
||||
.step({
|
||||
duration: mounted ? 300 : 1,
|
||||
})
|
||||
.height('auto')
|
||||
.step();
|
||||
}
|
||||
context.setData({
|
||||
animation: animation.export(),
|
||||
});
|
||||
return;
|
||||
}
|
||||
animation.height(height).top(0).step({ duration: 1 }).height(0).step({
|
||||
duration: 300,
|
||||
});
|
||||
context.setData({
|
||||
animation: animation.export(),
|
||||
});
|
||||
}
|
||||
function setContentAnimate(context, expanded, mounted) {
|
||||
utils_1
|
||||
.getRect(context, '.van-collapse-item__content')
|
||||
.then(function (rect) {
|
||||
return rect.height;
|
||||
})
|
||||
.then(function (height) {
|
||||
version_1.canIUseAnimate()
|
||||
? useAnimate(context, expanded, mounted, height)
|
||||
: useAnimation(context, expanded, mounted, height);
|
||||
});
|
||||
}
|
||||
exports.setContentAnimate = setContentAnimate;
|
||||
@@ -0,0 +1,68 @@
|
||||
'use strict';
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
var component_1 = require('../common/component');
|
||||
var relation_1 = require('../common/relation');
|
||||
var animate_1 = require('./animate');
|
||||
component_1.VantComponent({
|
||||
classes: ['title-class', 'content-class'],
|
||||
relation: relation_1.useParent('collapse'),
|
||||
props: {
|
||||
name: null,
|
||||
title: null,
|
||||
value: null,
|
||||
icon: String,
|
||||
label: String,
|
||||
disabled: Boolean,
|
||||
clickable: Boolean,
|
||||
border: {
|
||||
type: Boolean,
|
||||
value: true,
|
||||
},
|
||||
isLink: {
|
||||
type: Boolean,
|
||||
value: true,
|
||||
},
|
||||
},
|
||||
data: {
|
||||
expanded: false,
|
||||
},
|
||||
mounted: function () {
|
||||
this.updateExpanded();
|
||||
this.mounted = true;
|
||||
},
|
||||
methods: {
|
||||
updateExpanded: function () {
|
||||
if (!this.parent) {
|
||||
return;
|
||||
}
|
||||
var _a = this.parent.data,
|
||||
value = _a.value,
|
||||
accordion = _a.accordion;
|
||||
var _b = this.parent.children,
|
||||
children = _b === void 0 ? [] : _b;
|
||||
var name = this.data.name;
|
||||
var index = children.indexOf(this);
|
||||
var currentName = name == null ? index : name;
|
||||
var expanded = accordion
|
||||
? value === currentName
|
||||
: (value || []).some(function (name) {
|
||||
return name === currentName;
|
||||
});
|
||||
if (expanded !== this.data.expanded) {
|
||||
animate_1.setContentAnimate(this, expanded, this.mounted);
|
||||
}
|
||||
this.setData({ index: index, expanded: expanded });
|
||||
},
|
||||
onClick: function () {
|
||||
if (this.data.disabled) {
|
||||
return;
|
||||
}
|
||||
var _a = this.data,
|
||||
name = _a.name,
|
||||
expanded = _a.expanded;
|
||||
var index = this.parent.children.indexOf(this);
|
||||
var currentName = name == null ? index : name;
|
||||
this.parent.switch(currentName, !expanded);
|
||||
},
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {
|
||||
"van-cell": "../cell/index"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
<wxs src="../wxs/utils.wxs" module="utils" />
|
||||
|
||||
<view class="van-collapse-item custom-class {{ index !== 0 ? 'van-hairline--top' : '' }}">
|
||||
<van-cell
|
||||
title="{{ title }}"
|
||||
title-class="title-class"
|
||||
icon="{{ icon }}"
|
||||
value="{{ value }}"
|
||||
label="{{ label }}"
|
||||
is-link="{{ isLink }}"
|
||||
clickable="{{ clickable }}"
|
||||
border="{{ border && expanded }}"
|
||||
class="{{ utils.bem('collapse-item__title', { disabled, expanded }) }}"
|
||||
right-icon-class="van-cell__right-icon"
|
||||
custom-class="van-cell"
|
||||
hover-class="van-cell--hover"
|
||||
bind:click="onClick"
|
||||
>
|
||||
<slot
|
||||
name="title"
|
||||
slot="title"
|
||||
/>
|
||||
<slot
|
||||
name="icon"
|
||||
slot="icon"
|
||||
/>
|
||||
<slot name="value" />
|
||||
<slot
|
||||
name="right-icon"
|
||||
slot="right-icon"
|
||||
/>
|
||||
</van-cell>
|
||||
<view
|
||||
class="{{ utils.bem('collapse-item__wrapper') }}"
|
||||
style="height: 0;"
|
||||
animation="{{ animation }}"
|
||||
>
|
||||
<view
|
||||
class="van-collapse-item__content content-class"
|
||||
>
|
||||
<slot />
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -0,0 +1 @@
|
||||
@import '../common/index.wxss';.van-collapse-item__title .van-cell__right-icon{-webkit-transform:rotate(90deg);transform:rotate(90deg);transition:-webkit-transform .3s;transition:transform .3s;transition:transform .3s,-webkit-transform .3s;transition:-webkit-transform var(--collapse-item-transition-duration,.3s);transition:transform var(--collapse-item-transition-duration,.3s);transition:transform var(--collapse-item-transition-duration,.3s),-webkit-transform var(--collapse-item-transition-duration,.3s)}.van-collapse-item__title--expanded .van-cell__right-icon{-webkit-transform:rotate(-90deg);transform:rotate(-90deg)}.van-collapse-item__title--disabled .van-cell,.van-collapse-item__title--disabled .van-cell__right-icon{color:#c8c9cc!important;color:var(--collapse-item-title-disabled-color,#c8c9cc)!important}.van-collapse-item__title--disabled .van-cell--hover{background-color:#fff!important;background-color:var(--white,#fff)!important}.van-collapse-item__wrapper{overflow:hidden}.van-collapse-item__content{padding:15px;padding:var(--collapse-item-content-padding,15px);color:#969799;color:var(--collapse-item-content-text-color,#969799);font-size:13px;font-size:var(--collapse-item-content-font-size,13px);line-height:1.5;line-height:var(--collapse-item-content-line-height,1.5);background-color:#fff;background-color:var(--collapse-item-content-background-color,#fff)}
|
||||
Reference in New Issue
Block a user