|
| 1 | +import { AnimationReferenceMetadata } from '@angular/animations'; |
| 2 | +import { Component, ViewChild } from '@angular/core'; |
| 3 | +import { |
| 4 | + blink, fadeIn, fadeOut, flipBottom, flipHorBck, flipHorFwd, flipLeft, flipRight, flipTop, |
| 5 | + flipVerBck, flipVerFwd, growVerIn, growVerOut, heartbeat, |
| 6 | + IgxDialogComponent, IgxOverlayService, IListItemClickEventArgs, |
| 7 | + pulsateBck, pulsateFwd, rotateInBl, |
| 8 | + rotateInBottom, rotateInBr, rotateInCenter, rotateInDiagonal1, rotateInDiagonal2, rotateInHor, |
| 9 | + rotateInLeft, rotateInRight, rotateInTl, rotateInTop, rotateInTr, rotateInVer, rotateOutBl, |
| 10 | + rotateOutBottom, rotateOutBr, rotateOutCenter, rotateOutDiagonal1, rotateOutDiagonal2, |
| 11 | + rotateOutHor, rotateOutLeft, rotateOutRight, rotateOutTl, rotateOutTop, rotateOutTr, |
| 12 | + rotateOutVer, scaleInBl, scaleInBottom, scaleInBr, scaleInCenter, scaleInHorCenter, |
| 13 | + scaleInHorLeft, scaleInHorRight, scaleInLeft, scaleInRight, scaleInTl, scaleInTop, scaleInTr, |
| 14 | + scaleInVerBottom, scaleInVerCenter, scaleInVerTop, scaleOutBl, scaleOutBottom, scaleOutBr, |
| 15 | + scaleOutCenter, scaleOutHorCenter, scaleOutHorLeft, scaleOutHorRight, scaleOutLeft, |
| 16 | + scaleOutRight, scaleOutTl, scaleOutTop, scaleOutTr, scaleOutVerBottom, scaleOutVerCenter, |
| 17 | + scaleOutVerTop, shakeBl, shakeBottom, shakeBr, shakeCenter, shakeHor, shakeLeft, shakeRight, |
| 18 | + shakeTl, shakeTop, shakeTr, shakeVer, slideInBl, slideInBottom, slideInBr, slideInLeft, |
| 19 | + slideInRight, slideInTl, slideInTop, slideInTr, slideOutBl, slideOutBottom, slideOutBr, |
| 20 | + slideOutLeft, slideOutRight, slideOutTl, slideOutTop, slideOutTr, swingInBottomBck, |
| 21 | + swingInBottomFwd, swingInLeftBck, swingInLeftFwd, swingInRightBck, swingInRightFwd, |
| 22 | + swingInTopBck, swingInTopFwd, swingOutBottomBck, swingOutBottomFwd, swingOutLeftBck, |
| 23 | + swingOutLefttFwd, swingOutRightBck, swingOutRightFwd, swingOutTopBck, swingOutTopFwd |
| 24 | +} from 'igniteui-angular'; |
| 25 | +import { AbsolutePosition } from 'projects/igniteui-angular/src/lib/services/overlay/utilities'; |
| 26 | + |
| 27 | +@Component({ |
| 28 | + selector: 'app-animations-sample', |
| 29 | + styleUrls: ['animations.sample.scss'], |
| 30 | + templateUrl: 'animations.sample.html' |
| 31 | +}) |
| 32 | +export class AnimationsSampleComponent { |
| 33 | + @ViewChild('dialog', { static: true, read: IgxDialogComponent }) |
| 34 | + private dialog: IgxDialogComponent; |
| 35 | + |
| 36 | + public animationsCategories: string[] = [ |
| 37 | + 'fade', |
| 38 | + 'flip', |
| 39 | + 'grow', |
| 40 | + 'rotate', |
| 41 | + 'scale', |
| 42 | + 'slide', |
| 43 | + 'swing', |
| 44 | + 'shake', |
| 45 | + 'pulsate' |
| 46 | + ]; |
| 47 | + |
| 48 | + public animations: { name: string, animation: AnimationReferenceMetadata }[]; |
| 49 | + |
| 50 | + private fadeAnimations: { name: string, animation: AnimationReferenceMetadata }[] = [ |
| 51 | + { name: 'fadeIn', animation: fadeIn }, |
| 52 | + { name: 'fadeOut', animation: fadeOut }, |
| 53 | + ]; |
| 54 | + |
| 55 | + private flipAnimations: { name: string, animation: AnimationReferenceMetadata }[] = [ |
| 56 | + { name: 'flipTop', animation: flipTop }, |
| 57 | + { name: 'flipRight', animation: flipRight }, |
| 58 | + { name: 'flipBottom', animation: flipBottom }, |
| 59 | + { name: 'flipLeft', animation: flipLeft }, |
| 60 | + { name: 'flipHorFwd', animation: flipHorFwd }, |
| 61 | + { name: 'flipHorBck', animation: flipHorBck }, |
| 62 | + { name: 'flipVerFwd', animation: flipVerFwd }, |
| 63 | + { name: 'flipVerBck', animation: flipVerBck } |
| 64 | + ]; |
| 65 | + |
| 66 | + private growAnimations: { name: string, animation: AnimationReferenceMetadata }[] = [ |
| 67 | + { name: 'growVerIn', animation: growVerIn }, |
| 68 | + { name: 'growVerOut', animation: growVerOut }, |
| 69 | + ]; |
| 70 | + |
| 71 | + private rotateAnimations: { name: string, animation: AnimationReferenceMetadata }[] = [ |
| 72 | + { name: 'rotateInCenter', animation: rotateInCenter }, |
| 73 | + { name: 'rotateInTop', animation: rotateInTop }, |
| 74 | + { name: 'rotateInRight', animation: rotateInRight }, |
| 75 | + { name: 'rotateInLeft', animation: rotateInLeft }, |
| 76 | + { name: 'rotateInBottom', animation: rotateInBottom }, |
| 77 | + { name: 'rotateInTr', animation: rotateInTr }, |
| 78 | + { name: 'rotateInBr', animation: rotateInBr }, |
| 79 | + { name: 'rotateInBl', animation: rotateInBl }, |
| 80 | + { name: 'rotateInTl', animation: rotateInTl }, |
| 81 | + { name: 'rotateInDiagonal1', animation: rotateInDiagonal1 }, |
| 82 | + { name: 'rotateInDiagonal2', animation: rotateInDiagonal2 }, |
| 83 | + { name: 'rotateInHor', animation: rotateInHor }, |
| 84 | + { name: 'rotateInVer', animation: rotateInVer }, |
| 85 | + { name: 'rotateOutCenter', animation: rotateOutCenter }, |
| 86 | + { name: 'rotateOutTop', animation: rotateOutTop }, |
| 87 | + { name: 'rotateOutRight', animation: rotateOutRight }, |
| 88 | + { name: 'rotateOutLeft', animation: rotateOutLeft }, |
| 89 | + { name: 'rotateOutBottom', animation: rotateOutBottom }, |
| 90 | + { name: 'rotateOutTr', animation: rotateOutTr }, |
| 91 | + { name: 'rotateOutBr', animation: rotateOutBr }, |
| 92 | + { name: 'rotateOutBl', animation: rotateOutBl }, |
| 93 | + { name: 'rotateOutTl', animation: rotateOutTl }, |
| 94 | + { name: 'rotateOutDiagonal1', animation: rotateOutDiagonal1 }, |
| 95 | + { name: 'rotateOutDiagonal2', animation: rotateOutDiagonal2 }, |
| 96 | + { name: 'rotateOutHor', animation: rotateOutHor }, |
| 97 | + { name: 'rotateOutVer', animation: rotateOutVer } |
| 98 | + ]; |
| 99 | + |
| 100 | + private scaleAnimations: { name: string, animation: AnimationReferenceMetadata }[] = [ |
| 101 | + { name: 'scaleInTop', animation: scaleInTop }, |
| 102 | + { name: 'scaleInRight', animation: scaleInRight }, |
| 103 | + { name: 'scaleInBottom', animation: scaleInBottom }, |
| 104 | + { name: 'scaleInLeft', animation: scaleInLeft }, |
| 105 | + { name: 'scaleInCenter', animation: scaleInCenter }, |
| 106 | + { name: 'scaleInTr', animation: scaleInTr }, |
| 107 | + { name: 'scaleInBr', animation: scaleInBr }, |
| 108 | + { name: 'scaleInBl', animation: scaleInBl }, |
| 109 | + { name: 'scaleInTl', animation: scaleInTl }, |
| 110 | + { name: 'scaleInVerTop', animation: scaleInVerTop }, |
| 111 | + { name: 'scaleInVerBottom', animation: scaleInVerBottom }, |
| 112 | + { name: 'scaleInVerCenter', animation: scaleInVerCenter }, |
| 113 | + { name: 'scaleInHorCenter', animation: scaleInHorCenter }, |
| 114 | + { name: 'scaleInHorLeft', animation: scaleInHorLeft }, |
| 115 | + { name: 'scaleInHorRight', animation: scaleInHorRight }, |
| 116 | + { name: 'scaleOutTop', animation: scaleOutTop }, |
| 117 | + { name: 'scaleOutRight', animation: scaleOutRight }, |
| 118 | + { name: 'scaleOutBottom', animation: scaleOutBottom }, |
| 119 | + { name: 'scaleOutLeft', animation: scaleOutLeft }, |
| 120 | + { name: 'scaleOutCenter', animation: scaleOutCenter }, |
| 121 | + { name: 'scaleOutTr', animation: scaleOutTr }, |
| 122 | + { name: 'scaleOutBr', animation: scaleOutBr }, |
| 123 | + { name: 'scaleOutBl', animation: scaleOutBl }, |
| 124 | + { name: 'scaleOutTl', animation: scaleOutTl }, |
| 125 | + { name: 'scaleOutVerTop', animation: scaleOutVerTop }, |
| 126 | + { name: 'scaleOutVerBottom', animation: scaleOutVerBottom }, |
| 127 | + { name: 'scaleOutVerCenter', animation: scaleOutVerCenter }, |
| 128 | + { name: 'scaleOutHorCenter', animation: scaleOutHorCenter }, |
| 129 | + { name: 'scaleOutHorLeft', animation: scaleOutHorLeft }, |
| 130 | + { name: 'scaleOutHorRight', animation: scaleOutHorRight } |
| 131 | + ]; |
| 132 | + |
| 133 | + private slideAnimations: { name: string, animation: AnimationReferenceMetadata }[] = [ |
| 134 | + { name: 'slideInTop', animation: slideInTop }, |
| 135 | + { name: 'slideInRight', animation: slideInRight }, |
| 136 | + { name: 'slideInBottom', animation: slideInBottom }, |
| 137 | + { name: 'slideInLeft', animation: slideInLeft }, |
| 138 | + { name: 'slideInTr', animation: slideInTr }, |
| 139 | + { name: 'slideInBr', animation: slideInBr }, |
| 140 | + { name: 'slideInBl', animation: slideInBl }, |
| 141 | + { name: 'slideInTl', animation: slideInTl }, |
| 142 | + { name: 'slideOutTop', animation: slideOutTop }, |
| 143 | + { name: 'slideOutBottom', animation: slideOutBottom }, |
| 144 | + { name: 'slideOutRight', animation: slideOutRight }, |
| 145 | + { name: 'slideOutLeft', animation: slideOutLeft }, |
| 146 | + { name: 'slideOutTr', animation: slideOutTr }, |
| 147 | + { name: 'slideOutBr', animation: slideOutBr }, |
| 148 | + { name: 'slideOutBl', animation: slideOutBl }, |
| 149 | + { name: 'slideOutTl', animation: slideOutTl } |
| 150 | + ]; |
| 151 | + |
| 152 | + private swingAnimations: { name: string, animation: AnimationReferenceMetadata }[] = [ |
| 153 | + { name: 'swingInTopFwd', animation: swingInTopFwd }, |
| 154 | + { name: 'swingInRightFwd', animation: swingInRightFwd }, |
| 155 | + { name: 'swingInLeftFwd', animation: swingInLeftFwd }, |
| 156 | + { name: 'swingInBottomFwd', animation: swingInBottomFwd }, |
| 157 | + { name: 'swingInTopBck', animation: swingInTopBck }, |
| 158 | + { name: 'swingInRightBck', animation: swingInRightBck }, |
| 159 | + { name: 'swingInBottomBck', animation: swingInBottomBck }, |
| 160 | + { name: 'swingInLeftBck', animation: swingInLeftBck }, |
| 161 | + { name: 'swingOutTopFwd', animation: swingOutTopFwd }, |
| 162 | + { name: 'swingOutRightFwd', animation: swingOutRightFwd }, |
| 163 | + { name: 'swingOutBottomFwd', animation: swingOutBottomFwd }, |
| 164 | + { name: 'swingOutLefttFwd', animation: swingOutLefttFwd }, |
| 165 | + { name: 'swingOutTopBck', animation: swingOutTopBck }, |
| 166 | + { name: 'swingOutRightBck', animation: swingOutRightBck }, |
| 167 | + { name: 'swingOutBottomBck', animation: swingOutBottomBck }, |
| 168 | + { name: 'swingOutLeftBck', animation: swingOutLeftBck } |
| 169 | + ]; |
| 170 | + |
| 171 | + private shakeAnimations: { name: string, animation: AnimationReferenceMetadata }[] = [ |
| 172 | + { name: 'shakeHor', animation: shakeHor }, |
| 173 | + { name: 'shakeVer', animation: shakeVer }, |
| 174 | + { name: 'shakeTop', animation: shakeTop }, |
| 175 | + { name: 'shakeBottom', animation: shakeBottom }, |
| 176 | + { name: 'shakeRight', animation: shakeRight }, |
| 177 | + { name: 'shakeLeft', animation: shakeLeft }, |
| 178 | + { name: 'shakeCenter', animation: shakeCenter }, |
| 179 | + { name: 'shakeTr', animation: shakeTr }, |
| 180 | + { name: 'shakeBr', animation: shakeBr }, |
| 181 | + { name: 'shakeBl', animation: shakeBl }, |
| 182 | + { name: 'shakeTl', animation: shakeTl } |
| 183 | + ]; |
| 184 | + |
| 185 | + private pulsateAnimations: { name: string, animation: AnimationReferenceMetadata }[] = [ |
| 186 | + { name: 'heartbeat', animation: heartbeat }, |
| 187 | + { name: 'pulsateFwd', animation: pulsateFwd }, |
| 188 | + { name: 'pulsateBck', animation: pulsateBck }, |
| 189 | + { name: 'blink', animation: blink } |
| 190 | + ]; |
| 191 | + |
| 192 | + constructor() { |
| 193 | + this.animations = this.fadeAnimations; |
| 194 | + } |
| 195 | + |
| 196 | + public categoryItemClicked(e: IListItemClickEventArgs): void { |
| 197 | + const category = this.animationsCategories[e.item.index]; |
| 198 | + switch (category) { |
| 199 | + case 'fade': |
| 200 | + this.animations = this.fadeAnimations; |
| 201 | + break; |
| 202 | + case 'flip': |
| 203 | + this.animations = this.flipAnimations; |
| 204 | + break; |
| 205 | + case 'grow': |
| 206 | + this.animations = this.growAnimations; |
| 207 | + break; |
| 208 | + case 'rotate': |
| 209 | + this.animations = this.rotateAnimations; |
| 210 | + break; |
| 211 | + case 'scale': |
| 212 | + this.animations = this.scaleAnimations; |
| 213 | + break; |
| 214 | + case 'slide': |
| 215 | + this.animations = this.slideAnimations; |
| 216 | + break; |
| 217 | + case 'swing': |
| 218 | + this.animations = this.swingAnimations; |
| 219 | + break; |
| 220 | + case 'shake': |
| 221 | + this.animations = this.shakeAnimations; |
| 222 | + break; |
| 223 | + case 'pulsate': |
| 224 | + this.animations = this.pulsateAnimations; |
| 225 | + break; |
| 226 | + } |
| 227 | + } |
| 228 | + |
| 229 | + public playAnimation(e: IListItemClickEventArgs): void { |
| 230 | + const animation = this.animations[e.item.index].animation; |
| 231 | + if (animation.options?.params?.duration && animation.options?.params?.duration !== '1000ms') { |
| 232 | + animation.options.params.duration = '1000ms'; |
| 233 | + } |
| 234 | + const overlaySettings = IgxOverlayService.createAbsoluteOverlaySettings(AbsolutePosition.Center); |
| 235 | + overlaySettings.closeOnOutsideClick = true; |
| 236 | + overlaySettings.modal = true; |
| 237 | + overlaySettings.positionStrategy.settings.openAnimation = animation; |
| 238 | + overlaySettings.positionStrategy.settings.closeAnimation = null; |
| 239 | + this.dialog.open(overlaySettings); |
| 240 | + } |
| 241 | +} |
0 commit comments