Skip to content

Instantly share code, notes, and snippets.

@desandro
Created February 11, 2013 12:56
Show Gist options
  • Save desandro/4754275 to your computer and use it in GitHub Desktop.
Save desandro/4754275 to your computer and use it in GitHub Desktop.
Item.prototype._applyTransformPosition = function() {
// get possible translate position
if ( !transformProperty ) {
return;
}
var style = getStyle( this.element );
var transform = style[ transformProperty ];
if ( transform.indexOf('matrix') !== 0 ) {
return;
}
// split matrix(1, 0, 0, 1, x, y)
var matrixValues = transform.split(',');
// translate X value is in 12th or 4th position
var xIndex = transform.indexOf('matrix3d') === 0 ? 12 : 4;
this.position.x += parseInt( matrixValues[ xIndex ], 10 );
// translate X value is in 13th or 5th position
this.position.y += parseInt( matrixValues[ xIndex + 1 ], 10 );
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment