简体   繁体   English

如何逆转 mat-progress-spinner 的进度

[英]How to reverse the progress on mat-progress-spinner

I'm using the spinner as a timer and I would like to reverse the progress direction.我使用微调器作为计时器,我想反转进度方向。 It's clockwise if you go from 0 to 100, but my percentage is going from 100 (15 minutes = 900 seconds) to 0 (time has run out).如果你从 0 到 100,它是顺时针方向,但我的百分比从 100(15 分钟 = 900 秒)到 0(时间已经用完)。

<mat-progress-spinner [color]="primary"
   [value]="percentage"
   strokeWidth="8">
</mat-progress-spinner>

在此处输入图片说明

there two problems:有两个问题:

1.- Calculate the time in minutes seconds depending the value 1.- 根据值计算以分秒为单位的时间

I like use a Date object and date pipe我喜欢使用 Date 对象和日期管道

get time()
  {
    return new Date(0,0,0,0,0,900-9*this.value) 
  }

{{time|date:'mm:ss'}}

2.-make two divs centered, you can use, eg 2.-使两个div居中,你可以使用,例如

.box {
  display: flex;
  align-items: center;
  justify-content: center;
}

.box div {
  width: 100px;
  height: 100px;
}
.div2
{
  z-index:100;
  position:absolute;
  display: flex;
  align-items: center;
  justify-content: center;
}

And your .html还有你的 .html

<div class="box">
  <mat-progress-spinner
        class="example-margin"
        color="primary"
        mode="determinate"
        [value]="value">
    </mat-progress-spinner>
  <div class="div2">{{time|date:'mm:ss'}}</div>
</div>

See stackblitz堆栈闪电战

You can trick with some CSS which I think is the best and the easiest solution until Material implements it as a directive.在 Material 将其作为指令实现之前,您可以使用一些 CSS 来欺骗我认为这是最好和最简单的解决方案。

Horizontal flip (in your case):水平翻转(在你的情况下):

mat-progress-spinner {
    -moz-transform: scale(-1, 1);
    -webkit-transform: scale(-1, 1);
    -o-transform: scale(-1, 1);
    -ms-transform: scale(-1, 1);
    transform: scale(-1, 1);
}

Vertical flip :垂直翻转

mat-progress-spinner {
    -moz-transform: scale(1, -1);
    -webkit-transform: scale(1, -1);
    -o-transform: scale(1, -1);
    -ms-transform: scale(1, -1);
    transform: scale(1, -1);
}

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

相关问题 Angular4 <mat-progress-spinner> 如何在页面加载完成时显示和隐藏 - Angular4 <mat-progress-spinner> how to show and hide when a page load completes 如何仅使用有角度的材料在 mat-progress-spinner 中添加文本 - How to add text inside mat-progress-spinner with using angular material only 如何根据屏幕尺寸设置 HTML 属性? 我需要根据屏幕尺寸更改 mat-progress-spinner 直径 - How to set an HTML attribute based in screen size? I need to change mat-progress-spinner diameter based on screen size Angular:从 Angular 9/10 更新到 13 时,Mat-Progress-Spinner 无法识别不确定模式 - Angular: Mat-Progress-Spinner does not recognize indeterminate mode when updating from Angular 9/10 to 13 在 Angular、Material 和 Flex-Layout 上以 mat-progress-spinner 为中心的叠加文本 - Overlay text centered in mat-progress-spinner on Angular, Material and Flex-Layout 角垫进度微调器模块未更新值 - Angular Mat Progress Spinner Module not updating value 带图像图标的角材料进度微调器-(mat-spinner) - Angular Material Progress Spinner with Image icons - (mat-spinner) Angular 2 Material - 如何居中进度微调器 - Angular 2 Material - How To Center Progress Spinner 带有进度条的 Mat 选项卡 - Mat tabs with progress bar Angular Material Progress Spinner 没有动画 - Angular Material Progress Spinner not animated
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM