Last active
December 2, 2015 12:00
-
-
Save omniosi/9282851 to your computer and use it in GitHub Desktop.
an animated opening and closing menu button made with RaphaelJS and inspired by http://www.hugeinc.com/. It even works in IE6!
This file contains hidden or 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
#box{ | |
background:lightgrey; | |
width:60px; | |
height:60px; | |
} |
This file contains hidden or 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> | |
<html> | |
<head> | |
<script src="http://cdnjs.cloudflare.com/ajax/libs/raphael/2.1.0/raphael-min.js"></script> | |
<meta charset="utf-8"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<div id="box"></div> | |
</body> | |
</html> |
This file contains hidden or 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
Raphael(function(){ | |
var box = Raphael('box', '60', '60'); | |
var cover = box.rect(0,0,60,60).attr({fill:'lightgrey'}).toBack(); | |
var first = box.path("M15 20L45 20"); | |
first.attr({'stroke-width':'6px'}); | |
var second = box.path("M15 30L45 30"); | |
second.attr({'stroke-width':'6px',opacity:1}); | |
var third = box.path("M15 40L45 40"); | |
third.attr({'stroke-width':'6px'}); | |
var n = 1; | |
var st = box.set(); | |
st.push(cover,first,second,third); | |
st.click(function(){ | |
if(n===2){ | |
first.animate({path: "M15 20L45 20"},200,'ease-in-out'); | |
second.animate({opacity:1},200,'ease-in-out'); | |
third.animate({path: "M15 40L45 40"},200,'ease-in-out'); | |
n--; | |
}else{ | |
first.animate({path: "M15 15L45 45"},200,'ease-in-out'); | |
second.animate({opacity:0},50,'ease-in-out'); | |
third.animate({path: "M15 45L45 15"},200,'ease-in-out'); | |
n++; | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It even works in IE6!