@angular/animations#sequence TypeScript Examples

The following examples show how to use @angular/animations#sequence. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: banner.component.ts    From avid-covider with MIT License 5 votes vote down vote up
@Component({
  selector: 'app-banner',
  templateUrl: './banner.component.html',
  styleUrls: ['./banner.component.less'],
  animations: [
    trigger('openClose', [
      state('open', style({ transform: 'translateY(0%)' })),
      state('closed', style({ transform: 'translateY(-100%)', display: 'none'})),
      transition('open => closed', [
        sequence([
          animate('0.25s 0s ease-in', keyframes([
            style({transform: 'translateY(0%)'}),
            style({transform: 'translateY(-100%)'})
          ])),
          style({display: 'none'})
        ])
      ]),
      transition('closed => open', [
        sequence([
          style({display: 'flex'}),
          animate('0.25s 0s ease-out', keyframes([
            style({transform: 'translateY(-100%)'}),
            style({transform: 'translateY(0%)'})
          ]))
        ])
      ])
    ])
  ]
})
export class BannerComponent implements OnInit {

  @Input() message: string = null;
  @Input() buttonMessage: string = null;
  @Output() result = new EventEmitter<boolean>();

  constructor() { }

  ngOnInit() {
  }

  close(value) {
    this.message = null;
    this.result.emit(value);
  }

}
Example #2
Source File: reminder-widget.component.ts    From avid-covider with MIT License 5 votes vote down vote up
@Component({
  selector: 'app-reminder-widget',
  templateUrl: './reminder-widget.component.html',
  styleUrls: ['./reminder-widget.component.less'],
  animations: [
    trigger('openClose', [
      state('open', style({transform: 'translateY(0%)'})),
      state('closed', style({transform: 'translateY(100%)', display: 'none'})),
      transition('open => closed', [
        sequence([
          animate('0.25s 0s ease-in', keyframes([
            style({transform: 'translateY(0%)'}),
            style({transform: 'translateY(100%)'})
          ])),
          style({display: 'none'})
        ])
      ]),
      transition('closed => open', [
        sequence([
          style({display: 'flex'}),
          animate('0.25s 0s ease-out', keyframes([
            style({transform: 'translateY(100%)'}),
            style({transform: 'translateY(0%)'})
          ]))
        ])
      ])
    ])
  ]
})
export class ReminderWidgetComponent implements OnInit, OnChanges {

  @Output() select = new EventEmitter<string>();
  @Input() options: any[] = null;

  isOpen = false;

  constructor() { }

  ngOnInit() {
  }

  resolve(value?) {
    this.select.emit(value);
    this.isOpen = false;
  }

  ngOnChanges() {
    this.isOpen = !!this.options && !!this.options.length;
  }
}
Example #3
Source File: toaster.component.ts    From avid-covider with MIT License 5 votes vote down vote up
@Component({
  selector: 'app-toaster',
  templateUrl: './toaster.component.html',
  styleUrls: ['./toaster.component.less'],
  animations: [
    trigger('openClose', [
      state('closed', style({ filter: 'blur(20px)', transform: 'translateY(-35%)', opacity: 0, display: 'none'})),
      state('open', style({ filter: 'blur(0px)', transform: 'translateY(0%)', opacity: 1, })),
      transition('open => closed', [
        sequence([
          animate('0.5s', keyframes([
            style({ filter: 'blur(0px)', transform: 'translateY(0%)', opacity: 1 }),
            style({ filter: 'blur(20px)', transform: 'translateY(-35%)', opacity: 0 })
          ])),
          style({ display: 'none' })
        ])
      ]),
      transition('closed => open', [
        sequence([
          style({ display: 'flex' }),
          animate('0.5s', keyframes([
            style({ filter: 'blur(20px)', transform: 'translateY(-35%)', opacity: 0 }),
            style({ filter: 'blur(0px)', transform: 'translateY(0%)', opacity: 1 })
          ]))
        ])
      ])
    ])
  ]
})
export class ToasterComponent implements OnInit, OnChanges {

  @Input() message: string = null;

  constructor() { }

  ngOnInit() {
  }

