Created
March 25, 2010 02:46
-
-
Save j4johnfox/343103 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (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]; | |
} | |
} | |
- (void)zoomPhotoLayer:(CALayer)aPhotoLayer | |
byScaleFactor:(CGFloat)aScaleFactor | |
{ | |
var myTransformAnimation; | |
//see: http://maettig.com/code/css/css-transform.html | |
log('aPhotoLayer._DOMContentsElement is ' +aPhotoLayer._DOMContentsElement); | |
if (aPhotoLayer._DOMContentsElement == null) | |
{ | |
log('aPhotoLayer has no _DOMContentsElement, bail'); | |
return; | |
} | |
var styleObject = aPhotoLayer._DOMContentsElement.style; | |
log('aPhotoLayer is ' +aPhotoLayer +' styleObject is ' +styleObject +' [imageView imageLayer]._DOMContentsElement is ' | |
+[imageView imageLayer]._DOMContentsElement); | |
if (CPBrowserIsEngine(CPWebKitBrowserEngine) && (typeof styleObject.WebkitTransform != "undefined")) | |
{ | |
styleObject.WebkitTransform = "scale(" + aScaleFactor + ")"; | |
[aPhotoLayer setNeedsDisplay]; | |
} | |
else if (CPBrowserIsEngine(CPGeckoBrowserEngine) && (typeof styleObject.MozTransform != "undefined")) | |
{ | |
styleObject.MozTransform = "scale(" + aScaleFactor + ")"; | |
[aPhotoLayer setNeedsDisplay]; | |
} | |
/* | |
else if (CPBrowserIsEngine(CPOperaBrowserEngine)) | |
{ | |
//transformName = '-o-transform'; | |
} | |
*/ | |
else | |
{ | |
var myTransform = CGAffineTransformMakeScale(aScaleFactor, aScaleFactor); | |
[aPhotoLayer setAffineTransform:myTransform]; | |
[aPhotoLayer setNeedsDisplay]; | |
} | |
/* | |
var myTransform = CGAffineTransformMakeScale(aScaleFactor, aScaleFactor); | |
[aPhotoLayer setAffineTransform:myTransform]; | |
[aPhotoLayer setNeedsDisplay]; | |
*/ | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment