GitXplorerGitXplorer
a

spriteOnHover

public
5 stars
6 forks
3 issues

Commits

List of commits on branch master.
Unverified
de4ffa0aebada4f2796996fe6f94c744ec0ab7ea

Merge pull request #4 from sbglasius/master

aapolinario committed 10 years ago
Unverified
67c6d3ac11c804cd02082f6990b0a8f5eac54d70

Update component.json

ssbglasius committed 10 years ago
Unverified
5e11764530d798f548ce7b8cd2523927249afd82

Update component.json

ssbglasius committed 10 years ago
Unverified
f87ed383109505f8194e3d645cbd70f30efb1902

Update component.json

ssbglasius committed 10 years ago
Unverified
65f80679bd829b1f832dc88c225cea35fd92db7b

Minor fix

ssbglasius committed 10 years ago
Unverified
8e8644a70fc18c8cdaead86cddc7f8fe347910f7

Merge pull request #1 from sbglasius/component

ssbglasius committed 10 years ago

README

The README file for this repository.

spriteOnHover

spriteOnHover is a lightweight jQuery plugin designed to animate your sprites on hover (duh).

Instalation

Include script after the jQuery library (unless you are packaging scripts somehow else): <script src="https://raw.githubusercontent.com/apolinario/spriteOnHover/master//path/to/jquery.spriteOnHover-0.2.5.min.js"></script>

Simplest Usage

$('#yourSprite').spriteOnHover();

This will make the plugin work this the default parameters, which points to this:

$('#yourSprite').spriteOnHover({fps:30, orientation:’horizontal’, rewind: true, loop: false, autostart:false;repeat:true});

The usage is just hovering the sprite, you set $('#yourSprite').spriteOnHover(); and the element '#yourSprite' will be turned into a hoverable sprite, no need to use the mouseover, mouseenter, mouseleave or hover events of jquery.

The CSS

#yourSprite{
    width: 43px; //Your sprite width
    height: 43px; //Your sprite height
    background: transparent url(path/to/your/spritesheet.png) 0px 0px no-repeat; //Path to your spritesheet
}

Attention: The spriteOnHover plugin will autodetect how many frames your sprite has, based on the orientation parameter, but it’s crucial that every frame has the exactly same size as the others. For now, multi-line sprites are not supported.

The parameters

spriteOnHover has 6 parameters:

  • fps: Integer - The frame-per-second count of your animation (Default: 30)

  • orientation: Possible values: "horizontal" or "vertical" - The orientation of your spritesheet, for now, the plugin supports only a single-orientated spritesheet, and can’t handle multidimensional sprites. (Default: "horizontal"). Example:

    • This is a horizontal spritesheet
    • This is a vertical spritesheet
    • This is a multi-line spritesheet (not supported for now)
  • rewind: Possible values: true, false or "unanimate" - Is how your animation should work on mouseleave:

    • true: the animation will be animatedly rewinded;
    • false: the animation will stop in the last frame;
    • "unanimate": the sprite will go back straight to the first frame, with no animation
    • (Default: true)
  • loop: Possible values: true, false or "infinite"

    • false, your animation will be displayed once,
    • true, your animation will be looped
    • "infinite", after it’s started, you will get an infinitely looping animation that is no longer controlled by the hover action;
    • (default: false)
  • autostart: Possible values: true or false - Determines if your animation will autostart or only be triggered by hover.

    • true: the animation will start without a hover event
    • false: the animation will only start with on mouseover
    • (default: false)
  • repeat: Possible values: true or false

    • true: the animation will be triggered every time you hover the sprite (of course after finishing the last event)
    • false, the animation will be triggered only at the first hover action and after that will get stuck at the last frame of your animation.
    • (deafult: true);

Demos & Examples

In the plugin's page

Donate

Want to help me get the TODO features faster or the plugin just solved your problem? Donate <3

License

            DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
                    Version 2, December 2004

Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.

            DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
  TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION

0. You just DO WHAT THE FUCK YOU WANT TO.