@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 CHANGED
@@ -1,12 +1,12 @@
1
1
  declare class CellFadeAnimator {
2
2
  private durationMs;
3
3
  private active;
4
- private raf;
4
+ private animationFrameId;
5
5
  private onTick;
6
6
  constructor(durationMs?: number);
7
7
  markChanged(sheetId: string, r: number, c: number): void;
8
- alpha(sheetId: string, r: number, c: number): number;
9
- setOnTick(cb: (() => void) | null): void;
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.raf = null;
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.alpha = function (sheetId, r, c) {
20
- var it = this.active.get("".concat(sheetId, ":").concat(r, ":").concat(c));
21
- if (!it) return 1;
22
- var t = Math.min(1, (performance.now() - it.start) / it.dur);
23
- if (t >= 1) {
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 - t, 3));
27
+ return Math.max(0.05, 1 - Math.pow(1 - animationProgress, 3));
28
28
  };
29
- CellFadeAnimator.prototype.setOnTick = function (cb) {
30
- this.onTick = cb;
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.raf !== null) return;
36
- if (this.active.size === 0 && !this.onTick) return;
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.raf = null;
40
- if (_this.active.size > 0) (_a = _this.onTick) === null || _a === void 0 ? void 0 : _a.call(_this);
41
- if (_this.active.size > 0 || _this.onTick) {
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.raf = requestAnimationFrame(_loop);
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 a = cellFadeAnimator.alpha(sheetId, r, c);
766
- if (a < 0.999) {
765
+ var opacity = cellFadeAnimator.getOpacity(sheetId, r, c);
766
+ if (opacity < 0.999) {
767
767
  renderCtx.save();
768
- renderCtx.globalAlpha = a;
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 a = cellFadeAnimator.alpha(sheetId, r, c);
1080
- if (a < 0.999) {
1079
+ var opacity = cellFadeAnimator.getOpacity(sheetId, r, c);
1080
+ if (opacity < 0.999) {
1081
1081
  renderCtx.save();
1082
- renderCtx.globalAlpha = a;
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 a = cellFadeAnimator.alpha(sheetId, r, c);
1177
- if (a < 0.999) {
1176
+ var opacity = cellFadeAnimator.getOpacity(sheetId, r, c);
1177
+ if (opacity < 0.999) {
1178
1178
  renderCtx.save();
1179
- renderCtx.globalAlpha = a;
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 raf;
4
+ private animationFrameId;
5
5
  private onTick;
6
6
  constructor(durationMs?: number);
7
7
  markChanged(sheetId: string, r: number, c: number): void;
8
- alpha(sheetId: string, r: number, c: number): number;
9
- setOnTick(cb: (() => void) | null): void;
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.raf = null;
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.alpha = function (sheetId, r, c) {
27
- var it = this.active.get("".concat(sheetId, ":").concat(r, ":").concat(c));
28
- if (!it) return 1;
29
- var t = Math.min(1, (performance.now() - it.start) / it.dur);
30
- if (t >= 1) {
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 - t, 3));
34
+ return Math.max(0.05, 1 - Math.pow(1 - animationProgress, 3));
35
35
  };
36
- CellFadeAnimator.prototype.setOnTick = function (cb) {
37
- this.onTick = cb;
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.raf !== null) return;
43
- if (this.active.size === 0 && !this.onTick) return;
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.raf = null;
47
- if (_this.active.size > 0) (_a = _this.onTick) === null || _a === void 0 ? void 0 : _a.call(_this);
48
- if (_this.active.size > 0 || _this.onTick) {
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.raf = requestAnimationFrame(_loop);
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 a = _animate.cellFadeAnimator.alpha(sheetId, r, c);
773
- if (a < 0.999) {
772
+ var opacity = _animate.cellFadeAnimator.getOpacity(sheetId, r, c);
773
+ if (opacity < 0.999) {
774
774
  renderCtx.save();
775
- renderCtx.globalAlpha = a;
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 a = _animate.cellFadeAnimator.alpha(sheetId, r, c);
1087
- if (a < 0.999) {
1086
+ var opacity = _animate.cellFadeAnimator.getOpacity(sheetId, r, c);
1087
+ if (opacity < 0.999) {
1088
1088
  renderCtx.save();
1089
- renderCtx.globalAlpha = a;
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 a = _animate.cellFadeAnimator.alpha(sheetId, r, c);
1184
- if (a < 0.999) {
1183
+ var opacity = _animate.cellFadeAnimator.getOpacity(sheetId, r, c);
1184
+ if (opacity < 0.999) {
1185
1185
  renderCtx.save();
1186
- renderCtx.globalAlpha = a;
1186
+ renderCtx.globalAlpha = opacity;
1187
1187
  this.cellTextRender(textInfo, renderCtx, {
1188
1188
  pos_x: pos_x,
1189
1189
  pos_y: pos_y
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fileverse-dev/fortune-core",
3
- "version": "1.1.5-live-query-3",
3
+ "version": "1.1.5-live-query-4",
4
4
  "main": "lib/index.js",
5
5
  "module": "es/index.js",
6
6
  "typings": "lib/index.d.ts",