Repository navigation
Expand file tree
/
Copy pathCPWindow+animations.j
More file actions
182 lines (143 loc) · 6.32 KB
/
Copy pathCPWindow+animations.j
File metadata and controls
182 lines (143 loc) · 6.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
/*!
Created by Randy Luecke April 22nd 2011
Copyright RCLConcepts, LLC.
All right reserved.
This code is available under the MIT license.
*/
/*!
Window Animations:
Usage: This category extends CPWindow to allow for
prettier open and close animations.
You can specify where you want the animation to originate from,
and the speed you want the animation to happen.
By defaut the animation is 230ms long and originates from the
center of the window.
*/
CPWindowAnimationCornerTopLeft = "0% 0%";
CPWindowAnimationCornerTopCenter = "50% 0%";
CPWindowAnimationCornerTopRight = "100% 0%";
CPWindowAnimationCornerMiddleLeft = "0% 50%";
CPWindowAnimationCornerMiddleCenter = "50% 50%";
CPWindowAnimationCornerMiddleRight = "100% 50%";
CPWindowAnimationCornerBottomLeft = "0% 100%";
CPWindowAnimationCornerBottomCenter = "50% 100%";
CPWindowAnimationCornerBottomRight = "100% 100%";
@implementation CPWindow (OpenCloseAnimations)
/*!
The length of the animation. Values in ms. This defaults to 230ms;
*/
- (void)setAnimationLength:(float)aDuration
{
self.animationLength = aDuration;
}
/*!
Set the corner from which you want to animate from.
This defaults to the center
*/
- (void)setAnimationLocation:(WindowAnimationCorner)aCorner
{
self.animationOrigin = aCorner;
}
- (void)orderFontWithAnimation:(id)sender
{
[self orderFront:self];
var time = self.animationLength || "230",
corner = self.animationOrigin || CPWindowAnimationCornerMiddleCenter;
// apply the transforms
_DOMElement.style.WebkitTransitionDuration = time + "ms";
_DOMElement.style.WebkitTransitionTimingFunction = "ease-in-out";
_DOMElement.style.WebkitTransitionProperty = "-webkit-transform, opacity";
_DOMElement.style.WebkitTransformOrigin = corner;
_DOMElement.style.MozTransitionDuration = time + "ms";;
_DOMElement.style.MozTransitionTimingFunction = "ease-in-out";
_DOMElement.style.MozTransitionProperty = "-moz-transform, opacity";
_DOMElement.style.MozTransformOrigin = corner;
_DOMElement.style.transitionDuration = time + "ms";;
_DOMElement.style.transitionTimingFunction = "ease-in-out";
_DOMElement.style.transitionProperty = "transform, opacity";
_DOMElement.style.transformOrigin = corner;
// set initial value
_DOMElement.style.WebkitTransform = "scale(0)";
_DOMElement.style.MozTransform = "scale(0)";
_DOMElement.style.transform = "scale(0)";
_DOMElement.style.opacity = 0;
// animate it
window.setTimeout(function(){
// the _DOMElement is almost always 1x1px so we need to fix that.
_DOMElement.style.width = _frame.size.width + "px";
_DOMElement.style.height = _frame.size.height + "px";
_DOMElement.style.WebkitTransform = "scale(1)";
_DOMElement.style.MozTransform = "scale(1)";
_DOMElement.style.transform = "scale(1)";
_DOMElement.style.opacity = 1;
// clean that back up...
window.setTimeout(function(){
_DOMElement.style.width = "1px";
_DOMElement.style.height = "1px";
_DOMElement.style.WebkitTransitionDuration = "";
_DOMElement.style.WebkitTransitionTimingFunction = "";
_DOMElement.style.WebkitTransitionProperty = "";
_DOMElement.style.WebkitTransformOrigin = "";
_DOMElement.style.MozTransitionDuration = "";
_DOMElement.style.MozTransitionTimingFunction = "";
_DOMElement.style.MozTransitionProperty = "";
_DOMElement.style.MozTransformOrigin = "";
_DOMElement.style.transitionDuration = "";
_DOMElement.style.transitionTimingFunction = "";
_DOMElement.style.transitionProperty = "";
_DOMElement.style.transformOrigin = "";
}, self.animationLength);
},0);
}
- (void)orderOutWithAnimation:(id)sender
{
var time = self.animationLength || "230",
corner = self.animationOrigin || CPWindowAnimationCornerMiddleCenter;
// apply the transforms
_DOMElement.style.WebkitTransitionDuration = time + "ms";;
_DOMElement.style.WebkitTransitionTimingFunction = "ease-in-out";
_DOMElement.style.WebkitTransitionProperty = "-webkit-transform, opacity";
_DOMElement.style.WebkitTransformOrigin = corner;
_DOMElement.style.MozTransitionDuration = time + "ms";;
_DOMElement.style.MozTransitionTimingFunction = "ease-in-out";
_DOMElement.style.MozTransitionProperty = "-moz-transform, opacity";
_DOMElement.style.MozTransformOrigin = corner;
_DOMElement.style.transitionDuration = time + "ms";;
_DOMElement.style.transitionTimingFunction = "ease-in-out";
_DOMElement.style.transitionProperty = "transform, opacity";
_DOMElement.style.transformOrigin = corner;
// set initial value
_DOMElement.style.WebkitTransform = "scale(1)";
_DOMElement.style.MozTransform = "scale(1)";
_DOMElement.style.transform = "scale(1)";
_DOMElement.style.opacity = 1;
// animate it
window.setTimeout(function(){
// the _DOMElement is almost always 1x1px so we need to fix that.
_DOMElement.style.width = _frame.size.width + "px";
_DOMElement.style.height = _frame.size.height + "px";
_DOMElement.style.WebkitTransform = "scale(0)";
_DOMElement.style.MozTransform = "scale(0)";
_DOMElement.style.transform = "scale(0)";
_DOMElement.style.opacity = 0;
// clean that back up...
window.setTimeout(function(){
_DOMElement.style.width = "1px";
_DOMElement.style.height = "1px";
_DOMElement.style.WebkitTransitionDuration = "";
_DOMElement.style.WebkitTransitionTimingFunction = "";
_DOMElement.style.WebkitTransitionProperty = "";
_DOMElement.style.WebkitTransformOrigin = "";
_DOMElement.style.MozTransitionDuration = "";
_DOMElement.style.MozTransitionTimingFunction = "";
_DOMElement.style.MozTransitionProperty = "";
_DOMElement.style.MozTransformOrigin = "";
_DOMElement.style.transitionDuration = "";
_DOMElement.style.transitionTimingFunction = "";
_DOMElement.style.transitionProperty = "";
_DOMElement.style.transformOrigin = "";
[self orderOut:self];
}, self.animationLength);
},0);
}
@end