榆山数据端小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

47 lines
1.4 KiB

import baseComponent from '../helpers/baseComponent'
import classNames from '../helpers/classNames'
baseComponent({
relations: {
'../timeline-item/index': {
type: 'child',
observer() {
this.debounce(this.updateIsLastElement)
},
},
},
properties: {
prefixCls: {
type: String,
value: 'wux-timeline',
},
pending: {
type: Boolean,
value: false,
},
position: {
type: String,
value: 'left',
},
},
methods: {
updateIsLastElement() {
const elements = this.getRelationNodes('../timeline-item/index')
if (elements.length > 0) {
const lastIndex = elements.length - 1
const { pending, position } = this.data
elements.forEach((element, index) => {
const isLast = pending ? index === Math.max(0, lastIndex - 1) : index === lastIndex
const isPending = pending && index === lastIndex
element.updateIsLastElement({
index,
isLast,
isPending,
pending,
position,
})
})
}
},
},
})