forked from extnet/Ext.NET
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAnimConfig.cs
More file actions
441 lines (412 loc) · 16.2 KB
/
AnimConfig.cs
File metadata and controls
441 lines (412 loc) · 16.2 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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
/********
* @version : 2.1.1 - Ext.NET Pro License
* @author : Ext.NET, Inc. http://www.ext.net/
* @date : 2012-12-10
* @copyright : Copyright (c) 2007-2012, Ext.NET, Inc. (http://www.ext.net/). All rights reserved.
* @license : See license.txt and http://www.ext.net/license/.
********/
using System.ComponentModel;
using System.Text;
using System.Web.UI;
using Ext.Net.Utilities;
using System.Collections.Generic;
namespace Ext.Net
{
/// <summary>
/// Perform custom animation on this object.
///
/// This method is applicable to both the Component class and the Element class. It performs animated transitions of certain properties of this object over a specified timeline.
///
/// The sole parameter is an object which specifies start property values, end property values, and properties which describe the timeline.
///
/// Animating an Element
/// When animating an Element, the following properties may be specified in from, to, and keyframe objects:
///
/// x - The page X position in pixels.
/// y - The page Y position in pixels
/// left - The element's CSS left value. Units must be supplied.
/// top - The element's CSS top value. Units must be supplied.
/// width - The element's CSS width value. Units must be supplied.
/// height - The element's CSS height value. Units must be supplied.
/// scrollLeft - The element's scrollLeft value.
/// scrollTop - The element's scrollLeft value.
/// opacity - The element's opacity value. This must be a value between 0 and 1.
/// Be aware than animating an Element which is being used by an Ext Component without in some way informing the Component about the changed element state will result in incorrect Component behaviour. This is because the Component will be using the old state of the element. To avoid this problem, it is now possible to directly animate certain properties of Components.
///
/// Animating a Component
/// When animating a Component, the following properties may be specified in from, to, and keyframe objects:
///
/// x - The Component's page X position in pixels.
/// y - The Component's page Y position in pixels
/// left - The Component's left value in pixels.
/// top - The Component's top value in pixels.
/// width - The Component's width value in pixels.
/// width - The Component's width value in pixels.
/// dynamic - Specify as true to update the Component's layout (if it is a Container) at every frame of the animation. Use sparingly as laying out on every intermediate size change is an expensive operation.
/// </summary>
public partial class AnimConfig : BaseItem
{
/// <summary>
/// Used in conjunction with iterations to reverse the animation each time an iteration completes.
/// </summary>
[Meta]
[ConfigOption]
[Category("2. AnimConfig")]
[DefaultValue(false)]
[NotifyParentProperty(true)]
[Description("Used in conjunction with iterations to reverse the animation each time an iteration completes.")]
public virtual bool Alternate
{
get
{
return this.State.Get<bool>("Alternate", false);
}
set
{
this.State.Set("Alternate", value);
}
}
/// <summary>
/// A function to be run after the animation has completed.
/// </summary>
[Meta]
[ConfigOption(JsonMode.Raw)]
[Category("2. AnimConfig")]
[DefaultValue("")]
[NotifyParentProperty(true)]
[Description("A function to be run after the animation has completed.")]
public virtual string Callback
{
get
{
return this.State.Get<string>("Callback", "");
}
set
{
this.State.Set("Callback", value);
}
}
/// <summary>
/// The scope that the callback function will be called with
/// </summary>
[Meta]
[ConfigOption(JsonMode.Raw)]
[Category("2. AnimConfig")]
[DefaultValue("")]
[NotifyParentProperty(true)]
[Description("The scope that the callback function will be called with")]
public virtual string Scope
{
get
{
return this.State.Get<string>("Scope", "");
}
set
{
this.State.Set("Scope", value);
}
}
/// <summary>
/// Time to delay before starting the animation. Defaults to 0.
/// </summary>
[Meta]
[ConfigOption]
[Category("2. AnimConfig")]
[DefaultValue(0)]
[NotifyParentProperty(true)]
[Description("Time to delay before starting the animation. Defaults to 0.")]
public virtual int Delay
{
get
{
return this.State.Get<int>("Delay", 0);
}
set
{
this.State.Set("Delay", value);
}
}
/// <summary>
/// Time in milliseconds for the animation to last. Defaults to 250.
/// </summary>
[Meta]
[ConfigOption]
[Category("2. AnimConfig")]
[DefaultValue(250)]
[NotifyParentProperty(true)]
[Description("Time in milliseconds for the animation to last. Defaults to 250.")]
public virtual int Duration
{
get
{
return this.State.Get<int>("Duration", 250);
}
set
{
this.State.Set("Duration", value);
}
}
/// <summary>
/// Currently only for AbstractComponent Animation: Only set a component's outer element size bypassing layouts. Set to true to do full layouts for every frame of the animation. Defaults to false.
/// </summary>
[Meta]
[ConfigOption]
[Category("2. AnimConfig")]
[DefaultValue(false)]
[NotifyParentProperty(true)]
[Description("Currently only for AbstractComponent Animation: Only set a component's outer element size bypassing layouts. Set to true to do full layouts for every frame of the animation. Defaults to false.")]
public virtual bool Dynamic
{
get
{
return this.State.Get<bool>("Dynamic", false);
}
set
{
this.State.Set("Dynamic", value);
}
}
/// <summary>
/// This describes how the intermediate values used during a transition will be calculated. It allows for a transition to change speed over its duration.
/// Note that cubic-bezier will create a custom easing curve following the CSS3 transition-timing-function specification http://www.w3.org/TR/css3-transitions/-transition-timing-function_tag. The four values specify points P1 and P2 of the curve as (x1, y1, x2, y2). All values must be in the range [0, 1] or the definition is invalid
/// </summary>
[Meta]
[Category("2. AnimConfig")]
[DefaultValue(Easing.Ease)]
[NotifyParentProperty(true)]
[Description("This describes how the intermediate values used during a transition will be calculated. It allows for a transition to change speed over its duration.")]
public virtual Easing Easing
{
get
{
return this.State.Get<Easing>("Easing", Easing.Ease);
}
set
{
this.State.Set("Easing", value);
}
}
///<summary>
/// Using with Bezier easing only
/// Note that cubic-bezier will create a custom easing curve following the CSS3 transition-timing-function specification http://www.w3.org/TR/css3-transitions/-transition-timing-function_tag. The four values specify points P1 and P2 of the curve as (x1, y1, x2, y2). All values must be in the range [0, 1] or the definition is invalid
///</summary>
[Meta]
[Category("2. AnimConfig")]
[DefaultValue("")]
[NotifyParentProperty(true)]
[Description("This describes how the intermediate values used during a transition will be calculated. It allows for a transition to change speed over its duration.")]
public virtual string EasingArgs
{
get
{
return this.State.Get<string>("EasingArgs", "");
}
set
{
this.State.Set("EasingArgs", value);
}
}
/// <summary>
///
/// </summary>
[ConfigOption("easing")]
[DefaultValue("")]
protected virtual string EasingProxy
{
get
{
if (this.Easing == Easing.EaseNone || this.Easing == Easing.Ease)
{
return "";
}
string fn = this.Easing.ToString().ToLowerCamelCase();
if (this.EasingArgs.IsNotEmpty())
{
if (this.EasingArgs.StartsWith("(") && this.EasingArgs.EndsWith(")"))
{
fn = fn + this.EasingArgs;
}
else
{
fn = fn.ConcatWith("(", this.EasingArgs, ")");
}
}
return fn;
}
}
private ParameterCollection from;
///<summary>
/// An object containing property/value pairs for the beginning of the animation. If not specified, the current state of the Ext.fx.target will be used.
/// For example:
///
/// from : {
/// opacity: 0, // Transparent
/// color: '#ffffff', // White
/// left: 0
/// }
///</summary>
[Meta]
[ConfigOption(JsonMode.ArrayToObject)]
[Category("2. AnimConfig")]
[NotifyParentProperty(true)]
[PersistenceMode(PersistenceMode.InnerProperty)]
[Description("An object containing property/value pairs for the beginning of the animation. If not specified, the current state of the Ext.fx.target will be used.")]
public virtual ParameterCollection From
{
get
{
return this.from ?? (this.from = new ParameterCollection(false));
}
}
///<summary>
/// Number of times to execute the animation. Defaults to 1.
///</summary>
[Meta]
[ConfigOption]
[Category("2. AnimConfig")]
[DefaultValue(1)]
[NotifyParentProperty(true)]
[Description("Number of times to execute the animation. Defaults to 1.")]
public virtual int Iterations
{
get
{
return this.State.Get<int>("Iterations", 1);
}
set
{
this.State.Set("Iterations", value);
}
}
///<summary>
/// Animation keyframes follow the CSS3 Animation configuration pattern. 'from' is always considered '0%' and 'to' is considered '100%'.Every keyframe declaration must have a keyframe rule for 0% and 100%, possibly defined using "from" or "to". A keyframe declaration without these keyframe selectors is invalid and will not be available for animation. The keyframe declaration for a keyframe rule consists of properties and values. Properties that are unable to be animated are ignored in these rules, with the exception of 'easing' which can be changed at each keyframe.
/// Example:
/// keyframes : {
/// '0%': {
/// left: 100
/// },
/// '40%': {
/// left: 150
/// },
/// '60%': {
/// left: 75
/// },
/// '100%': {
/// left: 100
/// }
/// }
///</summary>
[Meta]
[Category("2. AnimConfig")]
[DefaultValue(null)]
[NotifyParentProperty(true)]
[Description("Animation keyframes follow the CSS3 Animation configuration pattern.")]
public virtual InsertOrderedDictionary<string,ParameterCollection> KeyFrames
{
get
{
return this.State.Get<InsertOrderedDictionary<string, ParameterCollection>>("KeyFrames", null);
}
set
{
this.State.Set("KeyFrames", value);
}
}
/// <summary>
///
/// </summary>
[ConfigOption("keyframes", JsonMode.Raw)]
[DefaultValue(null)]
protected virtual string KeyFramesProxy
{
get
{
if (this.KeyFrames == null || this.KeyFrames.Count == 0)
{
return null;
}
StringBuilder sb = new StringBuilder();
sb.Append("{");
foreach (KeyValuePair<string, ParameterCollection> keyFrame in this.KeyFrames)
{
if (keyFrame.Value != null && keyFrame.Value.Count > 0)
{
sb.Append(JSON.Serialize(keyFrame.Key));
sb.Append(":");
sb.Append(keyFrame.Value.ToJson());
sb.Append(",");
}
}
sb.Remove(sb.Length - 1, 1);
sb.Append("}");
return sb.Length > 2 ? sb.ToString() : null;
}
}
///<summary>
/// Run the animation from the end to the beginning. Defaults to false.
///</summary>
[Meta]
[ConfigOption]
[Category("2. AnimConfig")]
[DefaultValue(false)]
[NotifyParentProperty(true)]
[Description("Run the animation from the end to the beginning. Defaults to false.")]
public virtual bool Reverse
{
get
{
return this.State.Get<bool>("Reverse", false);
}
set
{
this.State.Set("Reverse", value);
}
}
private ParameterCollection to;
///<summary>
/// An object containing property/value pairs for the end of the animation.
/// For example:
///
/// to : {
/// opacity: 1, // Opaque
/// color: '#00ff00', // Green
/// left: 500
/// }
///</summary>
[Meta]
[ConfigOption(JsonMode.ArrayToObject)]
[Category("2. AnimConfig")]
[NotifyParentProperty(true)]
[PersistenceMode(PersistenceMode.InnerProperty)]
[Description("An object containing property/value pairs for the end of the animation.")]
public virtual ParameterCollection To
{
get
{
return this.to ?? (this.to = new ParameterCollection(false));
}
}
private AnimConfigListeners listeners;
/// <summary>
/// Client-side JavaScript Event Handlers
/// </summary>
[Meta]
[ConfigOption("listeners", JsonMode.Object)]
[Category("2. AnimConfig")]
[NotifyParentProperty(true)]
[PersistenceMode(PersistenceMode.InnerProperty)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
[Description("Client-side JavaScript Event Handlers")]
public AnimConfigListeners Listeners
{
get
{
if (this.listeners == null)
{
this.listeners = new AnimConfigListeners();
}
return this.listeners;
}
}
}
}