GithubHelp home page GithubHelp logo

brianpmarks / traqball.js Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dirkweber/traqball.js

0.0 2.0 0.0 172 KB

A small javascript library for CSS3 3D capable browsers. It creates a virtual trackball around a block level element, making it possible to rotate it freely around it's X-, Y- and Z-axis in 3D space.

License: MIT License

JavaScript 100.00%

traqball.js's Introduction

traqball.js: a virtual css3 3d trackball


traqball.js is a small javascript library for CSS3 3D capable browsers. It creates a virtual trackball around a block level element, making it possible to rotate it freely around it's X-, Y- and Z-axis in 3D space without gimbal lock on any axis.

traqball.js will only work in browsers that support the CSS 3D Transforms Module (http://www.w3.org/TR/css3-3d-transforms/). At the time of this writing (Nov. 2011) these are Safari, Chrome and Firefox 10.a. Microsoft and Opera have announced that they will include CSS3 3D support in upcoming versions of their browsers. Traqball.js already generates vendor prefixes for these browsers, and should work for them as soon as CSS3 3D support is included.

How to include traqball.js:

####1. Include a reference to traqball.js into the head:

<script type="text/javascript" src="traqball.js"></script>

traqball will NOT check if the browser supports CSS 3D transfoms. If you need feature checking, take care of that yourself or use some library like modernizr.

####2. On window load create one or more traqballs:

var mytraqball = new Traqball(configurationObject);

"configurationObject" contains all parameters to configure your traqball. Example:

{	
	stage:				"stage", 			// id of block element. String, default value: <body>
	axis: 				[0.5,1,0.25], 		// X,Y,Z values of initial rotation vector. Array, default value: [1,0,0]
	angle: 				0.12,				// Initial rotation angle in radian. Float, default value: 0.
	perspective: 		perspectiveValue,	// Perspective. Integer, default value 700.
	perspectiveOrigin:	"xVal yVal",		// Perspective Origin. String, default value "50% 50%".
	impulse: 			boolean, 			// Defines if object receives an impulse after relesing mouse/touchend. Default value: true.
	limitAxxis:			"x" | "y"			//limits the rotation to only one axxis.
	}

If a parameter is missing from configurationObject, existing CSS rules will be applied. If no CSS rules exist, default values will kick in.

The most important parameter is "stage". It is a string refering to the id of a block element that is passed to traqball. Traqball will apply the values for "perspective" and "perspective-origin" to this element and then search it for a block-level child element. The first it finds will be made "rotatable". If no id is provided, traqball will search for the first child element within the body tag.

Deactivating a traqball:

It is possible to deactivate a traqball, to temporarily disable user interaction (i.e. during transitions or animations):

mytraqball.disable();

Activating traqball

For activating a traqball after deactivation use

mytraqball.activate();

Updating traqball

In case configuration values must be altered, traqball can be updated with a new configuration object. Values from the previous configuration object will be kept, unless "newConfigurationObject" contains new parameters.

mytraqball.setup(newConfigurationObject);

License

traqball.js is is licensed under the terms of the MIT License, see the included MIT-LICENSE file.

More infos and demos on www.eleqtriq.com

traqball.js's People

Contributors

dirkweber avatar

Watchers

Brian Marks 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.