@syncfusion/ej2-base 24.2.7 → 25.1.35-579988

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (163) hide show
  1. package/.eslintrc.json +2 -1
  2. package/CHANGELOG.md +641 -677
  3. package/{README.md → ReadMe.md} +100 -100
  4. package/dist/ej2-base.umd.min.js +1 -10
  5. package/dist/ej2-base.umd.min.js.map +1 -1
  6. package/dist/es6/ej2-base.es2015.js +178 -1025
  7. package/dist/es6/ej2-base.es2015.js.map +1 -1
  8. package/dist/es6/ej2-base.es5.js +226 -934
  9. package/dist/es6/ej2-base.es5.js.map +1 -1
  10. package/dist/global/ej2-base.min.js +1 -10
  11. package/dist/global/ej2-base.min.js.map +1 -1
  12. package/dist/global/index.d.ts +0 -9
  13. package/dist/ts/ajax.ts +236 -0
  14. package/dist/ts/animation.ts +544 -0
  15. package/dist/ts/base.ts +357 -0
  16. package/dist/ts/browser.ts +387 -0
  17. package/dist/ts/child-property.ts +192 -0
  18. package/dist/ts/component.ts +519 -0
  19. package/dist/ts/dom.ts +488 -0
  20. package/dist/ts/draggable.ts +1155 -0
  21. package/dist/ts/droppable.ts +172 -0
  22. package/dist/ts/event-handler.ts +169 -0
  23. package/dist/ts/internationalization.ts +369 -0
  24. package/dist/ts/intl/date-formatter.ts +317 -0
  25. package/dist/ts/intl/date-parser.ts +426 -0
  26. package/dist/ts/intl/intl-base.ts +1104 -0
  27. package/dist/ts/intl/number-formatter.ts +411 -0
  28. package/dist/ts/intl/number-parser.ts +158 -0
  29. package/dist/ts/intl/parser-base.ts +394 -0
  30. package/dist/ts/keyboard.ts +238 -0
  31. package/dist/ts/l10n.ts +94 -0
  32. package/dist/ts/module-loader.ts +149 -0
  33. package/dist/ts/notify-property-change.ts +726 -0
  34. package/dist/ts/observer.ts +236 -0
  35. package/dist/ts/sanitize-helper.ts +224 -0
  36. package/dist/ts/template-engine.ts +191 -0
  37. package/dist/ts/template.ts +329 -0
  38. package/dist/ts/touch.ts +544 -0
  39. package/dist/ts/util.ts +523 -0
  40. package/dist/ts/validate-lic.ts +0 -0
  41. package/e2e/crypto.js +16 -16
  42. package/e2e/m.protractor.config.js +286 -286
  43. package/e2e/modified-protractor/protractor.config.js +316 -316
  44. package/e2e/protractor.config.js +389 -332
  45. package/helpers/e2e/index.js +3 -3
  46. package/license +10 -10
  47. package/package.json +225 -174
  48. package/src/ajax.d.ts +1 -1
  49. package/src/ajax.js +3 -8
  50. package/src/animation-model.d.ts +41 -41
  51. package/src/animation.d.ts +6 -6
  52. package/src/animation.js +25 -25
  53. package/src/base.d.ts +2 -1
  54. package/src/base.js +9 -7
  55. package/src/component-model.d.ts +16 -16
  56. package/src/component.d.ts +9 -3
  57. package/src/component.js +50 -38
  58. package/src/draggable-model.d.ts +113 -113
  59. package/src/draggable.d.ts +2 -0
  60. package/src/draggable.js +45 -29
  61. package/src/droppable-model.d.ts +23 -23
  62. package/src/droppable.js +19 -19
  63. package/src/event-handler.js +2 -1
  64. package/src/index.d.ts +0 -3
  65. package/src/index.js +0 -3
  66. package/src/intl/date-formatter.js +2 -6
  67. package/src/intl/date-parser.js +1 -20
  68. package/src/intl/intl-base.js +1 -164
  69. package/src/intl/number-formatter.d.ts +3 -0
  70. package/src/intl/number-formatter.js +7 -7
  71. package/src/intl/number-parser.js +1 -0
  72. package/src/keyboard-model.d.ts +16 -16
  73. package/src/keyboard.js +19 -19
  74. package/src/module-loader.d.ts +12 -0
  75. package/src/module-loader.js +11 -0
  76. package/src/notify-property-change.js +3 -2
  77. package/src/observer.js +2 -0
  78. package/src/sanitize-helper.js +5 -0
  79. package/src/template-engine.js +1 -0
  80. package/src/template.js +3 -2
  81. package/src/touch-model.d.ts +39 -39
  82. package/src/touch.js +19 -19
  83. package/src/validate-lic.d.ts +0 -11
  84. package/src/validate-lic.js +1 -259
  85. package/styles/_all.scss +2 -2
  86. package/styles/_bds-dark-definition.scss +15 -0
  87. package/styles/_bds-definition.scss +15 -0
  88. package/styles/_bootstrap-dark-definition.scss +42 -42
  89. package/styles/_bootstrap-definition.scss +42 -42
  90. package/styles/_bootstrap4-definition.scss +11 -11
  91. package/styles/_bootstrap5-dark-definition.scss +9 -9
  92. package/styles/_bootstrap5-definition.scss +8 -8
  93. package/styles/_fabric-dark-definition.scss +42 -42
  94. package/styles/_fabric-definition.scss +42 -42
  95. package/styles/_fluent-dark-definition.scss +9 -9
  96. package/styles/_fluent-definition.scss +9 -9
  97. package/styles/_fluent2-definition.scss +9 -0
  98. package/styles/_fusionnew-dark-definition.scss +8 -8
  99. package/styles/_fusionnew-definition.scss +8 -8
  100. package/styles/_highcontrast-definition.scss +42 -42
  101. package/styles/_highcontrast-light-definition.scss +42 -42
  102. package/styles/_material-dark-definition.scss +48 -48
  103. package/styles/_material-definition.scss +49 -49
  104. package/styles/_material3-dark-definition.scss +14 -14
  105. package/styles/_material3-definition.scss +15 -15
  106. package/styles/_tailwind-dark-definition.scss +15 -15
  107. package/styles/_tailwind-definition.scss +15 -15
  108. package/styles/animation/_all.scss +560 -560
  109. package/styles/bootstrap-dark.css +10 -1
  110. package/styles/bootstrap.css +10 -1
  111. package/styles/bootstrap4.css +10 -1
  112. package/styles/bootstrap5-dark.css +10 -1
  113. package/styles/bootstrap5.css +10 -1
  114. package/styles/common/_all.scss +2 -2
  115. package/styles/common/_core.scss +117 -117
  116. package/styles/common/_mixin.scss +9 -9
  117. package/styles/definition/_bds-dark.scss +1179 -0
  118. package/styles/definition/_bds.scss +1474 -0
  119. package/styles/definition/_bootstrap-dark.scss +219 -219
  120. package/styles/definition/_bootstrap.scss +215 -215
  121. package/styles/definition/_bootstrap4.scss +167 -167
  122. package/styles/definition/_bootstrap5-dark.scss +493 -493
  123. package/styles/definition/_bootstrap5.scss +494 -494
  124. package/styles/definition/_fabric-dark.scss +200 -200
  125. package/styles/definition/_fabric.scss +198 -198
  126. package/styles/definition/_fluent-dark.scss +557 -557
  127. package/styles/definition/_fluent.scss +558 -558
  128. package/styles/definition/_fluent2.scss +2198 -0
  129. package/styles/definition/_fusionnew-dark.scss +362 -362
  130. package/styles/definition/_fusionnew.scss +363 -363
  131. package/styles/definition/_highcontrast-light.scss +193 -193
  132. package/styles/definition/_highcontrast.scss +195 -195
  133. package/styles/definition/_material-dark.scss +198 -198
  134. package/styles/definition/_material.scss +192 -192
  135. package/styles/definition/_material3-dark.scss +710 -710
  136. package/styles/definition/_material3.scss +792 -792
  137. package/styles/definition/_tailwind-dark.scss +488 -488
  138. package/styles/definition/_tailwind.scss +485 -485
  139. package/styles/fabric-dark.css +10 -1
  140. package/styles/fabric.css +10 -1
  141. package/styles/fluent-dark.css +10 -1
  142. package/styles/fluent.css +10 -1
  143. package/styles/highcontrast-light.css +10 -1
  144. package/styles/highcontrast.css +10 -1
  145. package/styles/material-dark.css +10 -1
  146. package/styles/material.css +10 -1
  147. package/styles/material3-dark.css +10 -1
  148. package/styles/material3.css +10 -1
  149. package/styles/offline-theme/material-dark.css +10 -1
  150. package/styles/offline-theme/material.css +10 -1
  151. package/styles/offline-theme/tailwind-dark.css +10 -1
  152. package/styles/offline-theme/tailwind.css +10 -1
  153. package/styles/tailwind-dark.css +10 -1
  154. package/styles/tailwind.css +10 -1
  155. package/.github/PULL_REQUEST_TEMPLATE/Bug.md +0 -60
  156. package/.github/PULL_REQUEST_TEMPLATE/feature.md +0 -42
  157. package/bin/syncfusion-license.js +0 -2
  158. package/dist/ej2-base.min.js +0 -10
  159. package/e2e/index.d.ts +0 -27
  160. package/src/fetch.d.ts +0 -114
  161. package/src/fetch.js +0 -116
  162. package/src/hijri-parser.d.ts +0 -19
  163. package/src/hijri-parser.js +0 -204
