1
0
mirror of https://gitee.com/vant-contrib/vant.git synced 2025-04-06 03:57:59 +08:00

36 lines
707 B
JavaScript

import { use } from '../utils';
const [sfc, bem] = use('swipe-item');
export default sfc({
data() {
return {
offset: 0
};
},
beforeCreate() {
this.$parent.swipes.push(this);
},
destroyed() {
this.$parent.swipes.splice(this.$parent.swipes.indexOf(this), 1);
},
render(h) {
const { vertical, computedWidth, computedHeight } = this.$parent;
const style = {
width: computedWidth + 'px',
height: vertical ? computedHeight + 'px' : '100%',
transform: `translate${vertical ? 'Y' : 'X'}(${this.offset}px)`
};
return (
<div class={bem()} style={style} {...{ on: this.$listeners }}>
{this.slots()}
</div>
);
}
});