From 5005bf2f06846b8f7a26053e2bd6d7c0bc6390b3 Mon Sep 17 00:00:00 2001 From: guoyue Date: Mon, 27 Jun 2022 14:47:23 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AE=97=E6=B3=95=E5=AF=B9=E6=AF=94=EF=BC=9A?= =?UTF-8?q?=E5=B7=A6=E5=86=8C=E5=AF=BC=E8=88=AA=E8=B7=9F=E5=8F=B3=E4=BE=A7?= =?UTF-8?q?=E6=BB=9A=E5=8A=A8=E8=81=94=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- front/src/views/home/algorithmCompare.vue | 72 +++++++++++------------ 1 file changed, 33 insertions(+), 39 deletions(-) diff --git a/front/src/views/home/algorithmCompare.vue b/front/src/views/home/algorithmCompare.vue index c1e32113..f381a4ae 100644 --- a/front/src/views/home/algorithmCompare.vue +++ b/front/src/views/home/algorithmCompare.vue @@ -31,7 +31,7 @@ -
+
{{ data.title }}
@@ -101,12 +101,10 @@ import { pageWithAttrs } from '@/api/abilityStatistics' import { defineComponent, ref, onMounted, getCurrentInstance, computed, unref, reactive, nextTick } from 'vue'; import { selectOne } from '@/api/home' import { message, Tooltip, Table, Spin } from 'ant-design-vue' -import { useRouter } from 'vue-router' +import { useRouter } from 'vue-router'; const router = useRouter() let queryId = router.currentRoute.value.query.id; - -console.log('111---->', router) const ctx = getCurrentInstance(); // 最大4列 @@ -277,13 +275,40 @@ onMounted(() => { getList().then(res => { initData() }) - // 滚动条 - window.addEventListener('scroll', handleScroll, true) }) - - }) +// 滚动事件 +const scrollAction = (event) => { + isScrollFlag.value = true; + if (!isScrollFlag.value) { + rrturn + } + const _scrollTop = event.target.scrollTop + nextTick(() => { + let len = navScrollTopArray.value.length; + let min = navScrollTopArray.value[1].scrollTop + let max = navScrollTopArray.value[len - 2].scrollTop; + for (let index = 0; index < navScrollTopArray.value.length; index++) { + const item = navScrollTopArray.value[index]; + if (index < len - 1) { + if (_scrollTop > item.scrollTop && _scrollTop <= navScrollTopArray.value[index + 1].scrollTop) { + activeNameIndex.value = index + 1; + break; + } + } + if (_scrollTop >= max) { + activeNameIndex.value = len - 1; + break; + } + if (_scrollTop <= min) { + activeNameIndex.value = 0; + break; + } + } + }) +} + let navScrollTopArray = ref([]) // 获取元素距离顶部的位置 const getNavscrollTop = () => { @@ -297,36 +322,6 @@ const getNavscrollTop = () => { }) } -// 滚动 -const handleScroll = () => { - isScrollFlag.value = true; - if(isScrollFlag.value) { - let _scrollTop = ctx.refs.bottomRef && ctx.refs.bottomRef.scrollTop; - nextTick(() => { - let len = navScrollTopArray.value.length; - let min = navScrollTopArray.value[1].scrollTop - let max = navScrollTopArray.value[len - 2].scrollTop; - for (let index = 0; index < navScrollTopArray.value.length; index++) { - const item = navScrollTopArray.value[index]; - if (index < len - 1) { - if (_scrollTop > item.scrollTop && _scrollTop < navScrollTopArray.value[index + 1].scrollTop) { - activeNameIndex.value = index + 1; - break; - } - } - if (_scrollTop >= max) { - activeNameIndex.value = len - 1; - break; - } - if (_scrollTop <= min) { - activeNameIndex.value = 0; - break; - } - } - }) - } -} - let isScrollFlag = ref(false) // 切换左侧 const changeTab = (n, data) => { @@ -334,7 +329,6 @@ const changeTab = (n, data) => { activeNameIndex.value = n; // 获取元素距离父元素的距离 let realTop = ctx.refs[data][0].offsetTop; - console.log('realTop------------>', realTop); if (realTop || realTop === 0) { ctx.refs.bottomRef.scrollTo({ 'top': realTop - 240,