http://jsfiddle.net/reveries/9Dt7n/ http://www.reveriesrefined.com/test/代碼在JS小提琴而不是在Dreamweaver或服務器上的
當你掀掉了門,它應該動畫...在的jsfiddle它出色地工作,但是一旦我把這個代碼放到我的網站上,它就停止工作。你仍然會看到圖像,但是當你將它懸停在上面時,沒有動畫。我想知道如果可能js小提琴有一些隱藏的代碼,我不包括?
的jQuery(W/srpitely)
var iFrames = 23,
iFps = 24,
bRewind = false,
iStartFrame = -1,
bAnimating = false,
stopAndRewind = function(oAnim) {
iStartFrame = ~iStartFrame ? -1 : iFrames - 2;
bRewind = !bRewind;
bAnimating = false;
oAnim.spStop();
};
$("#door").on("mouseenter mouseleave", function() {
var iCurFrame = iStartFrame;
if ($._spritely.instances && $._spritely.instances[$(this).prop("id")])
{
if (bAnimating)
{
iCurFrame = $(this).spGet("current_frame");
stopAndRewind($(this));
}
$(this).destroy();
}
bAnimating = true;
$(this).sprite({
fps: iFps,
no_of_frames: iFrames,
start_at_frame: iCurFrame,
rewind: bRewind,
on_frame: (function() {
var o = {},
i = 1;
if (!bRewind)
{
i = iFrames - 2;
}
o[i] = stopAndRewind;
return o;
})()
});
});
所以我應該包括: $(文件)。就緒(函數(){ 碼...等等... – user1868086
@ user1868086:很多人做我個人認爲對於'準備的唯一有效的使用情況'''''''''如果你控制'script'元素的位置,只需將它放在頁面底部,就在關閉'