Project

General

Profile

1
import {AfterViewInit, Component} from "@angular/core";
2
import {animate, state, style, transition, trigger} from "@angular/animations";
3

    
4
@Component({
5
  selector: 'action-point',
6
  template: `
7
    <div class="uk-position-relative" style="width: 15px; height: 15px;">
8
      <div>
9
        <svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 15 15" fill="none">
10
          <circle cx="7.5" cy="7.5" r="7.5" fill="var(--portal-main-color)"/>
11
        </svg>
12
      </div>
13
      <div class="uk-position-top-left" [@move]="state" (@move.done)="onEnd($event)">
14
        <svg width="15" height="15" viewBox="0 0 15 15" fill="none">
15
          <circle cx="7.5" cy="6.5" r="5" stroke="var(--portal-main-color)" stroke-width="2.5" fill="none" />
16
        </svg>
17
      </div>
18
    </div>
19
  `,
20
  animations: [
21
    trigger('move', [
22
      state('in', style({
23
        transform: 'scale(1)',
24
        opacity: 1
25
      })),
26
      state('out', style({
27
        transform: 'scale(3)',
28
        opacity: 0
29
      })),
30
      transition('in => out', animate('2s ease-out'))
31
    ]),
32
  ]
33
})
34
export class ActionPointComponent implements AfterViewInit {
35
  state = 'in';
36
  
37
  ngAfterViewInit() {
38
    setTimeout(() => {
39
      this.state = 'out';
40
    }, 0);
41
  }
42
  
43
  onEnd(event) {
44
    this.state = 'in';
45
    if (event.toState === 'in') {
46
      setTimeout(() => {
47
        this.state = 'out';
48
      }, 2000);
49
    }
50
  }
51
}
(5-5/8)