cytoscape-panzoom
Description
This extension creates a widget that lets the user pan and zoom about a Cytoscape.js graph. This complements the built-in gesture support for panning and zooming in Cytoscape.js by giving less savvy users a more traditional UI -- similar to controls on map webapps.
Dependencies
- jQuery ^1.4 || ^2.0 || ^3.0
- Cytoscape.js ^2.0.0 || ^3.0.0
- Font Awesome 4 (for automatic icons), or you can specify your own class names for icons
Usage instructions
Download the library:
- via npm:
npm install cytoscape-panzoom
, - via bower:
bower install cytoscape-panzoom
, or - via direct download in the repository (probably from a tag).
require()
the library as appropriate for your project:
CommonJS:
var cytoscape = require('cytoscape');
var panzoom = require('cytoscape-panzoom');
panzoom( cytoscape );
AMD:
require(['cytoscape', 'jquery', 'cytoscape-panzoom'], function( cytoscape, $, panzoom ){
panzoom( cytoscape, $ );
});
Plain HTML/JS has the extension registered for you automatically, because no require()
is needed.
API
var defaults = {
zoomFactor: 0.05,
zoomDelay: 45,
minZoom: 0.1,
maxZoom: 10,
fitPadding: 50,
panSpeed: 10,
panDistance: 10,
panDragAreaSize: 75,
panMinPercentSpeed: 0.25,
panInactiveArea: 8,
panIndicatorMinOpacity: 0.5,
zoomOnly: false,
fitSelector: undefined,
animateOnFit: function(){
return false;
},
fitAnimationDuration: 1000,
sliderHandleIcon: 'fa fa-minus',
zoomInIcon: 'fa fa-plus',
zoomOutIcon: 'fa fa-minus',
resetIcon: 'fa fa-expand'
};
cy.panzoom( defaults );
cy.panzoom('destroy');
Publishing instructions
This project is set up to automatically be published to npm and bower. To publish:
- Set the version number environment variable:
export VERSION=1.2.3
- Publish:
gulp publish
- If publishing to bower for the first time, you'll need to run
bower register cytoscape-panzoom https://github.com/cytoscape/cytoscape.js-panzoom.git
- Make a release on GitHub to automatically register a new Zenodo DOI