Created
November 22, 2008 10:07
-
-
Save ku/27796 to your computer and use it in GitHub Desktop.
iview transform js test
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
var anim = 1; | |
if ( anim ){ | |
UIView.beginAnimations_context(null, null); | |
UIView.setAnimationDuration(0.4) | |
} | |
var orientation = 1; | |
var x = TransitionView.image.image.size.width; | |
var y = TransitionView.image.image.size.height; | |
var height = 460; | |
var width =320; | |
var X = ((orientation%2)?y:x); | |
var Y = ((orientation%2)?x:y); | |
var zx = ( width / X ); | |
var zy = ( height / Y ); | |
var zoom = (zx > zy) ? zy : zx; | |
zoom = (zoom>1) ? 1 : zoom; | |
if ( zoom * Y > height - 65 ) { | |
TransitionView.image.center = new CGPoint(160, 0 + ( Y*zoom) /2 ); | |
} else if ( zoom *Y < height - 65 ) { | |
TransitionView.image.center = new CGPoint(160, (height - 65)/2); | |
} else if ( zoom *Y < height - 45 ) { | |
TransitionView.image.center = new CGPoint(160, (height - 45) /2 ); | |
} else { | |
TransitionView.image.center = new CGPoint(160, 230); | |
} | |
var tx = 0; | |
var ty = 0; | |
var rad = (Math.PI / 2) * orientation; | |
var a = Math.cos(rad) * zoom; | |
var b = Math.sin(rad)*zoom | |
var c = - Math.sin(rad)*zoom | |
var d = Math.cos(rad) * zoom; | |
var t = new CGAffineTransform(a,b,c,d,tx,ty); | |
TransitionView.image.transform = t; | |
if ( anim) { | |
UIVIew.commitAnimations() | |
} | |
var center = TransitionView.image.center; | |
[zoom,x,y, center.x, center.y ,X,Y, X*zoom, Y*zoom]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment