drift-bottle.component_20241224161454.ts 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import { Component, OnInit } from '@angular/core';
  2. import { IonHeader,IonButton, IonContent, IonIcon, IonItem, IonLabel, IonList,
  3. IonListHeader,IonCardHeader,IonCardTitle,IonAvatar,IonCardContent, IonTitle,IonCard, IonToolbar,IonInput,IonSearchbar } from '@ionic/angular/standalone';
  4. import { Router } from '@angular/router';
  5. @Component({
  6. selector: 'app-drift-bottle',
  7. templateUrl: './drift-bottle.component.html',
  8. styleUrls: ['./drift-bottle.component.scss'],
  9. standalone: true,
  10. imports: [IonHeader,IonToolbar,IonTitle,IonContent,
  11. IonList,IonListHeader,IonItem,IonCardTitle,
  12. IonLabel,IonIcon,IonButton,IonCardContent,IonAvatar,
  13. IonInput,IonSearchbar,IonCard,IonCardHeader
  14. ]
  15. })
  16. export class DriftBottleComponent implements OnInit {
  17. constructor(private router: Router) { }
  18. goTab1(){
  19. this.router.navigate(['tabs/tab1']);
  20. }
  21. ngOnInit() {}
  22. addRipple(event: MouseEvent) {
  23. const container = event.currentTarget as HTMLElement;
  24. const rect = container.getBoundingClientRect();
  25. const x = event.clientX - rect.left;
  26. const y = event.clientY - rect.top;
  27. // 创建涟漪元素
  28. const ripple = document.createElement('span');
  29. ripple.classList.add('ripple');
  30. // 设置涟漪的位置和大小
  31. ripple.style.left = `${x}px`;
  32. ripple.style.top = `${y}px`;
  33. ripple.style.width = ripple.style.height = '100px'; // 可根据需要调整
  34. // 添加到DOM并触发动画
  35. container.appendChild(ripple);
  36. // 动画结束后移除涟漪元素
  37. setTimeout(() => {
  38. ripple.remove();
  39. }, 600); // 应与CSS动画时间相匹配
  40. }
  41. }