refactor: refactor code and add comment

This commit is contained in:
zyronon 2024-04-24 02:32:47 +08:00
parent 942ae76a0d
commit 15b89986b2
2 changed files with 22 additions and 17 deletions

View File

@ -92,7 +92,7 @@ function getMonth(time) {
.poster-item {
height: 200rem;
max-height: calc(33.33vw * 1.2);
max-height: calc(33.33vw * 1.3);
border: 0.5px solid black;
overflow: hidden;
position: relative;

View File

@ -78,27 +78,32 @@ watch(
() => props.list,
(newVal, oldVal) => {
// console.log('watch-list', newVal.length, oldVal.length, newVal)
//
//
if (newVal.length < oldVal.length) {
insertContent()
} else {
//
if (oldVal.length === 0) {
insertContent()
} else {
let lastSlideItem = wrapperEl.value.querySelector(`.${itemClassName}:last-child`)
let top = _css(lastSlideItem, 'top')
let lastIndex = Number(lastSlideItem.getAttribute('data-index')) + 1
// console.log('lastIndex', lastIndex)
newVal.slice(lastIndex, lastIndex + 3).map((item, index) => {
let el = getInsEl(item, lastIndex + index)
//top
//2022-3-27slide-itemtop
//top
// top
_css(el, 'top', top)
wrapperEl.value.appendChild(el)
state.wrapper.childrenLength++
})
//
// 使
// 3html538dom
// domvirtualTotal/2+1
// let lastSlideItem = wrapperEl.value.querySelector(`.${itemClassName}:last-child`)
// let top = _css(lastSlideItem, 'top')
// let newListStartIndex = Number(lastSlideItem.getAttribute('data-index')) + 1
// // console.log('newListStartIndex', newListStartIndex)
// newVal.slice(newListStartIndex, newListStartIndex + 3).map((item, index) => {
// let el = getInsEl(item, newListStartIndex + index)
// //top
// //2022-3-27slide-itemtop
// //top
// // top
// _css(el, 'top', top)
// wrapperEl.value.appendChild(el)
// state.wrapper.childrenLength++
// })
}
}
}
@ -129,6 +134,7 @@ watch(
watch(
() => props.active,
(newVal) => {
//list
if (newVal && !props.list.length) {
return emit('refresh')
}
@ -147,7 +153,6 @@ watch(
onMounted(() => {
slideInit(wrapperEl.value, state)
insertContent()
})
function insertContent(list = props.list) {