Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 40163dfc7a
Fetching contributors…

Cannot retrieve contributors at this time

56 lines (47 sloc) 1.807 kb
<?xml version="1.0"?>
<bindings xmlns="">
<binding id="TweeningElement">
<field name="x">0</field>
<field name="y">0</field>
<field name="z">0</field>
<field name="width">0</field>
<field name="height">0</field>
<field name="framerate">12</field><!-- frames per second -->
<field name="frames">1</field><!-- # of frames to tween -->
<field name="acceleration">0</field>
<field name="deceleration">0</field>
<method name="getComputedStyle">
<parameter name="prop" />
return parseFloat(this.currentStyle ?
this.currentStyle[prop] : //IE
document.defaultView.getComputedStyle(this,null)[prop] //W3C
) || 0;
<method name="tween">
// List of properties to tween; first value is XBL property, second is style property, third is units:
var props = [["x","left","px"], ["y","top","px"], ["z","zIndex",""], ["width","width","px"], ["height","height","px"]];
if(this._tweenTimer) clearTimeout(this._tweenTimer); //allow only one timer at a time
if(this.frames < 1) this.frames = 1; //can't have less than one frame
// Tween each property:
for(var i=0; i<props.length; i++) {
var curr = this.getComputedStyle(props[i][1]);
var goal = this[props[i][0]];
var next = curr + ((goal - curr) / this.frames);[props[i][1]] = next + (props[i][2] || "");
window.status = this.getComputedStyle("zIndex");
// Prepare next step if any:
if(this.frames > 0) {
var thisRef = this;
this._tweenTimer = setTimeout(function(){thisRef.tween();}, 1000 / this.framerate);
Jump to Line
Something went wrong with that request. Please try again.