Created
August 11, 2010 19:51
-
-
Save thiagosf/519612 to your computer and use it in GitHub Desktop.
Usar o botão de rolagem do mouse em jQuery.
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 PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | |
<html xmlns="http://www.w3.org/1999/xhtml" lang="pt-br"> | |
<head> | |
<meta http-equiv="Content-type" content="text/html; charset=utf-8" /> | |
<title>jQuery Lab</title> | |
<link href="http://fonts.googleapis.com/css?family=Cantarell:regular,italic,bold,bolditalic" rel="stylesheet" type="text/css" /> | |
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> | |
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/jquery-ui.min.js"></script> | |
<script src="http://brandonaaron.net/javascripts/plugins/mousewheel.js"></script> | |
<script> | |
var block = false; | |
$(function(){ | |
$('.color ul li').each(function(i) { | |
$(this).append(' <span style="color:#333;">'+i+'</span>'); | |
$(this).find('span').css({ | |
position: 'absolute', top: '5px', left:'0px', background:'#ccc' | |
}); | |
}); | |
$('.color ul li') | |
.bind('mousewheel', function(event, delta) { | |
var dir = delta > 0 ? 'Up' : 'Down', | |
vel = Math.abs(delta); | |
$(this).find('span').html(dir + ' at a velocity of ' + vel); | |
if (dir == 'Down') { | |
var _left = (parseInt($(this).find('span').css('left')) + (300 * vel)) + 'px'; | |
$(this).find('span').stop().animate({left:_left}, 500); | |
} | |
else { | |
var _left = (parseInt($(this).find('span').css('left')) - (300 * vel)) + 'px'; | |
$(this).find('span').stop().animate({left:_left}, 500); | |
} | |
return false; | |
}); | |
$('#menu ul li a').hover(function() { | |
if ($(this).attr('rel') !== 'block') { | |
$(this).stop().animate({color:'#fff'}, 400); | |
$(this).parent('li').stop().animate({backgroundColor:'#000'}, 500, 'easeOutElastic') | |
//$(this).parent('li').stop().animate({backgroundColor:'#000', height:'60px'}, 500, 'easeOutElastic') | |
} | |
}, function() { | |
if ($(this).attr('rel') !== 'block') { | |
$(this).stop().animate({color:'#999'}, 300); | |
$(this).parent('li').stop().animate({backgroundColor:'#333', height:'40px'}, 200).css('fontSize', '26px'); | |
} | |
}); | |
$('#menu ul li a').click(function() { | |
if ($(this).attr('rel') !== 'block') { | |
$this = $(this); | |
$('#menu ul li a').attr('rel', ''); | |
$('#menu ul li a').each(function(e) { | |
if ($(this).text() !== $this.text()) { | |
$(this).stop().animate({color:'#999'}, 400); | |
} | |
}); | |
$('#menu ul li') | |
.stop() | |
.animate({backgroundColor:'#333', height:'40px', fontSize:'26px'}, 200) | |
.find('div') | |
.remove(); | |
$this.attr('rel', 'block'); | |
$this | |
.parent('li') | |
.stop() | |
.animate({backgroundColor:'#cc3333', height:'280px', fontSize:'50px'}, 200) | |
.append('<div>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industrys standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</div>'); | |
block = false; | |
} | |
else { | |
$(this).attr('rel', ''); | |
$(this) | |
.parent('li') | |
.stop() | |
.animate({backgroundColor:'#333', height:'40px', fontSize:'26px'}, 200) | |
.find('div') | |
.remove(); | |
block = true; | |
} | |
}); | |
}); | |
</script> | |
<style> | |
* {margin:0;padding:0;list-style:none;} | |
body {font-family:consolas;background:#333;} | |
#menu {background:#333;padding:0;} | |
#menu ul {} | |
#menu ul li {background:#333;height:40px;padding:10px;font:normal 26px 'Cantarell',consolas,arial;letter-spacing:-1px;position:relative;} | |
#menu ul li a {color:#999;text-decoration:none;text-shadow:#000 2px 2px 2px;} | |
#menu ul li div {color:#fff;font:normal 16px 'Cantarell' !important;letter-spacing:0px;text-shadow:#000 0px 0px 2px;} | |
</style> | |
</head> | |
<body> | |
<div id="menu" class="color"> | |
<ul> | |
<li><a href="#">About</a></li> | |
<li><a href="#">Services</a></li> | |
<li><a href="#">Contact</a></li> | |
<li><a href="#">Between</a></li> | |
</ul> | |
</div> | |
<div style="background:#cc0000;position:absolute;width:100px;height:100px;color:#fff;display:none;" class="texto">AAA</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment