Hi, I want to have some kind of bounce effect in my animation plugin but it isn't working. The callback isn't called at all:
$(function() {
var offset = $("#first").offset();
var position = $(window).scrollTop();
$(window).scroll(function() {
var scroll = $(window).scrollTop();
if (scroll>position) {
$("body")
.animate({
scrollTop: offset.top + $("#first").innerHeight() + 150
},
1000,
"easeInOutQuart",
function() {
$("body").animate({
scrollTop: offset.top - 150
},
1000,
"easeOutBounce"
)
})
}
})
})
Okay.. Here's my HTML code.. I dont know why yours is working great.. But mine isn't.. The $('html') isn't working but yours is working fine..
<html lang="en" xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>Bounce Test Pad</title>
<link rel=stylesheet href="index.css" type= "text/css" />
<script type="text/javascript" src ="jquery-1.3.2.js"></script>
<script type = "text/javascript" src="jquery.easing.1.3.js"></script>
</head>
<body>
<img id="lightbulb" src = "img/veioza.png">
<div id="wrapper">
<img id="first" class="images" src="img/nike.jpg" />
<img id ="second" class = "images" src="img/golden.jpg" />
<img id = "third" class ="images" src ="img/a.jpg" />
</div>
<script type="text/javascript">
$(window).resize(function() {
centerIt();
});
$(function() {
centerIt();
})
function centerIt() {
var viewportWidthSize = window.innerWidth;
var pixels = (viewportWidthSize / 2) - $("#first").width() / 2;
$("#wrapper img").css("left", pixels);
};
$(function() {
var offset = $("#first").offset();
var prevpos = $(window).scrollTop();
var animating = false;
$(window).scroll(function() {
var curpos = $(window).scrollTop();
if (curpos>prevpos && !animating) {
$('html').animate(
{scrollTop: offset.top + $("#first").height()},
1000,
"easeInOutQuart"
)
}
animating = true;
})
})
</script>
</body>
</html>