Skip to content
This repository has been archived by the owner on Feb 2, 2024. It is now read-only.

[Batch Viewer] Zoom and drag improvements #103

Merged
merged 5 commits into from
Jun 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
"bn.js": "^4.11.9",
"combine-reducers": "^1.0.0",
"cytoscape": "^3.21.0",
"cytoscape-no-overlap": "^1.0.1",
"cytoscape-popper": "^2.0.0",
"date-fns": "^2.9.0",
"detect-browser": "^5.1.0",
Expand Down Expand Up @@ -129,6 +130,7 @@
"@types/bn.js": "^4.11.6",
"@types/combine-reducers": "^1.0.0",
"@types/cytoscape": "^3.19.4",
"@types/cytoscape-popper": "^2.0.0",
"@types/enzyme": "^3.10.4",
"@types/enzyme-adapter-react-16": "^1.0.5",
"@types/hapi__joi": "^16.0.12",
Expand All @@ -142,7 +144,6 @@
"@types/react-router-dom": "^5.1.3",
"@types/styled-components": "^5.0.1",
"@types/webpack-env": "^1.15.2",
"@types/cytoscape-popper": "^2.0.0",
"@typescript-eslint/eslint-plugin": "^4.3.0",
"@typescript-eslint/parser": "^4.3.0",
"babel-jest": "^26.1.0",
Expand Down
4 changes: 4 additions & 0 deletions src/apps/explorer/components/TransanctionBatchGraph/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import Cytoscape, {
EventObject,
} from 'cytoscape'
import popper from 'cytoscape-popper'
import noOverlap from 'cytoscape-no-overlap'
import React, { useState, useEffect, useRef, useCallback } from 'react'
import CytoscapeComponent from 'react-cytoscapejs'
import styled, { useTheme } from 'styled-components'
Expand All @@ -29,6 +30,8 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import useWindowSizes from 'hooks/useWindowSizes'

Cytoscape.use(popper)
Cytoscape.use(noOverlap)

const PROTOCOL_NAME = APP_NAME
const WrapperCytoscape = styled(CytoscapeComponent)`
background-color: ${({ theme }): string => theme.bg1};
Expand Down Expand Up @@ -255,6 +258,7 @@ function TransanctionBatchGraph({
cy.on('mouseout', 'edge', (event): void => {
event.target.removeClass('hover')
})
cy.nodes().noOverlap({ padding: 5 })

return (): void => cy.removeAllListeners()
}, [cytoscapeRef, elements.length])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ export function STYLESHEET(theme: DefaultTheme): Stylesheet[] {
style: {
'border-style': 'dashed',
'border-opacity': 0.8,
opacity: 0.8,
},
},
]
Expand Down
2 changes: 2 additions & 0 deletions src/declarations.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,3 +160,5 @@ declare module '*.md' {
}

declare module 'eth-json-rpc-middleware/*'

declare module 'cytoscape-no-overlap'
4 changes: 4 additions & 0 deletions src/types/cytoscape.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,8 @@ declare module 'cytoscape' {
interface Core {
removeAllListeners: () => void
}

interface NodeCollection {
noOverlap: ({ padding }: { padding: number }) => void
}
}
12 changes: 12 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7839,6 +7839,13 @@ cyclist@^1.0.1:
resolved "https://registry.yarnpkg.com/cyclist/-/cyclist-1.0.1.tgz#596e9698fd0c80e12038c2b82d6eb1b35b6224d9"
integrity sha1-WW6WmP0MgOEgOMK4LW6xs1tiJNk=

cytoscape-no-overlap@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/cytoscape-no-overlap/-/cytoscape-no-overlap-1.0.1.tgz#e677147b357f4ec2aac9c05e04e7c6b9e0ff822b"
integrity sha512-fbNqkSvXFJi6JRdDeVFHAuqnQpNObURvaUS763JYnnm1vakjk1D+/ZxjTtVagg24po+InhJNjBeO8CzpsY4EbQ==
dependencies:
user "0.0.0"

cytoscape-popper@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/cytoscape-popper/-/cytoscape-popper-2.0.0.tgz#d93917695a9b8af3dbda1d8ee433618ac4d4e359"
Expand Down Expand Up @@ -20128,6 +20135,11 @@ use@^3.1.0:
resolved "https://registry.yarnpkg.com/use/-/use-3.1.1.tgz#d50c8cac79a19fbc20f2911f56eb973f4e10070f"
integrity sha512-cwESVXlO3url9YWlFW/TA9cshCEhtu7IKJ/p5soJ/gGpj7vbvFrAY/eIioQ6Dw23KjZhYgiIo8HOs1nQ2vr/oQ==

[email protected]:
version "0.0.0"
resolved "https://registry.yarnpkg.com/user/-/user-0.0.0.tgz#f27f1b23fc511f2a8efa40db55cfba123824e02a"
integrity sha1-8n8bI/xRHyqO+kDbVc+6Ejgk4Co=

utf-8-validate@^5.0.2:
version "5.0.5"
resolved "https://registry.yarnpkg.com/utf-8-validate/-/utf-8-validate-5.0.5.tgz#dd32c2e82c72002dc9f02eb67ba6761f43456ca1"
Expand Down