@@ -0,0 +1,544 @@
1
+ import { createElement, selectAll, closest } from './dom';
2
+ import { Base, EmitType } from './base';
3
+ import { Browser } from './browser';
4
+ import { EventHandler } from './event-handler';
5
+ import { AnimationModel } from './animation-model';
6
+ import { Property, NotifyPropertyChanges, INotifyPropertyChanged, Event } from './notify-property-change';
7
+
8
+ /**
9
+ * Animation effect names
10
+ */
11
+ export type Effect = 'FadeIn' | 'FadeOut' | 'FadeZoomIn' | 'FadeZoomOut' | 'FlipLeftDownIn' | 'FlipLeftDownOut' | 'FlipLeftUpIn' |
12
+ 'FlipLeftUpOut' | 'FlipRightDownIn' | 'FlipRightDownOut' | 'FlipRightUpIn' | 'FlipRightUpOut' | 'FlipXDownIn' | 'FlipXDownOut' |
13
+ 'FlipXUpIn' | 'FlipXUpOut' | 'FlipYLeftIn' | 'FlipYLeftOut' | 'FlipYRightIn' | 'FlipYRightOut' | 'SlideBottomIn' | 'SlideBottomOut' |
14
+ 'SlideDown' | 'SlideLeft' | 'SlideLeftIn' | 'SlideLeftOut' | 'SlideRight' | 'SlideRightIn' | 'SlideRightOut' | 'SlideTopIn' |
15
+ 'SlideTopOut' | 'SlideUp' | 'ZoomIn' | 'ZoomOut';
16
+
17
+ /**
18
+ * The Animation framework provide options to animate the html DOM elements
19
+ * ```typescript
20
+ * let animeObject = new Animation({
21
+ * name: 'SlideLeftIn',
22
+ * duration: 1000
23
+ * });
24
+ * animeObject.animate('#anime1');
25
+ * animeObject.animate('#anime2', { duration: 500 });
26
+ * ```
27
+ */
28
+ @NotifyPropertyChanges
29
+ export class Animation extends Base<HTMLElement> implements INotifyPropertyChanged {
30
+ /**
31
+ * Specify the type of animation
32
+ *
33
+ * @default : 'FadeIn';
34
+ */
35
+ @Property('FadeIn')
36
+ public name: Effect;
37
+ /**
38
+ * Specify the duration to animate
39
+ *
40
+ * @default : 400;
41
+ */
42
+ @Property(400)
43
+ public duration: number;
44
+ /**
45
+ * Specify the animation timing function
46
+ *
47
+ * @default : 'ease';
48
+ */
49
+ @Property('ease')
50
+ public timingFunction: string;
51
+ /**
52
+ * Specify the delay to start animation
53
+ *
54
+ * @default : 0;
55
+ */
56
+ @Property(0)
57
+ public delay: number;
58
+ /**
59
+ * Triggers when animation is in-progress
60
+ *
61
+ * @event progress
62
+ */
63
+ @Event()
64
+ public progress: EmitType<AnimationOptions>;
65
+ /**
66
+ * Triggers when the animation is started
67
+ *
68
+ * @event begin
69
+ */
70
+ @Event()
71
+ public begin: EmitType<AnimationOptions>;
72
+
73
+ /**
74
+ * Triggers when animation is completed
75
+ *
76
+ * @event end
77
+ */
78
+ @Event()
79
+ public end: EmitType<AnimationOptions>;
80
+
81
+ /**
82
+ * Triggers when animation is failed due to any scripts
83
+ *
84
+ * @event fail
85
+ */
86
+ @Event()
87
+ public fail: EmitType<AnimationOptions>;
88
+
89
+ /**
90
+ * @private
91
+ */
92
+ public easing: { [key: string]: string } = {
93
+ ease: 'cubic-bezier(0.250, 0.100, 0.250, 1.000)',
94
+ linear: 'cubic-bezier(0.250, 0.250, 0.750, 0.750)',
95
+ easeIn: 'cubic-bezier(0.420, 0.000, 1.000, 1.000)',
96
+ easeOut: 'cubic-bezier(0.000, 0.000, 0.580, 1.000)',
97
+ easeInOut: 'cubic-bezier(0.420, 0.000, 0.580, 1.000)',
98
+ elasticInOut: 'cubic-bezier(0.5,-0.58,0.38,1.81)',
99
+ elasticIn: 'cubic-bezier(0.17,0.67,0.59,1.81)',
100
+ elasticOut: 'cubic-bezier(0.7,-0.75,0.99,1.01)'
101
+ };
102
+
103
+ constructor(options: AnimationModel) {
104
+ super(options, undefined);
105
+ }
106
+
107
+ /**
108
+ * Applies animation to the current element.
109
+ *
110
+ * @param {string | HTMLElement} element - Element which needs to be animated.
111
+ * @param {AnimationModel} options - Overriding default animation settings.
112
+ * @returns {void} ?
113
+ */
114
+ public animate(element: string | HTMLElement, options?: AnimationModel): void {
115
+ options = !options ? {} : options;
116
+ const model: AnimationOptions = this.getModel(options);
117
+ if (typeof element === 'string') {
118
+ const elements: HTMLElement[] = Array.prototype.slice.call(selectAll(element, document));
119
+ for (const element of elements) {
120
+ model.element = element;
121
+ Animation.delayAnimation(model);
122
+ }
123
+ } else {
124
+ model.element = element;
125
+ Animation.delayAnimation(model);
126
+ }
127
+ }
128
+
129
+ /**
130
+ * Stop the animation effect on animated element.
131
+ *
132
+ * @param {HTMLElement} element - Element which needs to be stop the animation.
133
+ * @param {AnimationOptions} model - Handling the animation model at stop function.
134
+ * @return {void}
135
+ */
136
+
137
+ public static stop(element: HTMLElement, model?: AnimationOptions): void {
138
+ element.style.animation = '';
139
+ element.removeAttribute('e-animate');
140
+ const animationId: string = element.getAttribute('e-animation-id');
141
+ if (animationId) {
142
+ const frameId: number = parseInt(animationId, 10);
143
+ cancelAnimationFrame(frameId);
144
+ element.removeAttribute('e-animation-id');
145
+ }
146
+ if (model && model.end) {
147
+ model.end.call(this, model);
148
+ }
149
+ }
150
+
151
+ /**
152
+ * Set delay to animation element
153
+ *
154
+ * @param {AnimationModel} model ?
155
+ * @returns {void}
156
+ */
157
+
158
+ private static delayAnimation(model: AnimationModel): void {
159
+ if (animationMode === 'Disable' || animationMode === GlobalAnimationMode.Disable) {
160
+ if (model.begin) {
161
+ model.begin.call(this, model);
162
+ }
163
+ if (model.end) {
164
+ model.end.call(this, model);
165
+ }
166
+ }
167
+ else {
168
+ if (model.delay) {
169
+ setTimeout(() => { Animation.applyAnimation(model); }, model.delay);
170
+ } else {
171
+ Animation.applyAnimation(model);
172
+ }
173
+ }
174
+ }
175
+
176
+ /**
177
+ * Triggers animation
178
+ *
179
+ * @param {AnimationModel} model ?
180
+ * @returns {void}
181
+ */
182
+
183
+ private static applyAnimation(model: AnimationOptions): void {
184
+ model.timeStamp = 0;
185
+ let step: number = 0;
186
+ let timerId: number = 0;
187
+ let prevTimeStamp: number = 0;
188
+ const duration: number = model.duration;
189
+ model.element.setAttribute('e-animate', 'true');
190
+ const startAnimation: (timeStamp?: number) => void = (timeStamp?: number): void => {
191
+ try {
192
+ if (timeStamp) {
193
+ // let step: number = model.timeStamp = timeStamp - startTime;
194
+ /** phantomjs workaround for timestamp fix */
195
+ prevTimeStamp = prevTimeStamp === 0 ? timeStamp : prevTimeStamp;
196
+ model.timeStamp = (timeStamp + model.timeStamp) - prevTimeStamp;
197
+ prevTimeStamp = timeStamp;
198
+ /** phantomjs workaround end */
199
+ // trigger animation begin event
200
+ if (!step && model.begin) {
201
+ model.begin.call(this, model);
202
+ }
203
+ step = step + 1;
204
+ const avg: number = model.timeStamp / step;
205
+ if (model.timeStamp < duration && model.timeStamp + avg < duration && model.element.getAttribute('e-animate')) {
206
+ // apply animation effect to the current element
207
+ model.element.style.animation = model.name + ' ' + model.duration + 'ms ' + model.timingFunction;
208
+ if (model.progress) {
209
+ model.progress.call(this, model);
210
+ }
211
+ // repeat requestAnimationFrame
212
+ requestAnimationFrame(startAnimation);
213
+ } else {
214
+ // clear requestAnimationFrame
215
+ cancelAnimationFrame(timerId);
216
+ model.element.removeAttribute('e-animation-id');
217
+ model.element.removeAttribute('e-animate');
218
+ model.element.style.animation = '';
219
+ if (model.end) {
220
+ model.end.call(this, model);
221
+ }
222
+ }
223
+ } else {
224
+ //startTime = performance.now();
225
+ // set initial requestAnimationFrame
226
+ timerId = requestAnimationFrame(startAnimation);
227
+ model.element.setAttribute('e-animation-id', timerId.toString());
228
+ }
229
+ } catch (e) {
230
+ cancelAnimationFrame(timerId);
231
+ model.element.removeAttribute('e-animation-id');
232
+ if (model.fail) {
233
+ model.fail.call(this, e);
234
+ }
235
+ }
236
+ };
237
+ startAnimation();
238
+ }
239
+
240
+ /**
241
+ * Returns Animation Model
242
+ *
243
+ * @param {AnimationModel} options ?
244
+ * @returns {AnimationModel} ?
245
+ */
246
+
247
+ private getModel(options: AnimationModel): AnimationModel {
248
+ return {
249
+ name: options.name || this.name,
250
+ delay: options.delay || this.delay,
251
+ duration: (options.duration !== undefined ? options.duration : this.duration),
252
+ begin: options.begin || this.begin,
253
+ end: options.end || this.end,
254
+ fail: options.fail || this.fail,
255
+ progress: options.progress || this.progress,
256
+ timingFunction: this.easing[options.timingFunction] ? this.easing[options.timingFunction] :
257
+ (options.timingFunction || this.easing[this.timingFunction])
258
+ };
259
+ }
260
+
261
+ /**
262
+ * @private
263
+ * @param {AnimationModel} newProp ?
264
+ * @param {AnimationModel} oldProp ?
265
+ * @returns {void} ?
266
+ */
267
+ // eslint-disable-next-line
268
+ public onPropertyChanged(newProp: AnimationModel, oldProp: AnimationModel): void {
269
+ // no code needed
270
+ }
271
+ /**
272
+ * Returns module name as animation
273
+ *
274
+ * @private
275
+ * @returns {void} ?
276
+ */
277
+ public getModuleName(): string {
278
+ return 'animation';
279
+ }
280
+
281
+ /**
282
+ *
283
+ * @private
284
+ * @returns {void} ?
285
+ */
286
+ public destroy(): void {
287
+ //Override base destroy;
288
+ }
289
+ }
290
+
291
+ /**
292
+ * Animation event argument for progress event handler
293
+ */
294
+ export interface AnimationOptions extends AnimationModel {
295
+ /**
296
+ * Get current time-stamp in progress EventHandler
297
+ */
298
+ timeStamp?: number;
299
+ /**
300
+ * Get current animation element in progress EventHandler
301
+ */
302
+ element?: HTMLElement;
303
+ }
304
+
305
+ /**
306
+ * Ripple provides material theme's wave effect when an element is clicked
307
+ * ```html
308
+ * <div id='ripple'></div>
309
+ * <script>
310
+ * rippleEffect(document.getElementById('ripple'));
311
+ * </script>
312
+ * ```
313
+ *
314
+ * @private
315
+ * @param {HTMLElement} element - Target element
316
+ * @param {RippleOptions} rippleOptions - Ripple options .
317
+ * @param {Function} done .
318
+ * @returns {void} .
319
+ */
320
+ export function rippleEffect(element: HTMLElement, rippleOptions?: RippleOptions, done?: Function): () => void {
321
+ const rippleModel: RippleOptions = getRippleModel(rippleOptions);
322
+ if (rippleModel.rippleFlag === false || (rippleModel.rippleFlag === undefined && !isRippleEnabled)) {
323
+ return (() => {
324
+ // do nothing.
325
+ });
326
+ }
327
+ element.setAttribute('data-ripple', 'true');
328
+ EventHandler.add(element, 'mousedown', rippleHandler, { parent: element, rippleOptions: rippleModel });
329
+ EventHandler.add(element, 'mouseup', rippleUpHandler, { parent: element, rippleOptions: rippleModel, done: done });
330
+ EventHandler.add(element, 'mouseleave', rippleLeaveHandler, { parent: element, rippleOptions: rippleModel });
331
+ if (Browser.isPointer) {
332
+ EventHandler.add(element, 'transitionend', rippleLeaveHandler, { parent: element, rippleOptions: rippleModel });
333
+ }
334
+
335
+ return (() => {
336
+ element.removeAttribute('data-ripple');
337
+ EventHandler.remove(element, 'mousedown', rippleHandler);
338
+ EventHandler.remove(element, 'mouseup', rippleUpHandler);
339
+ EventHandler.remove(element, 'mouseleave', rippleLeaveHandler);
340
+ EventHandler.remove(element, 'transitionend', rippleLeaveHandler);
341
+ });
342
+ }
343
+
344
+ /**
345
+ * Ripple method arguments to handle ripple effect
346
+ *
347
+ * @private
348
+ */
349
+ export interface RippleOptions {
350
+ /**
351
+ * Get selector child elements for ripple effect
352
+ */
353
+ selector?: string;
354
+ /**
355
+ * Get ignore elements to prevent ripple effect
356
+ */
357
+ ignore?: string;
358
+ /**
359
+ * Override the enableRipple method
360
+ */
361
+ rippleFlag?: boolean;
362
+ /**
363
+ * Set ripple effect from center position
364
+ */
365
+ isCenterRipple?: boolean;
366
+ /**
367
+ * Set ripple duration
368
+ */
369
+ duration?: number;
370
+ }
371
+
372
+ /**
373
+ * Handler for ripple model
374
+ *
375
+ * @param {RippleOptions} rippleOptions ?
376
+ * @returns {RippleOptions} ?
377
+ */
378
+ function getRippleModel(rippleOptions?: RippleOptions): RippleOptions {
379
+ const rippleModel: RippleOptions = {
380
+ selector: rippleOptions && rippleOptions.selector ? rippleOptions.selector : null,
381
+ ignore: rippleOptions && rippleOptions.ignore ? rippleOptions.ignore : null,
382
+ rippleFlag: rippleOptions && rippleOptions.rippleFlag,
383
+ isCenterRipple: rippleOptions && rippleOptions.isCenterRipple,
384
+ duration: rippleOptions && rippleOptions.duration ? rippleOptions.duration : 350
385
+ };
386
+ return rippleModel;
387
+ }
388
+
389
+ /**
390
+ * Handler for ripple event
391
+ *
392
+ * @param {MouseEvent} e ?
393
+ * @returns {void} ?
394
+ * @private
395
+ */
396
+ function rippleHandler(e: MouseEvent): void {
397
+ const target: HTMLElement = <HTMLElement>(e.target);
398
+ const selector: string = this.rippleOptions.selector;
399
+ const element: HTMLElement = selector ? <HTMLElement>closest(target, selector) : target;
400
+ if (!element || (this.rippleOptions && closest(target, this.rippleOptions.ignore))) {
401
+ return;
402
+ }
403
+ const offset: ClientRect = element.getBoundingClientRect();
404
+ const offsetX: number = e.pageX - document.body.scrollLeft;
405
+ const offsetY: number = e.pageY - ((!document.body.scrollTop && document.documentElement) ?
406
+ document.documentElement.scrollTop : document.body.scrollTop);
407
+ const pageX: number = Math.max(Math.abs(offsetX - offset.left), Math.abs(offsetX - offset.right));
408
+ const pageY: number = Math.max(Math.abs(offsetY - offset.top), Math.abs(offsetY - offset.bottom));
409
+ const radius: number = Math.sqrt(pageX * pageX + pageY * pageY);
410
+ let diameter: string = radius * 2 + 'px';
411
+ let x: number = offsetX - offset.left - radius;
412
+ let y: number = offsetY - offset.top - radius;
413
+ if (this.rippleOptions && this.rippleOptions.isCenterRipple) {
414
+ x = 0;
415
+ y = 0;
416
+ diameter = '100%';
417
+ }
418
+ element.classList.add('e-ripple');
419
+ const duration: string = this.rippleOptions.duration.toString();
420
+ const styles: string = 'width: ' + diameter + ';height: ' + diameter + ';left: ' + x + 'px;top: ' + y + 'px;' +
421
+ 'transition-duration: ' + duration + 'ms;';
422
+ const rippleElement: HTMLElement = createElement('div', { className: 'e-ripple-element', styles: styles });
423
+ element.appendChild(rippleElement);
424
+ window.getComputedStyle(rippleElement).getPropertyValue('opacity');
425
+ rippleElement.style.transform = 'scale(1)';
426
+
427
+ if (element !== this.parent) {
428
+ EventHandler.add(element, 'mouseleave', rippleLeaveHandler, { parent: this.parent, rippleOptions: this.rippleOptions });
429
+ }
430
+ }
431
+
432
+ /**
433
+ * Handler for ripple element mouse up event
434
+ *
435
+ * @param {MouseEvent} e ?
436
+ * @returns {void} ?
437
+ * @private
438
+ */
439
+ function rippleUpHandler(e: MouseEvent): void {
440
+ removeRipple(e, this);
441
+ }
442
+
443
+ /**
444
+ * Handler for ripple element mouse move event
445
+ *
446
+ * @param {MouseEvent} e ?
447
+ * @returns {void} ?
448
+ * @private
449
+ */
450
+ function rippleLeaveHandler(e: MouseEvent): void {
451
+ removeRipple(e, this);
452
+ }
453
+
454
+ /**
455
+ * Handler for removing ripple element
456
+ *
457
+ * @param {MouseEvent} e ?
458
+ * @param {RippleArgs} eventArgs ?
459
+ * @returns {void} ?
460
+ * @private
461
+ */
462
+ function removeRipple(e: MouseEvent, eventArgs: RippleArgs): void {
463
+ const duration: number = eventArgs.rippleOptions.duration;
464
+ const target: HTMLElement = <HTMLElement>(e.target);
465
+ const selector: string = eventArgs.rippleOptions.selector;
466
+ const element: HTMLElement = selector ? <HTMLElement>closest(target, selector) : target;
467
+ if (!element || (element && element.className.indexOf('e-ripple') === -1)) {
468
+ return;
469
+ }
470
+ const rippleElements: HTMLElement[] = selectAll('.e-ripple-element', element);
471
+ const rippleElement: HTMLElement = rippleElements[rippleElements.length - 1];
472
+ if (rippleElement) {
473
+ rippleElement.style.opacity = '0.5';
474
+ }
475
+ if (eventArgs.parent !== element) {
476
+ EventHandler.remove(element, 'mouseleave', rippleLeaveHandler);
477
+ }
478
+ /* tslint:disable:align */
479
+ setTimeout(() => {
480
+ if (rippleElement && rippleElement.parentNode) {
481
+ rippleElement.parentNode.removeChild(rippleElement);
482
+ }
483
+ if (!element.getElementsByClassName('e-ripple-element').length) {
484
+ element.classList.remove('e-ripple');
485
+ }
486
+ if (eventArgs.done) {
487
+ eventArgs.done(e);
488
+ }
489
+ }, duration);
490
+ }
491
+
492
+ interface RippleArgs {
493
+ parent: HTMLElement;
494
+ selector: string;
495
+ rippleOptions: RippleOptions;
496
+ done: Function;
497
+ }
498
+ export let isRippleEnabled: boolean = false;
499
+
500
+ /**
501
+ * Animation Module provides support to enable ripple effect functionality to Essential JS 2 components.
502
+ *
503
+ * @param {boolean} isRipple Specifies the boolean value to enable or disable ripple effect.
504
+ * @returns {boolean} ?
505
+ */
506
+ export function enableRipple(isRipple: boolean): boolean {
507
+ isRippleEnabled = isRipple;
508
+ return isRippleEnabled;
509
+ }
510
+
511
+ /**
512
+ * Defines the Modes of Global animation.
513
+ *
514
+ * @private
515
+ */
516
+ export let animationMode: string | GlobalAnimationMode;
517
+
518
+ /**
519
+ * This method is used to enable or disable the animation for all components.
520
+ *
521
+ * @param {string|GlobalAnimationMode} value - Specifies the value to enable or disable the animation for all components. When set to 'enable', it enables the animation for all components, regardless of the individual component's animation settings. When set to 'disable', it disables the animation for all components, regardless of the individual component's animation settings.
522
+ * @returns {void}
523
+ */
524
+ export function setGlobalAnimation(value: string | GlobalAnimationMode): void {
525
+ animationMode = value;
526
+ }
527
+
528
+ /**
529
+ * Defines the global animation modes for all components.
530
+ */
531
+ export enum GlobalAnimationMode {
532
+ /**
533
+ * Defines the global animation mode as Default. Animation is enabled or disabled based on the component's animation settings.
534
+ */
535
+ Default = 'Default',
536
+ /**
537
+ * Defines the global animation mode as Enable. Enables the animation for all components, regardless of the individual component's animation settings.
538
+ */
539
+ Enable = 'Enable',
540
+ /**
541
+ * Defines the global animation mode as Disable. Disables the animation for all components, regardless of the individual component's animation settings.
542
+ */
543
+ Disable = 'Disable'
544
+ }