Commit 56a52f8f by zhaochengxiang

资产滚动

parent 42a4b586
import React,{ useState, useEffect, useRef } from "react";
import { Button, Pagination, Space, Modal, Input, Table, Tooltip, Checkbox, Typography, Dropdown, Menu } from "antd";
import classNames from 'classnames';
import SmoothScroll from 'smooth-scroll';
import { Resizable } from 'react-resizable';
import ResizeObserver from 'rc-resize-observer';
import { useContextMenu, Menu as RcMenu, Item as RcItem } from "react-contexify";
......@@ -192,9 +191,6 @@ const AssetTable = (props) => {
setCheckedKeys([]);
if (shouldScrollRef.current === true) {
shouldScrollRef.current = false;
if (remoteRelationRef.current) {
getDataAssetLocationByRelation();
} else {
......@@ -225,20 +221,6 @@ const AssetTable = (props) => {
//eslint-disable-next-line react-hooks/exhaustive-deps
}, [ keyword, pagination, elementsChanged, assetActionChanged, recursive, fullSearch ])
useEffect(() => {
if (shouldScrollRef.current) {
SmoothScroll('a[href*="#"]');
var scroll = new SmoothScroll();
var anchor = document.querySelector(`#data-asset-${anchorId}`);
if (anchor) {
scroll.animateScroll(anchor);
shouldScrollRef.current = false;
}
}
})
const storageChange = (e) => {
if (e.key === 'assetRelationOnClickEvent') {
remoteRelationRef.current = e.relation;
......@@ -460,6 +442,22 @@ const AssetTable = (props) => {
setAssets(_assets);
if (shouldScrollRef.current) {
let scrollId = null;
if (remoteRelationRef.current) {
scrollId = remoteRelationRef.current.dataAssetId;
} else {
scrollId = anchorId;
}
shouldScrollRef.current = false;
setTimeout(() => {
var anchor = document.querySelector(`#data-asset-${scrollId}`);
anchor?.scrollIntoView();
}, 500)
}
if (reference === AssetManageReference) {
if (remoteRelationRef.current) {
const index = _assets.findIndex((asset) => asset.id === remoteRelationRef.current.dataAssetId);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment