[英]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.