  ngOnChanges(): void {
    if (this.message) {
      setTimeout(() => {
        this.message = null;
      }, 5000);
    }
  }

}
Example #4
Source File: route.animations.ts    From enterprise-ng-2020-workshop with MIT License 5 votes vote down vote up
STEPS_ALL: any[] = [
  query(':enter > *', style({ opacity: 0, position: 'fixed' }), {
    optional: true
  }),
  query(':enter .' + ROUTE_ANIMATIONS_ELEMENTS, style({ opacity: 0 }), {
    optional: true
  }),
  sequence([
    query(
      ':leave > *',
      [
        style({ transform: 'translateY(0%)', opacity: 1 }),
        animate(
          '0.2s ease-in-out',
          style({ transform: 'translateY(-3%)', opacity: 0 })
        ),
        style({ position: 'fixed' })
      ],
      { optional: true }
    ),
    query(
      ':enter > *',
      [
        style({
          transform: 'translateY(-3%)',
          opacity: 0,
          position: 'static'
        }),
        animate(
          '0.5s ease-in-out',
          style({ transform: 'translateY(0%)', opacity: 1 })
        )
      ],
      { optional: true }
    )
  ]),
  query(
    ':enter .' + ROUTE_ANIMATIONS_ELEMENTS,
    stagger(75, [
      style({ transform: 'translateY(10%)', opacity: 0 }),
      animate(
        '0.5s ease-in-out',
        style({ transform: 'translateY(0%)', opacity: 1 })
      )
    ]),
    { optional: true }
  )
]
Example #5
Source File: ngx-mat-timepicker-period.component.ts    From ngx-mat-timepicker with MIT License 5 votes vote down vote up
@Component({
    selector: "ngx-mat-timepicker-period",
    templateUrl: "ngx-mat-timepicker-period.component.html",
    styleUrls: ["ngx-mat-timepicker-period.component.scss"],
    animations: [
        trigger("scaleInOut", [
            transition(":enter", [
                style({transform: "scale(0)"}),
                animate(".2s", style({transform: "scale(1)"})),
                sequence([
                    animate("3s", style({opacity: 1})),
                    animate(".3s", style({opacity: 0}))
                ])
            ])
        ])
    ]
})
export class NgxMatTimepickerPeriodComponent {

    @Input() activeTimeUnit: NgxMatTimepickerUnits;
    @Input() format: number;
    @Input() hours: NgxMatTimepickerClockFace[];
    isPeriodAvailable = true;
    @Input() maxTime: DateTime;
    @Input() meridiems: string[];
    @Input() minTime: DateTime;
    @Input() minutes: NgxMatTimepickerClockFace[];
    @Output() periodChanged = new EventEmitter<NgxMatTimepickerPeriods>();
    @Input() selectedHour: number | string;
    @Input() selectedPeriod: NgxMatTimepickerPeriods;
    timePeriod = NgxMatTimepickerPeriods;

    animationDone(): void {
        this.isPeriodAvailable = true;
    }

    changePeriod(period: NgxMatTimepickerPeriods): void {
        this.isPeriodAvailable = this._isSwitchPeriodAvailable(period);
        if (this.isPeriodAvailable) {
            this.periodChanged.next(period);
        }
    }

    private _getDisabledTimeByPeriod(period: NgxMatTimepickerPeriods): NgxMatTimepickerClockFace[] {
        switch (this.activeTimeUnit) {
            case NgxMatTimepickerUnits.HOUR:
                return NgxMatTimepickerUtils.disableHours(this.hours, {
                    min: this.minTime,
                    max: this.maxTime,
                    format: this.format,
                    period
                });
            case NgxMatTimepickerUnits.MINUTE:
                return NgxMatTimepickerUtils.disableMinutes(this.minutes, +this.selectedHour, {
                    min: this.minTime,
                    max: this.maxTime,
                    format: this.format,
                    period
                });
            default:
                throw new Error("no such NgxMatTimepickerUnits");
        }
    }

    private _isSwitchPeriodAvailable(period: NgxMatTimepickerPeriods): boolean {
        const time = this._getDisabledTimeByPeriod(period);

        return !time.every(t => t.disabled);
    }
}