From 5c906b4644422459aa842751c180ec8d84bdd6bd Mon Sep 17 00:00:00 2001 From: chenjinsong <523037378@qq.com> Date: Mon, 11 Apr 2022 15:58:24 +0800 Subject: [PATCH] =?UTF-8?q?CN-430=20feat:=20=E6=95=B4=E5=B1=8F=E6=BB=9A?= =?UTF-8?q?=E5=8A=A8=E9=A2=84=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/constants.js | 5 ++ src/utils/tools.js | 32 ++++++++++ src/views/charts/Panel.vue | 58 +++++++++++++++---- src/views/charts/PanelChartList.vue | 17 +++++- .../charts/wholeScreenScroll/DnsScreen.vue | 9 +++ 5 files changed, 110 insertions(+), 11 deletions(-) create mode 100644 src/views/charts/wholeScreenScroll/DnsScreen.vue diff --git a/src/utils/constants.js b/src/utils/constants.js index d118344c..f38e7d44 100644 --- a/src/utils/constants.js +++ b/src/utils/constants.js @@ -197,6 +197,11 @@ export const dnsServerRole = { RTDNSM: 'RTDNSM' } +// 整屏滚动的路径映射 +export const wholeScreenRouterMapping = { + dns: '/panel/dnsServiceInsights' +} + export const themeData = [ { value: 'light', label: 'light' }, { value: 'dark', label: 'dark' } diff --git a/src/utils/tools.js b/src/utils/tools.js index c7f94b24..21e7e25d 100644 --- a/src/utils/tools.js +++ b/src/utils/tools.js @@ -652,3 +652,35 @@ export function arrayIsEqual (arr1, arr2) { } } } + +export function scrollToTop (dom, toTop, duration, direction) { + const clientHeight = dom.clientHeight + const currentTop = dom.scrollTop + const totalScrollDistance = Math.abs(currentTop - toTop) + let scrollY = currentTop + let oldTimestamp = null + + function step (newTimestamp) { + if (oldTimestamp !== null) { + if (direction === 'up') { + scrollY -= totalScrollDistance * (newTimestamp - oldTimestamp) / duration + console.info(scrollY) + if (scrollY < 0) { + dom.scrollTop = 0 + return + } + dom.scrollTop = scrollY + } else if (direction === 'down') { + scrollY += totalScrollDistance * (newTimestamp - oldTimestamp) / duration + if (scrollY > clientHeight) { + dom.scrollTop = clientHeight + return + } + dom.scrollTop = scrollY + } + } + oldTimestamp = newTimestamp + window.requestAnimationFrame(step) + } + window.requestAnimationFrame(step) +} diff --git a/src/views/charts/Panel.vue b/src/views/charts/Panel.vue index 0f2ab89e..05697a68 100644 --- a/src/views/charts/Panel.vue +++ b/src/views/charts/Panel.vue @@ -1,5 +1,5 @@