Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Old 05-10-2009, 06:45 AM jquery jPhysics-3D
Sleeping Troll's Avatar
Ultra Talker

Posts: 351
Name: Butch Begy
Trades: 0
I am modifying jPhysics for 3D resolution, but getting error in code that I can't figure? Any help appreciated.
Code:
jQuery.fn.physics = function(params) {
 this.each(function(i){
  //Defaults for first time (without physics properties) (when not in 'params')
  if (!this.position) {
   if (!params.position) this.position = new $.Vector(0,0,0);
   if (!params.velocity) this.velocity = new $.Vector(0,0,0);
   if (!params.acceleration) this.acceleration = new $.Vector(0,0,0);
   if (!params.minPosition) this.minPosition = new $.Vector(-Infinity,-Infinity,-Infinity);
   if (!params.maxPosition) this.maxPosition = new $.Vector(Infinity,Infinity,-Infinity);
   if (!params.minVelocity) this.minVelocity = new $.Vector(-Infinity,-Infinity,-Infinity);
   if (!params.maxVelocity) this.maxVelocity = new $.Vector(Infinity,Infinity,-Infinity);
   if (!params.minAcceleration) this.minAcceleration = new $.Vector(-Infinity,-Infinity,-Infinity);
   if (!params.maxAcceleration) this.maxAcceleration = new $.Vector(Infinity,Infinity,-Infinity);
   if (!params.mass) this.mass = 1;
   this.style.position = 'absolute';
  }
  //Use 'params' where possible
  if (params.position) this.position = params.position;
  if (params.velocity) this.velocity = params.velocity;
  if (params.acceleration) this.acceleration = params.acceleration;
  if (params.minPosition) this.minPosition = params.minPosition;
  if (params.maxPosition) this.maxPosition = params.maxPosition;
  if (params.minVelocity) this.minVelocity = params.minVelocity;
  if (params.maxVelocity) this.maxVelocity = params.maxVelocity;
  if (params.minAcceleration) this.minAcceleration = params.minAcceleration;
  if (params.maxAcceleration) this.maxAcceleration = params.maxAcceleration;
  if (params.mass) this.mass = params.mass;
  this.style.left = Math.round(this.position[0])+'px';
  this.style.top = Math.round(this.position[1])+'px';
  this.style.z-index = Math.round(this.position[2]);//this line throws "syntax error"
 });
 return this;
};
I am thinking the "-" in z-index is being parsed as an operator? If this is the case, how do I work around it?
__________________
Sleeping Troll, EMUSE, Mind Expansion...Truly serendipity!

Last edited by Sleeping Troll; 05-10-2009 at 06:56 AM..
Sleeping Troll is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 05-10-2009, 10:53 AM Re: jquery jPhysics-3D
wayfarer07's Avatar
Poo on You

Latest Blog Post:
Introducing WowWindow
Posts: 3,985
Name: Abel Mohler
Location: Asheville, North Carolina USA
Trades: 0
this.style.z-index

Should be

this.style.zIndex

CSS properties that are split with a dash are always expressed in camelCase in JavaScript, since dashes are not allowed in property names, as they would indicate subtraction.
__________________
Join me on
Please login or register to view this content. Registration is FREE
wayfarer07 is offline
Reply With Quote
View Public Profile Visit wayfarer07's homepage!
 
Old 05-11-2009, 12:01 AM Re: jquery jPhysics-3D
VirtuosiMedia's Avatar
Web Design Made Simple

Posts: 1,228
Trades: 0
If Abel's suggestion doesn't work, try writing variables with a hyphen in bracket notation, like so:
Code:
this.style['z-index']
__________________
Want new web resources every day? - Follow me on
Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
VirtuosiMedia is offline
Reply With Quote
View Public Profile Visit VirtuosiMedia's homepage!
 
Reply     « Reply to jquery jPhysics-3D
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.14914 seconds with 12 queries