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 { .poster-item {
height: 200rem; height: 200rem;
max-height: calc(33.33vw * 1.2); max-height: calc(33.33vw * 1.3);
border: 0.5px solid black; border: 0.5px solid black;
overflow: hidden; overflow: hidden;
position: relative; position: relative;

View File

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