Skip to content

Commit ad41378

Browse files
committed
进度新增min/max
1 parent c62d888 commit ad41378

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

packages/core/src/pen/model.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,8 @@ export interface Pen extends Rect {
347347
video?: string;
348348
audio?: string;
349349

350+
max?: number; // progress最大值
351+
min?: number; // progress最小值
350352
progress?: number;
351353
progressColor?: string;
352354
verticalProgress?: boolean;
@@ -435,6 +437,8 @@ export interface Pen extends Rect {
435437
height?: number;
436438
borderRadius?: number;
437439

440+
max?: number;
441+
min?: number;
438442
progress?: number;
439443
progressColor?: string;
440444
progressGradientColors?: string;

packages/core/src/pen/render.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1967,8 +1967,10 @@ export function ctxDrawPath(
19671967
ctx.restore();
19681968
}
19691969

1970-
const progress = pen.calculative.progress;
1971-
if (progress != null) {
1970+
const progress =
1971+
(pen.calculative.progress - (pen.calculative.min || 0)) /
1972+
((pen.calculative.max || 1) - (pen.calculative.min || 0));
1973+
if (progress != null && !isNaN(progress)) {
19721974
// 从左往右 x, y, x + width * progress, y
19731975
// 从右往左 ex, y, x + width * (1-progress), y
19741976
// 从下往上 x, y, x, y + height * progress

0 commit comments

Comments
 (0)