GithubHelp home page GithubHelp logo

jquery.throwable's Introduction

JQuery.throwable

JQuery plugin to make HTML elements throwable

Create physical-like HTML objects in your browser

Code example

$(".box2d").throwable({
                        containment:[0,0,500,500],
                        drag:true,
                        gravity:{x:0,y:0},
                        impulse:{
                            f:52,
                            p:{x:1,y:1}
                        },
                        shape:"circle",
                        autostart:false,
                        bounce:0.5,
                        damping:100,
                        areaDetection:[[0,0,300,300]],
                        collisionDetection: true
                    });

Options

* gravity: object {x:valueX,y:valueY} 
* container: define the limits where the object can be thrown 
                   "window" is the default
                   "parent" the object will be contained inside the parent
                   you can specify custom a container by giving array [x1,y1,x2,y2]
* shape: defines the shape of the object, by default is "box" and you can specify "circle"
* autostart: by default the effects start at mouse move 
* drag: boolean to specify if the object will be draggable or not, by default it is set to true
* impulse: you can specify an impluse to apply on the object by giving an object 
                   {
                        f: forceValue, // define the energy of the impluse (number)
                        p: pointDirection //define the direction on the impluse object like the gravity option
                   }
* bounce: defines the bounce effect of the body (value between 0 and 1) default 0, no bounce
* damping: defines the damping(*) effect value from 0 to infini, default 0 
* areaDetection: specify an array of areas, that when an objet enter those areas the event inarea is fired 
                 and outarea event fired when exiting
* collisionDectection : bool to activate or desactivate the collision detection 

(*) : damping

Events & Callbacks

* inarea : fired when an object enter and area specified in the option areaDetection
* outarea : fired when an object exit and area specified in the option areaDetection
* collision : fired when a collision happened between two objects 
* nocollision : fired when there is no collision 

Requirements

* JQuery (of course it's a jquery plugin)

Demos

Credits

How to use it!

You can test it by including this js link to your page

<script src="http://benahm.github.io/jquery.throwable/javascripts/jquery.throwable.js" type="text/javascript"></script> 

Or download the js file

jquery.throwable's People

Contributors

benahm avatar raphox avatar relequestual avatar runningmangame avatar salazr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

jquery.throwable's Issues

Ground/wall div

it it possible to make a ground div
that is fixed ground div that wont react on boxes that are falling on it, but still will be a impenetrable.

really hoping on your responds, because im stuck with this ๐Ÿ‘

avoid animation not starting until mouse moved?

I am trying to change the code to make gravity start when triggered by an event (ondocumentready, onclick, ...) but without needing the mouse to have moved before the gravity effect starts (as it is now) and I couldn't find a nice way to do it without breaking some other functionality. Can you help ?
Thanks.

Elements not dragable on windows 8 HTML5 apps

i'll create a new game by using your jquery.throwable plugin,for windows 8 Apps.
Your plugin works on all browsers well,but fails in ,Visual studio for windows 8 HTML5 app,in this throwable working but drag option will not work.
i was study the whole code i think the error is in
" var count = world.Query(aabb, shapes, k_maxCount); "
here count is 0 in output rather then 1. and shapes having null.

Please help me to solve out of this problem.

Elements on load are laggy and are not moving when swipped

Hi,

On ios devices, the throwable elements are laggy on load and do not move when swipped. This issue only seems to be apparent on devices which have upgraded to 7.1 as I have tested on earlier versions, and was unable to replicate.

This is the site which I am currently having the issues on: http://fashioncupboard.elleuk.com/

If you could provide me with any help it would be much appreciated.

Thanks,

Miles

restarting the world

Hi

Is there anyway to restart the physics environment? I am wanting to make the world container be resizable. I'm happy to just reboot the physics environent once a browser resize has finished.

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.