简体   繁体   English

如何禁用 Angular Material Pagination 按钮的波纹效果?

[英]How to disable ripple effect of Angular Material Pagination button?

I have an Angular Material Paginator which I am currently customizing the css of.我有一个 Angular Material Paginator,我目前正在定制它的 css。

It looks like this:它看起来像这样:

在此处输入图像描述

I cant record my screen on my device so I will explain.我无法在我的设备上录制我的屏幕,所以我会解释。

The two arrow buttons on the right side are Angular Material Icon Buttons.右侧的两个箭头按钮是 Angular 材质图标按钮。

When I click them, a ripple effect (gray circle) appears.当我点击它们时,会出现涟漪效应(灰色圆圈)。 I need to delete that ripple effect.我需要删除那个涟漪效应。

I couldn't inspect the element where it happens because it only appears on a click.我无法检查它发生的元素,因为它只在单击时出现。

I checked SO already about this question and the most common answer, to use [disableRipple]="true" doesn't work here, since angular paginator does not have this property.我已经检查了这个问题和最常见的答案,使用[disableRipple]="true"在这里不起作用,因为 angular 分页器没有这个属性。 I am working in a big project with several developers, so I would not like to touch global scss files.我和几个开发人员一起在一个大项目中工作,所以我不想接触全局 scss 文件。

This is my code btw:这是我的代码顺便说一句:

<mat-paginator
    #paginator
    (page)="changePage($event)"
    [length]="imagesAndFiles.length"
    [pageIndex]="pageIndex"
    [pageSize]="pageSize"
    [pageSizeOptions]="[4, 8, 16, 24, 32]"
  >
</mat-paginator>

How can I remove the ripple effect from the arrow buttons?如何消除箭头按钮的波纹效果?

There is a directive called matRippleDisabled that can be used in the paginator.有一个名为matRippleDisabled的指令可以在分页器中使用。
See the official doc about ripple请参阅有关 ripple 的官方文档

You can use css to hide the ripple element您可以使用 css 隐藏波纹元素

  • Add a class to the paginator element将 class 添加到分页器元素
  • Hide the mat-button-ripple class隐藏 mat-button-ripple class
<mat-paginator
  class="hide-ripple"
  #paginator
  (page)="changePage($event)"
  [length]="imagesAndFiles.length"
  [pageIndex]="pageIndex"
  [pageSize]="pageSize"
  [pageSizeOptions]="[4, 8, 16, 24, 32]"
>
</mat-paginator>
.hide-ripple {
  ::ng-deep {
    .mat-button-ripple {
      display: none;
    }
  }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM