iVis-at-Bilkent / cytoscape.js-grid-guide

A Cytsocape.js extension to provide a framework for grid interactions such as grid lines and snapping to grid, and guidelines and snap support for alignment of nodes.
MIT License
59 stars 9 forks source link

Fixes multiple instances issue #29

Closed metincansiper closed 6 years ago

metincansiper commented 6 years ago

While working with multiple Cytoscape.js instances the grids was always being updated for the instance which is created latest.

For example imagine that we have two Cytoscape.js instances named as cy1 and cy2 where cy2 is created later. If I toggle showGrid option for cy1 the changes were seen at the container of cy2 rather than container of cy1.

This PR is created to solve this bug.

kinimesi commented 6 years ago

@metincansiper There are a few similar problems related to setting options in different Cytoscape instances. http://plnkr.co/edit/iw8OCMh54FTbH1jjgWGY?p=preview

In this example, initPosAlignment is set to true for the first instance and false for the second instance. But guidelines is not drawn to initial mouse position on both instances.

Also the color of geometric guidelines strokeStyle is set to black for the first instance and red for the second instance. But it is red for both instances.

Edit: there is also an error in console related to multiple registration of align.

metincansiper commented 6 years ago

@kinimesi The problems that you mentioned seems to be fixed now.