Skip to content

Commit

Permalink
chore: 同步更改 index.vue
Browse files Browse the repository at this point in the history
  • Loading branch information
daiwanxing committed Jul 19, 2024
1 parent 287ab78 commit 9645921
Showing 1 changed file with 13 additions and 22 deletions.
35 changes: 13 additions & 22 deletions src/packages/__VUE/elevator/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@
<view class="nut-elevator__list__fixed-title">{{ indexList?.[currentIndex]?.[acceptKey] }}</view>
</view>
<view v-show="scrollStart" v-if="indexList.length" class="nut-elevator__code--current">
{{
indexList[codeIndex][acceptKey]
}}
{{ indexList[codeIndex][acceptKey] }}
</view>
<view class="nut-elevator__bars" @touchstart="touchStart" @touchmove.stop.prevent="touchMove" @touchend="touchEnd">
<view class="nut-elevator__bars__inner">
Expand All @@ -36,8 +34,7 @@
@click="handleClickIndex(item[acceptKey])"
>
{{ item[acceptKey] }}
</view
>
</view>
</view>
</view>
</view>
Expand Down Expand Up @@ -96,29 +93,25 @@ export default create({
fixedTop: 0
})

const clientHeight = computed(() => {
return listview.value.clientHeight
})
const clientHeight = computed(() => listview.value.clientHeight)

const getData = (el: HTMLElement, name: string): string | void => {
const prefix = 'data-'
return el.getAttribute(prefix + name) as string
}

const setListGroup = (el: any) => {
nextTick(() => {
if (!state.listGroup.includes(el) && el != null) {
state.listGroup.push(el)
}
})
if (!state.listGroup.includes(el) && el != null) {
state.listGroup.push(el)
}
}

const calculateHeight = () => {
let height = 0
state.listHeight.push(height)
for (let i = 0; i < state.listGroup.length; i++) {
let item = state.listGroup[i]
height += Math.floor(item.clientHeight)
height += Math.round(item.clientHeight)
state.listHeight.push(height)
}
}
Expand Down Expand Up @@ -166,20 +159,18 @@ export default create({
}

const listViewScroll = (e: Event) => {
let target = e.target as Element
let scrollTop = target.scrollTop
const target = e.target as Element
const scrollTop = target.scrollTop

Check warning on line 163 in src/packages/__VUE/elevator/index.vue

View check run for this annotation

Codecov / codecov/patch

src/packages/__VUE/elevator/index.vue#L162-L163

Added lines #L162 - L163 were not covered by tests
const listHeight = state.listHeight
state.scrollY = scrollTop
state.scrollY = Math.round(scrollTop)

Check warning on line 165 in src/packages/__VUE/elevator/index.vue

View check run for this annotation

Codecov / codecov/patch

src/packages/__VUE/elevator/index.vue#L165

Added line #L165 was not covered by tests
for (let i = 0; i < listHeight.length - 1; i++) {
let height1 = listHeight[i]
let height2 = listHeight[i + 1]
if (state.scrollY >= height1 && state.scrollY < height2) {
const [startHeight, endHeight] = [listHeight[i], listHeight[i + 1]]
if (state.scrollY >= startHeight && state.scrollY < endHeight) {

Check warning on line 168 in src/packages/__VUE/elevator/index.vue

View check run for this annotation

Codecov / codecov/patch

src/packages/__VUE/elevator/index.vue#L167-L168

Added lines #L167 - L168 were not covered by tests
state.currentIndex = i
state.diff = height2 - state.scrollY
state.diff = endHeight - state.scrollY

Check warning on line 170 in src/packages/__VUE/elevator/index.vue

View check run for this annotation

Codecov / codecov/patch

src/packages/__VUE/elevator/index.vue#L170

Added line #L170 was not covered by tests
return
}
}

state.currentIndex = listHeight.length - 2
}

Expand Down

0 comments on commit 9645921

Please sign in to comment.