http://jsfiddle.net/reveries/9Dt7n/ http://www.reveriesrefined.com/test/
When you hove over the door, it's supposed to animate... and in jsfiddle it works brilliantly, but once I put this code on my website, it stops working. You will still see the image, but when you hover over it, there's no animation. I'm wondering if maybe js fiddle has some hidden code that i'm not including??
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;
})()
});
});
` tag. Then it will have access to all of the elements defined above it (which is to say, all of them). That's what the [YUI folks recommend](http://developer.yahoo.com/performance/rules.html), and the developers behind [Google Closure](http://groups.google.com/group/closure-library-discuss/browse_thread/thread/1beecbb5d6afcb41).
– T.J. Crowder Dec 03 '12 at 23:22