Skip to content

Instantly share code, notes, and snippets.

@j4johnfox
Created March 23, 2010 22:24
Show Gist options
  • Save j4johnfox/341760 to your computer and use it in GitHub Desktop.
Save j4johnfox/341760 to your computer and use it in GitHub Desktop.
- (void)setAnchorPoint:(CGPoint)anAnchorPoint
inPhotoLayer:(CALayer)aPhotoLayer
{
log('anAnchorPoint is ' +CPStringFromPoint(anAnchorPoint));
if (aPhotoLayer._DOMContentsElement == null)
{
log('aPhotoLayer has no _DOMContentsElement cannot set its anchor point, bail');
return;
}
var styleObject = aPhotoLayer._DOMContentsElement.style;
var xVal = (anAnchorPoint.x * 100 +'%');
var yVal = (anAnchorPoint.y * 100 +'%');
log('xVal is ' +xVal +' yVal is ' +yVal);
if (CPBrowserIsEngine(CPWebKitBrowserEngine) && (typeof styleObject.WebkitTransformOrigin != "undefined"))
{
styleObject.WebkitTransformOrigin = +xVal +" " +yVal;
[aPhotoLayer setNeedsDisplay];
}
else if (CPBrowserIsEngine(CPGeckoBrowserEngine) && (typeof styleObject.MozTransformOrigin != "undefined"))
{
styleObject.MozTransformOrigin = +xVal +" " +yVal;
[aPhotoLayer setNeedsDisplay];
}
/*
else if (CPBrowserIsEngine(CPOperaBrowserEngine))
{
//transformName = '-o-transform';
}
*/
else
{
[aPhotoLayer setAnchorPoint:anAnchorPoint];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment