68 - (id)initWithViewAnimations:(
CPArray)viewAnimations
78 - (void)startAnimation
80 var animationIndex = [_viewAnimations count];
81 while (animationIndex--)
83 var dictionary = [_viewAnimations objectAtIndex:animationIndex],
84 view = [
self _targetView:dictionary],
85 startFrame = [
self _startFrame:dictionary];
87 [view setFrame:startFrame];
89 var effect = [
self _effect:dictionary];
92 [view setAlphaValue:0.0];
93 [
self _targetView:view setHidden:NO];
96 [view setAlphaValue:1.0];
102 - (void)setCurrentProgress:(CPAnimationProgress)progress
106 var animationIndex = [_viewAnimations count];
107 while (animationIndex--)
109 var dictionary = [_viewAnimations objectAtIndex:animationIndex],
110 view = [
self _targetView:dictionary],
111 startFrame = [
self _startFrame:dictionary],
112 endFrame = [
self _endFrame:dictionary],
113 differenceFrame = _CGRectMakeZero(),
116 differenceFrame.origin.x = endFrame.origin.x - startFrame.origin.x;
117 differenceFrame.origin.y = endFrame.origin.y - startFrame.origin.y;
118 differenceFrame.size.width = endFrame.size.width - startFrame.size.width;
119 differenceFrame.size.height = endFrame.size.height - startFrame.size.height;
121 var intermediateFrame = _CGRectMakeZero();
122 intermediateFrame.origin.x = startFrame.origin.x + differenceFrame.origin.x * value;
123 intermediateFrame.origin.y = startFrame.origin.y + differenceFrame.origin.y * value;
124 intermediateFrame.size.width = startFrame.size.width + differenceFrame.size.width * value;
125 intermediateFrame.size.height = startFrame.size.height + differenceFrame.size.height * value;
127 [view setFrame:intermediateFrame];
130 var effect = [
self _effect:dictionary];
132 [view setAlphaValue:1.0 * value];
134 [view setAlphaValue:1.0 + ( 0.0 - 1.0 ) * value];
136 if (progress === 1.0)
137 [
self _targetView:view setHidden:_CGRectIsNull(endFrame) || [view alphaValue] === 0.0];
141 - (void)stopAnimation
143 var animationIndex = [_viewAnimations count];
144 while (animationIndex--)
146 var dictionary = [_viewAnimations objectAtIndex:animationIndex],
147 view = [
self _targetView:dictionary],
148 endFrame = [
self _endFrame:dictionary];
150 [view setFrame:endFrame];
152 var effect = [
self _effect:dictionary];
154 [view setAlphaValue:1.0];
156 [view setAlphaValue:0.0];
158 [
self _targetView:view setHidden:_CGRectIsNull(endFrame) || [view alphaValue] === 0.0];
164 - (void)_targetView:(
id)theView setHidden:(BOOL)isHidden
166 if ([theView isKindOfClass:[
CPWindow class]])
169 [theView orderOut:self];
171 [theView orderFront:self];
174 [theView setHidden:isHidden];
179 var targetView = [dictionary
valueForKey:CPViewAnimationTargetKey];
188 var startFrame = [dictionary
valueForKey:CPViewAnimationStartFrameKey];
190 return [[
self _targetView:dictionary] frame];
197 var endFrame = [dictionary
valueForKey:CPViewAnimationEndFrameKey];
199 return [[
self _targetView:dictionary] frame];
206 return [dictionary
valueForKey:CPViewAnimationEffectKey];
211 return _viewAnimations;
219 - (void)setViewAnimations:(
CPArray)viewAnimations
221 if (viewAnimations != _viewAnimations)
224 _viewAnimations = [viewAnimations
copy];