我想有某種反彈影響我的動畫插件,但它無法正常工作。回調不叫可言:的jQuery:需要一些幫助.. .animate的回調函數不工作
$(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"
)
})
}
})
})
好吧..這是我的HTML代碼..我不知道爲什麼你的是偉大的工作。但我的不是。該$(「HTML」)ISN 「T工作,但是你的工作很好..
<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>
嘗試驗證它不會通過把警報或執行console.log在那裏叫。 – 2009-05-03 10:41:39
嗨Pim, 我試着在回調函數中放置一個警報。該警報被稱爲不間斷。它只是彈出警報不停止 – 2009-05-03 10:48:00