【问题标题】:Keep Angular Material Mat Ripple Animation After Clicked单击后保持角度材质垫波纹动画
【发布时间】:2020-08-12 07:47:01
【问题描述】:

我使用 mat-list 和 matRipple 来制作点击动画。通常,垫波纹动画会在一段时间后消失,可以使用 RippleGlobalOptions 进行控制,但我想在单击后保留动画,这样背景颜色就不会改变。那么,有没有什么办法可以保持背景风格呢?

    <mat-list #selectable
              role="list">
                <mat-list-item *ngFor="let item of ItemsSource; let i = index;"
                               (click)="OnRowClicked(item)"
                               role="listitem"
                               matRipple>
                    {{item["Description"]}}
                    <mat-divider></mat-divider>
                </mat-list-item>
    </mat-list>
  public ItemsSource = [{Description: "test", Code: "1" },
                        {Description: "test2", Code: "2" }];

  public SelectedItem: any;

  public OnRowClicked(event: any) {
      this.SelectedItem = event;
    }  

分叉:https://stackblitz.com/edit/angular-vrus3x

【问题讨论】:

    标签: css angular angular-material material-design mat-list


    【解决方案1】:

    您可以使用Manual Ripples

    class MyComponent {
    
      /** Reference to the directive instance of the ripple. */
      @ViewChild(MatRipple) ripple: MatRipple;
    
      /** Shows a centered and persistent ripple. */
      launchRipple() {
        const rippleRef = this.ripple.launch({
          persistent: true,
          centered: true
        });
    
        // Fade out the ripple later.
        rippleRef.fadeOut();
      }
    }
    

    这是我在谷歌上找到的stackblitz

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-06-17
      • 1970-01-01
      • 2018-12-08
      • 1970-01-01
      • 2020-02-23
      • 2021-06-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多