Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6063225
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:08:29+00:00 2026-05-23T09:08:29+00:00

I am working with CSS sprites and the jQuery plugin spritely . I have

  • 0

I am working with CSS sprites and the jQuery plugin spritely.

I have a Super Mario image and when rolled over, I’d like the animation to play. When, you move your mouse away from the Super Mario (which is a <div> element), I would like the animation to play in reverse back to the original place it started.

Here is what I have so far:

<!DOCTYPE html>
<html>
<head>
    <title>Mario Planet Spritely Nav</title>
    <script src="http://cdnjs.cloudflare.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script>
    <script src="jquery.spritely-0.5.js"></script>
    <script>
        $(document).ready(function() {
            $('#mario').hover(
                function() {
                    $('#mario').sprite({
                        fps: 2,
                        no_of_frames: 6,
                        play_frames: 6
                    });
                },
                function() {
                    $('#mario').sprite({
                        fps: 2,
                        no_of_frames: 6,
                        play_frames: 5,
                        rewind: true
                    });
                }
            );
        });
    </script>
    <style>
        #mario {
            position: absolute;
            width: 40px;
            height: 52px;
            background: transparent url(mh.png);
            cursor: pointer;
        }
    </style>
</head>
<body>
<div id="mario"></div>
</body>
</html>

I have the fps intentionally slow so I can try and figure out what’s going on here. For some reason, the first hover and mouseout work great. But then, during the second hover, something weird happens. It appears to play an extra frame. I don’t understand why.

Here is my mh.png image (I don’t have a current webserver to show a live demo):

mh.png

Do you guys have any idea as to why this is occurring?

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T09:08:30+00:00Added an answer on May 23, 2026 at 9:08 am

    I happen to be one of the Spritely developers — perhaps I can be of some help!

    This is happening because of the different play_frames values when running the Sprite. Admittedly it is quite confusing. I’ll try and explain.

    When you initially call sprite, it will play the first 6 frames. When you mouse out again, it will go back by 5 frames. All is good so far. But things get out of sync, and so when you play the next 6, you are one frame further than expected.

    The following solution should fix it for you,

    var play_frames = 6;
    
    $('#mario').hover(
        function() {
            $('#mario').sprite({
                fps: 2,
                no_of_frames: 6,
                play_frames: play_frames
            });
            play_frames = 5;
        },
        function() {
            $('#mario').sprite({
                fps: 2,
                no_of_frames: 6,
                play_frames: 5,
                rewind: true
            });
        }
    );
    

    Edit: I have just realized that the solution posted previously is more or less the same! Not sure why this would not work for you. It is working for me.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I have working code that animates a BG image via a plugin. This
I'm working on a site at the moment and have ventured into CSS Sprites
I'm trying to do a navigation bar using css sprites. I have the image
jQuery beginner here. Here is what I'm working on. I have an area map
It's weird! I was working on my CSS and jquery just stopped working! checked
I wrote this script awhile back and have modified it to use css sprites
I have a slide viewer I am making. I have all the css working
I am working with some css animation. But I found that, the CSS transition
I'm working on a program that uses HTML/CSS/Javascript/JQuery for its user interface. One of
I have this defined in an existing CSS sheet that I'm working with: label.error-field

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.