http://jsfiddle.net/reveries/9Dt7n/ http://www.reveriesrefined.com/test/
当您将鼠标悬停在门上时,它应该动画......并且在 jsfiddle 中它工作得很好,但是一旦我将此代码放在我的网站上,它就会停止工作。您仍然会看到图像,但是当您将鼠标悬停在它上面时,没有动画。我想知道js fiddle是否有一些我不包括的隐藏代码?
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;
})()
});
});