Built with blockbuilder.org
Created
March 2, 2018 18:59
-
-
Save lordliquid/616d13dcdd2741b97b6f5ff783d2d83a to your computer and use it in GitHub Desktop.
Menu
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
license: mit |
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
<!DOCTYPE html> | |
<head> | |
<meta charset="utf-8"> | |
<script src="https://d3js.org/d3.v4.min.js"></script> | |
<style> | |
body { margin:0;position:fixed;top:0;right:0;bottom:0;left:0; } | |
</style> | |
</head> | |
<body> | |
<script> | |
// Feel free to change or delete any of the code you see in this editor! | |
var svg = d3.select("body").append("svg") | |
.attr("width", 960) | |
.attr("height", '100%') | |
let toolbar = svg.append('g'); | |
let links = ['Home', 'Menu Item 1', 'Menu Item 2', 'Menu Item 3']; | |
function expandToolbar() { | |
let elem = d3.select(this); | |
elem | |
.transition() | |
.duration(1000) | |
.ease(d3.easeCircleOut) | |
.attr('width', '20%') | |
.attr('height', '100%') | |
.attr('z-index', 1); | |
let textEnter = elem.selectAll('text') | |
.data(links) | |
textEnter | |
.enter() | |
.append('text') | |
.text(t => t) | |
.attr('fill', 'white') | |
.attr('z-index', 1000) | |
} | |
function collapseToolbar() { | |
let elem = d3.select(this); | |
elem | |
.transition() | |
.duration(700) | |
.ease(d3.easeCircleIn) | |
.attr('width', '2%') | |
.attr('height', '100%'); | |
} | |
toolbar | |
.append('rect') | |
.attr('width', '2%') | |
.attr('height', '100%') | |
.on('mouseover', expandToolbar) | |
.on('mouseout', collapseToolbar) | |
</script> | |
</body> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment