Comments (2)
The events are somewhat analogous to mousedown-mouseup-click: boxstart-boxend-box.
You can track all of the elements that are in a box gesture by keeping a list similar to your example:
const GROUP_THRESHOLD = 100; // time delta that separates one box gesture from another
let boxed = cy.collection();
const sendData = eles => {
let elsData = eles.map(el => el.data());
// send the array of data json objs somewhere; just log for now...
console.log(elsData);
};
const checkGroup = _.debounce(() => {
sendData(boxed);
boxed = cy.collection();
}, GROUP_THRESHOLD); // events must be at least this duration apart to make a separate group
const addToBoxed = el => {
boxed.merge(el);
checkGroup();
};
cy.on('box', e => { // or 'boxselect'
const el = e.target;
addToBoxed(el);
});
I've considered having native support in the core lib for getting a group of enclosed elements at once from a box gesture. The only solution I've seen that could work well for that is to allow for e.target
to have more than one element. This would also work for other gestures, and this would generally reduce the number of event objects created for group events. However, this approach is inconsistent with how listeners work in most systems --- e.g. the DOM. It would also be a breaking API change.
So, the pattern posted above works for now.
from react-cytoscapejs.
Thank you Max! This works perfectly, I'll keep an eye out for changes on the API in case native support is added.
from react-cytoscapejs.
Related Issues (20)
- ReferenceError: window is not defined when refresshing the page.
- Maximum call stack size exceeded HOT 1
- How to use ctxmenu in this component?
- Issues with React 18 StrictMode HOT 4
- Next.js uses cjs module loader resulting in SyntaxError: Cannot use import statement outside a module HOT 2
- TS: cannot find module error
- nodes selction is not working
- Canvas elements moved by 50% to the right of the CytoscapeComponent HOT 2
- v2.0 has demo target missing HOT 7
- resize CytoscapeComponent
- updates to component HOT 2
- Createportal / react-cytoscape HOT 1
- Microbundle Compile Error Next.js HOT 1
- Support automatically check/uncheck link between two nodes
- Question: Could the nodes be interactive? HOT 2
- Question: Update to React 18? HOT 2
- Question: Styling & Layout HOT 1
- Infinite render graph force-directed on parameter "randomize": false
- Module not found: Can't resolve 'react-cytoscapejs' in Nextjs
- TypeError: renderer is null HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-cytoscapejs.