Code Monkey home page Code Monkey logo

spriteonhover's Introduction

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="/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.	

spriteonhover's People

Contributors

apolinario avatar sbglasius avatar

Watchers

 avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.