-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
30,860 additions
and
9,135 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
<!DOCTYPE> | ||
|
||
<html> | ||
|
||
<head> | ||
<title>cytoscape-popper + Popper.js@2 demo</title> | ||
|
||
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1, maximum-scale=1"> | ||
<script src="https://unpkg.com/cytoscape/dist/cytoscape.min.js"></script> | ||
|
||
<!-- for testing with local version of cytoscape.js --> | ||
<!--<script src="../cytoscape.js/build/cytoscape.js"></script>--> | ||
|
||
<script src="https://unpkg.com/@popperjs/core@2"></script> | ||
<script src="cytoscape-popper.js"></script> | ||
|
||
<style> | ||
body { | ||
font-family: helvetica neue, helvetica, liberation sans, arial, sans-serif; | ||
font-size: 14px | ||
} | ||
|
||
#cy { | ||
position: absolute; | ||
left: 0; | ||
top: 0; | ||
bottom: 0; | ||
right: 0; | ||
z-index: 1; | ||
} | ||
|
||
h1 { | ||
opacity: 0.5; | ||
font-size: 1em; | ||
font-weight: bold; | ||
} | ||
|
||
.popper-div { /* just an example */ | ||
border: 1px solid red; | ||
background: #fff; | ||
z-index: 9999; | ||
padding: 0.25em; | ||
pointer-events: none; | ||
} | ||
</style> | ||
|
||
<script> | ||
document.addEventListener('DOMContentLoaded', function () { | ||
// Popper from @popperjs/core | ||
cytoscape.use(cytoscapePopper(Popper.createPopper)); | ||
|
||
var cy = window.cy = cytoscape({ | ||
container: document.getElementById('cy'), | ||
|
||
style: [ | ||
{ | ||
selector: 'node', | ||
style: { | ||
'content': 'data(id)' | ||
} | ||
}, | ||
|
||
{ | ||
selector: 'edge', | ||
style: { | ||
'curve-style': 'bezier', | ||
'target-arrow-shape': 'triangle' | ||
} | ||
} | ||
], | ||
|
||
elements: { | ||
nodes: [ | ||
{ data: { id: 'a' } }, | ||
{ data: { id: 'b' } } | ||
], | ||
edges: [ | ||
{ data: { id: 'ab', source: 'a', target: 'b' } } | ||
] | ||
}, | ||
|
||
layout: { | ||
name: 'grid' | ||
} | ||
}); | ||
|
||
var a = cy.getElementById('a'); | ||
var b = cy.getElementById('b'); | ||
var ab = cy.getElementById('ab'); | ||
|
||
var makeDiv = function(text){ | ||
var div = document.createElement('div'); | ||
|
||
div.classList.add('popper-div'); | ||
|
||
div.innerHTML = text; | ||
|
||
document.body.appendChild( div ); | ||
|
||
return div; | ||
}; | ||
|
||
var popperA = a.popper({ | ||
content: function(){ return makeDiv('Sticky position div'); }, | ||
}); | ||
|
||
var updateA = function(){ | ||
popperA.update(); | ||
}; | ||
|
||
a.on('position', updateA); | ||
cy.on('pan zoom resize', updateA); | ||
|
||
var popperB = b.popper({ | ||
content: function(){ return makeDiv('One time position div'); }, | ||
}); | ||
|
||
var popperAB = ab.popper({ | ||
content: function(){ return makeDiv('Sticky position div'); }, | ||
}); | ||
|
||
var updateAB = function(){ | ||
popperAB.update(); | ||
}; | ||
|
||
ab.connectedNodes().on('position', updateAB); | ||
cy.on('pan zoom resize', updateAB); | ||
}); | ||
</script> | ||
</head> | ||
|
||
<body> | ||
<h1>cytoscape-popper + Popper.js@2 demo</h1> | ||
<div id="cy"></div> | ||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.