@fileverse-dev/fortune-core 1.1.5-live-query-3 → 1.1.5-live-query-4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/animate.d.ts +3 -3
- package/es/animate.js +17 -16
- package/es/canvas.js +9 -9
- package/lib/animate.d.ts +3 -3
- package/lib/animate.js +17 -16
- package/lib/canvas.js +9 -9
- package/package.json +1 -1
package/es/animate.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
declare class CellFadeAnimator {
|
|
2
2
|
private durationMs;
|
|
3
3
|
private active;
|
|
4
|
-
private
|
|
4
|
+
private animationFrameId;
|
|
5
5
|
private onTick;
|
|
6
6
|
constructor(durationMs?: number);
|
|
7
7
|
markChanged(sheetId: string, r: number, c: number): void;
|
|
8
|
-
|
|
9
|
-
setOnTick(
|
|
8
|
+
getOpacity(sheetId: string, r: number, c: number): number;
|
|
9
|
+
setOnTick(repaintFn: (() => void) | null): void;
|
|
10
10
|
private ensureTicking;
|
|
11
11
|
}
|
|
12
12
|
export declare const cellFadeAnimator: CellFadeAnimator;
|
package/es/animate.js
CHANGED
|
@@ -5,7 +5,7 @@ var CellFadeAnimator = function () {
|
|
|
5
5
|
}
|
|
6
6
|
this.durationMs = durationMs;
|
|
7
7
|
this.active = new Map();
|
|
8
|
-
this.
|
|
8
|
+
this.animationFrameId = null;
|
|
9
9
|
this.onTick = null;
|
|
10
10
|
this.durationMs = durationMs;
|
|
11
11
|
}
|
|
@@ -16,33 +16,34 @@ var CellFadeAnimator = function () {
|
|
|
16
16
|
});
|
|
17
17
|
this.ensureTicking();
|
|
18
18
|
};
|
|
19
|
-
CellFadeAnimator.prototype.
|
|
20
|
-
var
|
|
21
|
-
if (!
|
|
22
|
-
var
|
|
23
|
-
if (
|
|
19
|
+
CellFadeAnimator.prototype.getOpacity = function (sheetId, r, c) {
|
|
20
|
+
var activeCellAnimationData = this.active.get("".concat(sheetId, ":").concat(r, ":").concat(c));
|
|
21
|
+
if (!activeCellAnimationData) return 1;
|
|
22
|
+
var animationProgress = Math.min(1, (performance.now() - activeCellAnimationData.start) / activeCellAnimationData.dur);
|
|
23
|
+
if (animationProgress >= 1) {
|
|
24
24
|
this.active.delete("".concat(sheetId, ":").concat(r, ":").concat(c));
|
|
25
25
|
return 1;
|
|
26
26
|
}
|
|
27
|
-
return Math.max(0.05, 1 - Math.pow(1 -
|
|
27
|
+
return Math.max(0.05, 1 - Math.pow(1 - animationProgress, 3));
|
|
28
28
|
};
|
|
29
|
-
CellFadeAnimator.prototype.setOnTick = function (
|
|
30
|
-
this.onTick =
|
|
29
|
+
CellFadeAnimator.prototype.setOnTick = function (repaintFn) {
|
|
30
|
+
this.onTick = repaintFn;
|
|
31
31
|
this.ensureTicking();
|
|
32
32
|
};
|
|
33
33
|
CellFadeAnimator.prototype.ensureTicking = function () {
|
|
34
34
|
var _this = this;
|
|
35
|
-
if (this.
|
|
36
|
-
if (this.active.size === 0
|
|
35
|
+
if (this.animationFrameId !== null) return;
|
|
36
|
+
if (this.active.size === 0) return;
|
|
37
37
|
var _loop = function loop() {
|
|
38
38
|
var _a;
|
|
39
|
-
_this.
|
|
40
|
-
if (_this.active.size
|
|
41
|
-
|
|
42
|
-
_this.raf = requestAnimationFrame(_loop);
|
|
39
|
+
_this.animationFrameId = null;
|
|
40
|
+
if (_this.active.size === 0) {
|
|
41
|
+
return;
|
|
43
42
|
}
|
|
43
|
+
(_a = _this.onTick) === null || _a === void 0 ? void 0 : _a.call(_this);
|
|
44
|
+
_this.animationFrameId = requestAnimationFrame(_loop);
|
|
44
45
|
};
|
|
45
|
-
this.
|
|
46
|
+
this.animationFrameId = requestAnimationFrame(_loop);
|
|
46
47
|
};
|
|
47
48
|
return CellFadeAnimator;
|
|
48
49
|
}();
|
package/es/canvas.js
CHANGED
|
@@ -762,10 +762,10 @@ var Canvas = function () {
|
|
|
762
762
|
var verticalAlignPos = endY + offsetTop - 2;
|
|
763
763
|
renderCtx.textBaseline = "bottom";
|
|
764
764
|
var sheetId = this.sheetCtx.currentSheetId;
|
|
765
|
-
var
|
|
766
|
-
if (
|
|
765
|
+
var opacity = cellFadeAnimator.getOpacity(sheetId, r, c);
|
|
766
|
+
if (opacity < 0.999) {
|
|
767
767
|
renderCtx.save();
|
|
768
|
-
renderCtx.globalAlpha =
|
|
768
|
+
renderCtx.globalAlpha = opacity;
|
|
769
769
|
renderCtx.fillText(_.isNil(value) ? "" : value, horizonAlignPos, verticalAlignPos);
|
|
770
770
|
renderCtx.restore();
|
|
771
771
|
} else {
|
|
@@ -1076,10 +1076,10 @@ var Canvas = function () {
|
|
|
1076
1076
|
renderCtx.fillStyle = "#ff0000";
|
|
1077
1077
|
}
|
|
1078
1078
|
var sheetId = this.sheetCtx.currentSheetId;
|
|
1079
|
-
var
|
|
1080
|
-
if (
|
|
1079
|
+
var opacity = cellFadeAnimator.getOpacity(sheetId, r, c);
|
|
1080
|
+
if (opacity < 0.999) {
|
|
1081
1081
|
renderCtx.save();
|
|
1082
|
-
renderCtx.globalAlpha =
|
|
1082
|
+
renderCtx.globalAlpha = opacity;
|
|
1083
1083
|
this.cellTextRender(textInfo, renderCtx, {
|
|
1084
1084
|
pos_x: pos_x,
|
|
1085
1085
|
pos_y: pos_y
|
|
@@ -1173,10 +1173,10 @@ var Canvas = function () {
|
|
|
1173
1173
|
renderCtx.fillStyle = checksCF.textColor;
|
|
1174
1174
|
}
|
|
1175
1175
|
var sheetId = this.sheetCtx.currentSheetId;
|
|
1176
|
-
var
|
|
1177
|
-
if (
|
|
1176
|
+
var opacity = cellFadeAnimator.getOpacity(sheetId, r, c);
|
|
1177
|
+
if (opacity < 0.999) {
|
|
1178
1178
|
renderCtx.save();
|
|
1179
|
-
renderCtx.globalAlpha =
|
|
1179
|
+
renderCtx.globalAlpha = opacity;
|
|
1180
1180
|
this.cellTextRender(textInfo, renderCtx, {
|
|
1181
1181
|
pos_x: pos_x,
|
|
1182
1182
|
pos_y: pos_y
|
package/lib/animate.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
declare class CellFadeAnimator {
|
|
2
2
|
private durationMs;
|
|
3
3
|
private active;
|
|
4
|
-
private
|
|
4
|
+
private animationFrameId;
|
|
5
5
|
private onTick;
|
|
6
6
|
constructor(durationMs?: number);
|
|
7
7
|
markChanged(sheetId: string, r: number, c: number): void;
|
|
8
|
-
|
|
9
|
-
setOnTick(
|
|
8
|
+
getOpacity(sheetId: string, r: number, c: number): number;
|
|
9
|
+
setOnTick(repaintFn: (() => void) | null): void;
|
|
10
10
|
private ensureTicking;
|
|
11
11
|
}
|
|
12
12
|
export declare const cellFadeAnimator: CellFadeAnimator;
|
package/lib/animate.js
CHANGED
|
@@ -12,7 +12,7 @@ var CellFadeAnimator = function () {
|
|
|
12
12
|
}
|
|
13
13
|
this.durationMs = durationMs;
|
|
14
14
|
this.active = new Map();
|
|
15
|
-
this.
|
|
15
|
+
this.animationFrameId = null;
|
|
16
16
|
this.onTick = null;
|
|
17
17
|
this.durationMs = durationMs;
|
|
18
18
|
}
|
|
@@ -23,33 +23,34 @@ var CellFadeAnimator = function () {
|
|
|
23
23
|
});
|
|
24
24
|
this.ensureTicking();
|
|
25
25
|
};
|
|
26
|
-
CellFadeAnimator.prototype.
|
|
27
|
-
var
|
|
28
|
-
if (!
|
|
29
|
-
var
|
|
30
|
-
if (
|
|
26
|
+
CellFadeAnimator.prototype.getOpacity = function (sheetId, r, c) {
|
|
27
|
+
var activeCellAnimationData = this.active.get("".concat(sheetId, ":").concat(r, ":").concat(c));
|
|
28
|
+
if (!activeCellAnimationData) return 1;
|
|
29
|
+
var animationProgress = Math.min(1, (performance.now() - activeCellAnimationData.start) / activeCellAnimationData.dur);
|
|
30
|
+
if (animationProgress >= 1) {
|
|
31
31
|
this.active.delete("".concat(sheetId, ":").concat(r, ":").concat(c));
|
|
32
32
|
return 1;
|
|
33
33
|
}
|
|
34
|
-
return Math.max(0.05, 1 - Math.pow(1 -
|
|
34
|
+
return Math.max(0.05, 1 - Math.pow(1 - animationProgress, 3));
|
|
35
35
|
};
|
|
36
|
-
CellFadeAnimator.prototype.setOnTick = function (
|
|
37
|
-
this.onTick =
|
|
36
|
+
CellFadeAnimator.prototype.setOnTick = function (repaintFn) {
|
|
37
|
+
this.onTick = repaintFn;
|
|
38
38
|
this.ensureTicking();
|
|
39
39
|
};
|
|
40
40
|
CellFadeAnimator.prototype.ensureTicking = function () {
|
|
41
41
|
var _this = this;
|
|
42
|
-
if (this.
|
|
43
|
-
if (this.active.size === 0
|
|
42
|
+
if (this.animationFrameId !== null) return;
|
|
43
|
+
if (this.active.size === 0) return;
|
|
44
44
|
var _loop = function loop() {
|
|
45
45
|
var _a;
|
|
46
|
-
_this.
|
|
47
|
-
if (_this.active.size
|
|
48
|
-
|
|
49
|
-
_this.raf = requestAnimationFrame(_loop);
|
|
46
|
+
_this.animationFrameId = null;
|
|
47
|
+
if (_this.active.size === 0) {
|
|
48
|
+
return;
|
|
50
49
|
}
|
|
50
|
+
(_a = _this.onTick) === null || _a === void 0 ? void 0 : _a.call(_this);
|
|
51
|
+
_this.animationFrameId = requestAnimationFrame(_loop);
|
|
51
52
|
};
|
|
52
|
-
this.
|
|
53
|
+
this.animationFrameId = requestAnimationFrame(_loop);
|
|
53
54
|
};
|
|
54
55
|
return CellFadeAnimator;
|
|
55
56
|
}();
|
package/lib/canvas.js
CHANGED
|
@@ -769,10 +769,10 @@ var Canvas = exports.Canvas = function () {
|
|
|
769
769
|
var verticalAlignPos = endY + offsetTop - 2;
|
|
770
770
|
renderCtx.textBaseline = "bottom";
|
|
771
771
|
var sheetId = this.sheetCtx.currentSheetId;
|
|
772
|
-
var
|
|
773
|
-
if (
|
|
772
|
+
var opacity = _animate.cellFadeAnimator.getOpacity(sheetId, r, c);
|
|
773
|
+
if (opacity < 0.999) {
|
|
774
774
|
renderCtx.save();
|
|
775
|
-
renderCtx.globalAlpha =
|
|
775
|
+
renderCtx.globalAlpha = opacity;
|
|
776
776
|
renderCtx.fillText(_lodash.default.isNil(value) ? "" : value, horizonAlignPos, verticalAlignPos);
|
|
777
777
|
renderCtx.restore();
|
|
778
778
|
} else {
|
|
@@ -1083,10 +1083,10 @@ var Canvas = exports.Canvas = function () {
|
|
|
1083
1083
|
renderCtx.fillStyle = "#ff0000";
|
|
1084
1084
|
}
|
|
1085
1085
|
var sheetId = this.sheetCtx.currentSheetId;
|
|
1086
|
-
var
|
|
1087
|
-
if (
|
|
1086
|
+
var opacity = _animate.cellFadeAnimator.getOpacity(sheetId, r, c);
|
|
1087
|
+
if (opacity < 0.999) {
|
|
1088
1088
|
renderCtx.save();
|
|
1089
|
-
renderCtx.globalAlpha =
|
|
1089
|
+
renderCtx.globalAlpha = opacity;
|
|
1090
1090
|
this.cellTextRender(textInfo, renderCtx, {
|
|
1091
1091
|
pos_x: pos_x,
|
|
1092
1092
|
pos_y: pos_y
|
|
@@ -1180,10 +1180,10 @@ var Canvas = exports.Canvas = function () {
|
|
|
1180
1180
|
renderCtx.fillStyle = checksCF.textColor;
|
|
1181
1181
|
}
|
|
1182
1182
|
var sheetId = this.sheetCtx.currentSheetId;
|
|
1183
|
-
var
|
|
1184
|
-
if (
|
|
1183
|
+
var opacity = _animate.cellFadeAnimator.getOpacity(sheetId, r, c);
|
|
1184
|
+
if (opacity < 0.999) {
|
|
1185
1185
|
renderCtx.save();
|
|
1186
|
-
renderCtx.globalAlpha =
|
|
1186
|
+
renderCtx.globalAlpha = opacity;
|
|
1187
1187
|
this.cellTextRender(textInfo, renderCtx, {
|
|
1188
1188
|
pos_x: pos_x,
|
|
1189
1189
|
pos_y: pos_y
|