@operato/scene-timer 1.2.49 → 1.2.62

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/CHANGELOG.md CHANGED
@@ -3,6 +3,23 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [1.2.62](https://github.com/things-scene/operato-scene/compare/v1.2.61...v1.2.62) (2023-09-11)
7
+
8
+ **Note:** Version bump only for package @operato/scene-timer
9
+
10
+
11
+
12
+
13
+
14
+ ## [1.2.53](https://github.com/things-scene/operato-scene/compare/v1.2.52...v1.2.53) (2023-08-17)
15
+
16
+
17
+ ### :bug: Bug Fix
18
+
19
+ * add data-reflection property to timer family ([93a9046](https://github.com/things-scene/operato-scene/commit/93a904621788b5e45987939e4f28252a93c2c4f8))
20
+
21
+
22
+
6
23
  ## [1.2.49](https://github.com/things-scene/operato-scene/compare/v1.2.48...v1.2.49) (2023-06-26)
7
24
 
8
25
 
Binary file
Binary file
@@ -1,6 +1,7 @@
1
1
  import { ComponentNature, Properties, Shape } from '@hatiolab/things-scene';
2
2
  declare const DueTimer_base: typeof Shape;
3
3
  export default class DueTimer extends DueTimer_base {
4
+ private _round;
4
5
  get nature(): ComponentNature;
5
6
  ready(): void;
6
7
  onchange(after: Properties): void;
@@ -12,5 +13,6 @@ export default class DueTimer extends DueTimer_base {
12
13
  get due(): number;
13
14
  set due(due: number);
14
15
  get countdown(): number;
16
+ get round(): number;
15
17
  }
16
18
  export {};
package/dist/duetimer.js CHANGED
@@ -26,17 +26,29 @@ const NATURE = {
26
26
  name: 'format-stop',
27
27
  placeholder: '--:--:--'
28
28
  },
29
+ {
30
+ type: 'select',
31
+ label: 'data-reflection',
32
+ name: 'dataReflection',
33
+ property: {
34
+ options: ['', 'countdown', 'round']
35
+ }
36
+ },
29
37
  {
30
38
  type: 'color',
31
- label: 'background-color',
32
- name: 'backgroundColor',
33
- property: 'backgroundColor'
39
+ label: 'progress-color',
40
+ name: 'progressColor',
41
+ property: 'progressColor'
34
42
  }
35
43
  ],
36
44
  'value-property': 'due',
37
45
  help: 'scene/component/duetimer'
38
46
  };
39
47
  export default class DueTimer extends RectPath(Shape) {
48
+ constructor() {
49
+ super(...arguments);
50
+ this._round = 0;
51
+ }
40
52
  get nature() {
41
53
  return NATURE;
42
54
  }
@@ -48,32 +60,42 @@ export default class DueTimer extends RectPath(Shape) {
48
60
  this.timeout = Math.max(Math.round((due - Date.now()) / 1000), 0);
49
61
  }
50
62
  onchange(after) {
51
- if ('due' in after) {
63
+ if ('timeout' in after) {
52
64
  this.timeout = Math.max(Math.round((this.due - Date.now()) / 1000), 0);
53
65
  this.counting();
54
66
  }
55
67
  }
56
68
  counting() {
69
+ // @ts-ignore
70
+ if (this.disposed) {
71
+ return;
72
+ }
57
73
  requestAnimationFrame(() => {
58
74
  const countdown = this.countdown;
75
+ const { dataReflection = 'countdown' } = this.state;
59
76
  if (countdown > 0) {
60
- this.setState('data', format(countdown, this.getState('format-run')));
77
+ const text = format(countdown, this.getState('format-run'));
78
+ this.text = text;
79
+ if (dataReflection != 'round') {
80
+ this.setState('data', text);
81
+ }
61
82
  setTimeout(() => {
62
83
  this.counting();
63
84
  }, 1000);
64
85
  }
65
86
  else {
66
- this.setState('data', this.getState('format-stop'));
87
+ const text = format(countdown, this.getState('format-stop'));
88
+ this.text = text;
89
+ this.setState('data', dataReflection != 'round' ? text : ++this._round);
67
90
  }
68
91
  });
69
92
  }
70
93
  render(context) {
71
- var { top, left, height, width, backgroundColor = 'transparent' } = this.state;
72
- // background의 색상
94
+ var { top, left, height, width, progressColor = 'transparent' } = this.state;
95
+ // progress의 색상
73
96
  context.beginPath();
74
97
  context.rect(left, top, width, height);
75
- context.fillStyle = backgroundColor;
76
- context.fill();
98
+ this.drawFill(context);
77
99
  // value의 색상
78
100
  context.beginPath();
79
101
  var progress = (this.countdown / this.timeout) * 100;
@@ -81,7 +103,8 @@ export default class DueTimer extends RectPath(Shape) {
81
103
  progress = width - (width * progress) / 100;
82
104
  progress = Math.max(Math.min(progress, width), 0);
83
105
  context.rect(left, top, progress, height);
84
- this.drawFill(context);
106
+ context.fillStyle = progressColor;
107
+ context.fill();
85
108
  context.beginPath();
86
109
  }
87
110
  // stroke
@@ -108,6 +131,9 @@ export default class DueTimer extends RectPath(Shape) {
108
131
  const now = Date.now();
109
132
  return Math.max(Math.round((due - now) / 1000), 0);
110
133
  }
134
+ get round() {
135
+ return this._round;
136
+ }
111
137
  }
112
138
  Component.register('duetimer', DueTimer);
113
139
  //# sourceMappingURL=duetimer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"duetimer.js","sourceRoot":"","sources":["../src/duetimer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAA+B,QAAQ,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAA;AAEhG;;GAEG;AACH,OAAO,MAAM,MAAM,eAAe,CAAA;AAElC,MAAM,MAAM,GAAoB;IAC9B,OAAO,EAAE,KAAK;IACd,SAAS,EAAE,IAAI;IACf,SAAS,EAAE,IAAI;IACf,UAAU,EAAE;QACV;YACE,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,KAAK;YACZ,IAAI,EAAE,KAAK;YACX,WAAW,EAAE,WAAW;SACzB;QACD;YACE,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,YAAY;YACnB,IAAI,EAAE,YAAY;YAClB,WAAW,EAAE,UAAU;SACxB;QACD;YACE,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,aAAa;YACpB,IAAI,EAAE,aAAa;YACnB,WAAW,EAAE,UAAU;SACxB;QACD;YACE,IAAI,EAAE,OAAO;YACb,KAAK,EAAE,kBAAkB;YACzB,IAAI,EAAE,iBAAiB;YACvB,QAAQ,EAAE,iBAAiB;SAC5B;KACF;IACD,gBAAgB,EAAE,KAAK;IACvB,IAAI,EAAE,0BAA0B;CACjC,CAAA;AAED,MAAM,CAAC,OAAO,O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AAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAA;IAC9C,CAAC;IAED,IAAI,OAAO,CAAC,OAAO;QACjB,IAAI,CAAC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAA;IAChD,CAAC;IAED,IAAI,GAAG;QACL,OAAO,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAA;IAC1C,CAAC;IAED,IAAI,GAAG,CAAC,GAAG;QACT,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,GAAG,CAAC,CAAA;IAC3B,CAAC;IAED,IAAI,SAAS;QACX,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAA;QACpB,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAA;QAEtB,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,GAAG,GAAG,CAAC,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC,CAAA;IACpD,CAAC;CACF;AAED,SAAS,CAAC,QAAQ,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAA","sourcesContent":["import { Component, ComponentNature, Properties, RectPath, Shape } from '@hatiolab/things-scene'\n\n/*\n * Copyright © HatioLab Inc. All rights reserved.\n */\nimport format from './libs/format'\n\nconst NATURE: ComponentNature = {\n mutable: false,\n resizable: true,\n rotatable: true,\n properties: [\n {\n type: 'number',\n label: 'due',\n name: 'due',\n placeholder: 'timestamp'\n },\n {\n type: 'string',\n label: 'format-run',\n name: 'format-run',\n placeholder: 'hh:mm:ss'\n },\n {\n type: 'string',\n label: 'format-stop',\n name: 'format-stop',\n placeholder: '--:--:--'\n },\n {\n type: 'color',\n label: 'background-color',\n name: 'backgroundColor',\n property: 'backgroundColor'\n }\n ],\n 'value-property': 'due',\n help: 'scene/component/duetimer'\n}\n\nexport default class DueTimer extends RectPath(Shape) {\n get nature() {\n return NATURE\n }\n\n ready() {\n if (!this.app.isViewMode) {\n return\n }\n\n var { due = 0 } = this.state\n\n this.timeout = Math.max(Math.round((due - Date.now()) / 1000), 0)\n }\n\n onchange(after: Properties) {\n if ('due' in after) {\n this.timeout = Math.max(Math.round((this.due - Date.now()) / 1000), 0)\n this.counting()\n }\n }\n\n counting() {\n requestAnimationFrame(() => {\n const countdown = this.countdown\n\n if (countdown > 0) {\n this.setState('data', format(countdown, this.getState('format-run')))\n\n setTimeout(() => {\n this.counting()\n }, 1000)\n } else {\n this.setState('data', this.getState('format-stop'))\n }\n })\n }\n\n render(context: CanvasRenderingContext2D) {\n var { top, left, height, width, backgroundColor = 'transparent' } = this.state\n\n // background의 색상\n context.beginPath()\n context.rect(left, top, width, height)\n\n context.fillStyle = backgroundColor\n context.fill()\n\n // value의 색상\n context.beginPath()\n\n var progress = (this.countdown / this.timeout) * 100\n\n if (!isNaN(progress)) {\n progress = width - (width * progress) / 100\n progress = Math.max(Math.min(progress, width), 0)\n\n context.rect(left, top, progress, height)\n this.drawFill(context)\n\n context.beginPath()\n }\n\n // stroke\n context.rect(left, top, width, height)\n }\n\n postrender(context: CanvasRenderingContext2D) {\n this.drawStroke(context)\n this.drawText(context)\n }\n\n get timeout() {\n return Number(this.getState('timeout') || 0)\n }\n\n set timeout(timeout) {\n this.setState('timeout', Number(timeout) || 0)\n }\n\n get due() {\n return Number(this.getState('due') || 0)\n }\n\n set due(due) {\n this.setState('due', due)\n }\n\n get countdown() {\n const due = this.due\n const now = Date.now()\n\n return Math.max(Math.round((due - now) / 1000), 0)\n }\n}\n\nComponent.register('duetimer', DueTimer)\n"]}
1
+ {"version":3,"file":"duetimer.js","sourceRoot":"","sources":["../src/duetimer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAA+B,QAAQ,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAA;AAEhG;;GAEG;AACH,OAAO,MAAM,MAAM,eAAe,CAAA;AAElC,MAAM,MAAM,GAAoB;IAC9B,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ACT,OAAO,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAA;IAC9C,CAAC;IAED,IAAI,OAAO,CAAC,OAAO;QACjB,IAAI,CAAC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAA;IAChD,CAAC;IAED,IAAI,GAAG;QACL,OAAO,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAA;IAC1C,CAAC;IAED,IAAI,GAAG,CAAC,GAAG;QACT,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,GAAG,CAAC,CAAA;IAC3B,CAAC;IAED,IAAI,SAAS;QACX,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAA;QACpB,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAA;QAEtB,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,GAAG,GAAG,CAAC,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC,CAAA;IACpD,CAAC;IAED,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,MAAM,CAAA;IACpB,CAAC;CACF;AAED,SAAS,CAAC,QAAQ,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAA","sourcesContent":["import { Component, ComponentNature, Properties, RectPath, Shape } from '@hatiolab/things-scene'\n\n/*\n * Copyright © HatioLab Inc. All rights reserved.\n */\nimport format from './libs/format'\n\nconst NATURE: ComponentNature = {\n mutable: false,\n resizable: true,\n rotatable: true,\n properties: [\n {\n type: 'number',\n label: 'due',\n name: 'due',\n placeholder: 'timestamp'\n },\n {\n type: 'string',\n label: 'format-run',\n name: 'format-run',\n placeholder: 'hh:mm:ss'\n },\n {\n type: 'string',\n label: 'format-stop',\n name: 'format-stop',\n placeholder: '--:--:--'\n },\n {\n type: 'select',\n label: 'data-reflection',\n name: 'dataReflection',\n property: {\n options: ['', 'countdown', 'round']\n }\n },\n {\n type: 'color',\n label: 'progress-color',\n name: 'progressColor',\n property: 'progressColor'\n }\n ],\n 'value-property': 'due',\n help: 'scene/component/duetimer'\n}\n\nexport default class DueTimer extends RectPath(Shape) {\n private _round: number = 0\n\n get nature() {\n return NATURE\n }\n\n ready() {\n if (!this.app.isViewMode) {\n return\n }\n\n var { due = 0 } = this.state\n\n this.timeout = Math.max(Math.round((due - Date.now()) / 1000), 0)\n }\n\n onchange(after: Properties) {\n if ('timeout' in after) {\n this.timeout = Math.max(Math.round((this.due - Date.now()) / 1000), 0)\n this.counting()\n }\n }\n\n counting() {\n // @ts-ignore\n if (this.disposed) {\n return\n }\n\n requestAnimationFrame(() => {\n const countdown = this.countdown\n const { dataReflection = 'countdown' } = this.state\n\n if (countdown > 0) {\n const text = format(countdown, this.getState('format-run'))\n\n this.text = text\n\n if (dataReflection != 'round') {\n this.setState('data', text)\n }\n\n setTimeout(() => {\n this.counting()\n }, 1000)\n } else {\n const text = format(countdown, this.getState('format-stop'))\n\n this.text = text\n\n this.setState('data', dataReflection != 'round' ? text : ++this._round)\n }\n })\n }\n\n render(context: CanvasRenderingContext2D) {\n var { top, left, height, width, progressColor = 'transparent' } = this.state\n\n // progress의 색상\n context.beginPath()\n context.rect(left, top, width, height)\n\n this.drawFill(context)\n\n // value의 색상\n context.beginPath()\n\n var progress = (this.countdown / this.timeout) * 100\n\n if (!isNaN(progress)) {\n progress = width - (width * progress) / 100\n progress = Math.max(Math.min(progress, width), 0)\n\n context.rect(left, top, progress, height)\n context.fillStyle = progressColor\n context.fill()\n\n context.beginPath()\n }\n\n // stroke\n context.rect(left, top, width, height)\n }\n\n postrender(context: CanvasRenderingContext2D) {\n this.drawStroke(context)\n this.drawText(context)\n }\n\n get timeout() {\n return Number(this.getState('timeout') || 0)\n }\n\n set timeout(timeout) {\n this.setState('timeout', Number(timeout) || 0)\n }\n\n get due() {\n return Number(this.getState('due') || 0)\n }\n\n set due(due) {\n this.setState('due', due)\n }\n\n get countdown() {\n const due = this.due\n const now = Date.now()\n\n return Math.max(Math.round((due - now) / 1000), 0)\n }\n\n get round() {\n return this._round\n }\n}\n\nComponent.register('duetimer', DueTimer)\n"]}
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  import Timer from './timer';
2
2
  import DueTimer from './duetimer';
3
- declare const _default: (typeof DueTimer | typeof Timer)[];
3
+ declare const _default: (typeof Timer | typeof DueTimer)[];
4
4
  export default _default;
@@ -10,7 +10,6 @@ declare const _default: {
10
10
  width: number;
11
11
  height: number;
12
12
  strokeStyle: string;
13
- text: string;
14
13
  days: number;
15
14
  hours: number;
16
15
  minutes: number;
@@ -12,7 +12,6 @@ export default {
12
12
  width: 100,
13
13
  height: 100,
14
14
  strokeStyle: 'darkgray',
15
- text: '#{data}',
16
15
  days: 0,
17
16
  hours: 0,
18
17
  minutes: 0,
@@ -1 +1 @@
1
- {"version":3,"file":"duetimer.js","sourceRoot":"","sources":["../../src/templates/duetimer.ts"],"names":[],"mappings":"AAAA,MAAM,IAAI,GAAG,IAAI,GAAG,CAAC,uBAAuB,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAA;AAEnE,eAAe;IACb,IAAI,EAAE,OAAO;IACb,WAAW,EAAE,OAAO;IACpB,KAAK,EAAE,KAAK;IACZ,gGAAgG;IAChG,IAAI;IACJ,KAAK,EAAE;QACL,IAAI,EAAE,OAAO;QACb,IAAI,EAAE,EAAE;QACR,GAAG,EAAE,EAAE;QACP,KAAK,EAAE,GAAG;QACV,MAAM,EAAE,GAAG;QACX,WAAW,EAAE,UAAU;QACvB,IAAI,EAAE,SAAS;QACf,IAAI,EAAE,CAAC;QACP,KAAK,EAAE,CAAC;QACR,OAAO,EAAE,CAAC;QACV,OAAO,EAAE,CAAC;QACV,YAAY,EAAE,OAAO;QACrB,aAAa,EAAE,OAAO;KACvB;CACF,CAAA","sourcesContent":["const icon = new URL('../../icons/timer.png', import.meta.url).href\n\nexport default {\n type: 'timer',\n description: 'timer',\n group: 'etc',\n /* line|shape|textAndMedia|chartAndGauge|table|container|dataSource|IoT|3D|warehouse|form|etc */\n icon,\n model: {\n type: 'timer',\n left: 10,\n top: 10,\n width: 100,\n height: 100,\n strokeStyle: 'darkgray',\n text: '#{data}',\n days: 0,\n hours: 0,\n minutes: 0,\n seconds: 0,\n 'format-run': 'mm:ss',\n 'format-stop': '--:--'\n }\n}\n"]}
1
+ {"version":3,"file":"duetimer.js","sourceRoot":"","sources":["../../src/templates/duetimer.ts"],"names":[],"mappings":"AAAA,MAAM,IAAI,GAAG,IAAI,GAAG,CAAC,uBAAuB,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAA;AAEnE,eAAe;IACb,IAAI,EAAE,OAAO;IACb,WAAW,EAAE,OAAO;IACpB,KAAK,EAAE,KAAK;IACZ,gGAAgG;IAChG,IAAI;IACJ,KAAK,EAAE;QACL,IAAI,EAAE,OAAO;QACb,IAAI,EAAE,EAAE;QACR,GAAG,EAAE,EAAE;QACP,KAAK,EAAE,GAAG;QACV,MAAM,EAAE,GAAG;QACX,WAAW,EAAE,UAAU;QACvB,IAAI,EAAE,CAAC;QACP,KAAK,EAAE,CAAC;QACR,OAAO,EAAE,CAAC;QACV,OAAO,EAAE,CAAC;QACV,YAAY,EAAE,OAAO;QACrB,aAAa,EAAE,OAAO;KACvB;CACF,CAAA","sourcesContent":["const icon = new URL('../../icons/timer.png', import.meta.url).href\n\nexport default {\n type: 'timer',\n description: 'timer',\n group: 'etc',\n /* line|shape|textAndMedia|chartAndGauge|table|container|dataSource|IoT|3D|warehouse|form|etc */\n icon,\n model: {\n type: 'timer',\n left: 10,\n top: 10,\n width: 100,\n height: 100,\n strokeStyle: 'darkgray',\n days: 0,\n hours: 0,\n minutes: 0,\n seconds: 0,\n 'format-run': 'mm:ss',\n 'format-stop': '--:--'\n }\n}\n"]}
@@ -10,7 +10,6 @@ declare const _default: {
10
10
  width: number;
11
11
  height: number;
12
12
  strokeStyle: string;
13
- text: string;
14
13
  'format-run': string;
15
14
  'format-stop': string;
16
15
  };
@@ -10,7 +10,6 @@ declare const _default: {
10
10
  width: number;
11
11
  height: number;
12
12
  strokeStyle: string;
13
- text: string;
14
13
  'format-run': string;
15
14
  'format-stop': string;
16
15
  };
@@ -12,7 +12,6 @@ export default {
12
12
  width: 100,
13
13
  height: 100,
14
14
  strokeStyle: 'darkgray',
15
- text: '#{data}',
16
15
  'format-run': 'mm:ss',
17
16
  'format-stop': '--:--'
18
17
  }
@@ -1 +1 @@
1
- {"version":3,"file":"timer.js","sourceRoot":"","sources":["../../src/templates/timer.ts"],"names":[],"mappings":"AAAA,MAAM,IAAI,GAAG,IAAI,GAAG,CAAC,0BAA0B,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAA;AAEtE,eAAe;IACb,IAAI,EAAE,UAAU;IAChB,WAAW,EAAE,UAAU;IACvB,KAAK,EAAE,KAAK;IACZ,gGAAgG;IAChG,IAAI;IACJ,KAAK,EAAE;QACL,IAAI,EAAE,UAAU;QAChB,IAAI,EAAE,EAAE;QACR,GAAG,EAAE,EAAE;QACP,KAAK,EAAE,GAAG;QACV,MAAM,EAAE,GAAG;QACX,WAAW,EAAE,UAAU;QACvB,IAAI,EAAE,SAAS;QACf,YAAY,EAAE,OAAO;QACrB,aAAa,EAAE,OAAO;KACvB;CACF,CAAA","sourcesContent":["const icon = new URL('../../icons/duetimer.png', import.meta.url).href\n\nexport default {\n type: 'duetimer',\n description: 'duetimer',\n group: 'etc',\n /* line|shape|textAndMedia|chartAndGauge|table|container|dataSource|IoT|3D|warehouse|form|etc */\n icon,\n model: {\n type: 'duetimer',\n left: 10,\n top: 10,\n width: 100,\n height: 100,\n strokeStyle: 'darkgray',\n text: '#{data}',\n 'format-run': 'mm:ss',\n 'format-stop': '--:--'\n }\n}\n"]}
1
+ {"version":3,"file":"timer.js","sourceRoot":"","sources":["../../src/templates/timer.ts"],"names":[],"mappings":"AAAA,MAAM,IAAI,GAAG,IAAI,GAAG,CAAC,0BAA0B,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAA;AAEtE,eAAe;IACb,IAAI,EAAE,UAAU;IAChB,WAAW,EAAE,UAAU;IACvB,KAAK,EAAE,KAAK;IACZ,gGAAgG;IAChG,IAAI;IACJ,KAAK,EAAE;QACL,IAAI,EAAE,UAAU;QAChB,IAAI,EAAE,EAAE;QACR,GAAG,EAAE,EAAE;QACP,KAAK,EAAE,GAAG;QACV,MAAM,EAAE,GAAG;QACX,WAAW,EAAE,UAAU;QACvB,YAAY,EAAE,OAAO;QACrB,aAAa,EAAE,OAAO;KACvB;CACF,CAAA","sourcesContent":["const icon = new URL('../../icons/duetimer.png', import.meta.url).href\n\nexport default {\n type: 'duetimer',\n description: 'duetimer',\n group: 'etc',\n /* line|shape|textAndMedia|chartAndGauge|table|container|dataSource|IoT|3D|warehouse|form|etc */\n icon,\n model: {\n type: 'duetimer',\n left: 10,\n top: 10,\n width: 100,\n height: 100,\n strokeStyle: 'darkgray',\n 'format-run': 'mm:ss',\n 'format-stop': '--:--'\n }\n}\n"]}
package/dist/timer.d.ts CHANGED
@@ -2,6 +2,7 @@ import { ComponentNature, Properties, Shape } from '@hatiolab/things-scene';
2
2
  declare const Timer_base: typeof Shape;
3
3
  export default class Timer extends Timer_base {
4
4
  private _due?;
5
+ private _round;
5
6
  get nature(): ComponentNature;
6
7
  ready(): void;
7
8
  onchange(after: Properties): void;
@@ -11,5 +12,6 @@ export default class Timer extends Timer_base {
11
12
  get timeout(): number;
12
13
  set timeout(timeout: number);
13
14
  get countdown(): number;
15
+ get round(): number;
14
16
  }
15
17
  export {};
package/dist/timer.js CHANGED
@@ -46,15 +46,32 @@ const NATURE = {
46
46
  },
47
47
  {
48
48
  type: 'color',
49
- label: 'background-color',
50
- name: 'backgroundColor',
51
- property: 'backgroundColor'
49
+ label: 'progress-color',
50
+ name: 'progressColor',
51
+ property: 'progressColor'
52
+ },
53
+ {
54
+ type: 'select',
55
+ label: 'data-reflection',
56
+ name: 'dataReflection',
57
+ property: {
58
+ options: ['countdown', 'round']
59
+ }
60
+ },
61
+ {
62
+ type: 'boolean',
63
+ label: 'repeat',
64
+ name: 'repeat'
52
65
  }
53
66
  ],
54
67
  'value-property': 'timeout',
55
68
  help: 'scene/component/timer'
56
69
  };
57
70
  export default class Timer extends RectPath(Shape) {
71
+ constructor() {
72
+ super(...arguments);
73
+ this._round = 0;
74
+ }
58
75
  get nature() {
59
76
  return NATURE;
60
77
  }
@@ -72,26 +89,40 @@ export default class Timer extends RectPath(Shape) {
72
89
  }
73
90
  }
74
91
  counting() {
92
+ // @ts-ignore
93
+ if (this.disposed) {
94
+ return;
95
+ }
96
+ const { dataReflection = 'countdown' } = this.state;
75
97
  requestAnimationFrame(() => {
76
98
  const countdown = this.countdown;
77
99
  if (countdown > 0) {
78
- this.setState('data', format(countdown, this.getState('format-run')));
100
+ const text = format(countdown, this.getState('format-run'));
101
+ this.text = text;
102
+ if (dataReflection != 'round') {
103
+ this.setState('data', text);
104
+ }
79
105
  setTimeout(() => {
80
106
  this.counting();
81
107
  }, 1000);
82
108
  }
83
109
  else {
84
- this.setState('data', this.getState('format-stop'));
110
+ const text = format(countdown, this.getState('format-stop'));
111
+ this.text = text;
112
+ this.setState('data', dataReflection != 'round' ? text : ++this._round);
113
+ if (this.state.repeat) {
114
+ this._due = Date.now() + this.timeout * 1000;
115
+ this.counting();
116
+ }
85
117
  }
86
118
  });
87
119
  }
88
120
  render(context) {
89
- var { top, left, height, width, backgroundColor = 'transparent' } = this.state;
90
- // background의 색상
121
+ var { top, left, height, width, progressColor = 'transparent' } = this.state;
122
+ // progress의 색상
91
123
  context.beginPath();
92
124
  context.rect(left, top, width, height);
93
- context.fillStyle = backgroundColor;
94
- context.fill();
125
+ this.drawFill(context);
95
126
  // value의 색상
96
127
  context.beginPath();
97
128
  var progress = (this.countdown / this.timeout) * 100;
@@ -99,7 +130,8 @@ export default class Timer extends RectPath(Shape) {
99
130
  progress = width - (width * progress) / 100;
100
131
  progress = Math.max(Math.min(progress, width), 0);
101
132
  context.rect(left, top, progress, height);
102
- this.drawFill(context);
133
+ context.fillStyle = progressColor;
134
+ context.fill();
103
135
  context.beginPath();
104
136
  }
105
137
  // stroke
@@ -124,6 +156,9 @@ export default class Timer extends RectPath(Shape) {
124
156
  const now = Date.now();
125
157
  return Math.max(Math.round((due - now) / 1000), 0);
126
158
  }
159
+ get round() {
160
+ return this._round;
161
+ }
127
162
  }
128
163
  Component.register('timer', Timer);
129
164
  //# sourceMappingURL=timer.js.map
package/dist/timer.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"timer.js","sourceRoot":"","sources":["../src/timer.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,SAAS,EAA+B,QAAQ,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAA;AAEhG,OAAO,MAAM,MAAM,eAAe,CAAA;AAElC,MAAM,MAAM,GAAoB;IAC9B,OAAO,EAAE,KAAK;IACd,SAAS,EAAE,IAAI;IACf,SAAS,EAAE,IAAI;IACf,UAAU,EAAE;QACV;YACE,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,MAAM;YACb,IAAI,EAAE,MAAM;YACZ,WAAW,EAAE,MAAM;SACpB;QACD;YACE,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,OAAO;YACd,IAAI,EAAE,OAAO;YACb,WAAW,EAAE,OAAO;SACrB;QACD;YACE,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,SAAS;YAChB,IAAI,EAAE,SAAS;YACf,WAAW,EAAE,SAAS;SACvB;QACD;YACE,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,SAAS;YAChB,IAAI,EAAE,SAAS;YACf,WAAW,EAAE,SAAS;SACvB;QACD;YACE,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,YAAY;YACnB,IAAI,E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;QACT,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,CAAC,CAAA;IACxC,CAAC;IAED,UAAU,CAAC,OAAiC;QAC1C,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAA;QACxB,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAA;IACxB,CAAC;IAED,IAAI,OAAO;QACT,OAAO,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAA;IAC9C,CAAC;IAED,IAAI,OAAO,CAAC,OAAO;QACjB,IAAI,CAAC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAA;IAChD,CAAC;IAED,IAAI,SAAS;QACX,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAA;QAC5B,IAAI,CAAC,OAAO,IAAI,OAAO,GAAG,CAAC,EAAE;YAC3B,OAAO,CAAC,CAAA;SACT;QAED,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,IAAI,CAAC,CAAA;QAC1B,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAA;QAEtB,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,GAAG,GAAG,CAAC,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC,CAAA;IACpD,CAAC;CACF;AAED,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,KAAK,CAAC,CAAA","sourcesContent":["/*\n * Copyright © HatioLab Inc. All rights reserved.\n */\n\nimport { Component, ComponentNature, Properties, RectPath, Shape } from '@hatiolab/things-scene'\n\nimport format from './libs/format'\n\nconst NATURE: ComponentNature = {\n mutable: false,\n resizable: true,\n rotatable: true,\n properties: [\n {\n type: 'number',\n label: 'days',\n name: 'days',\n placeholder: 'days'\n },\n {\n type: 'number',\n label: 'hours',\n name: 'hours',\n placeholder: 'hours'\n },\n {\n type: 'number',\n label: 'minutes',\n name: 'minutes',\n placeholder: 'minutes'\n },\n {\n type: 'number',\n label: 'seconds',\n name: 'seconds',\n placeholder: 'seconds'\n },\n {\n type: 'string',\n label: 'format-run',\n name: 'format-run',\n placeholder: 'hh:mm:ss'\n },\n {\n type: 'string',\n label: 'format-stop',\n name: 'format-stop',\n placeholder: '--:--:--'\n },\n {\n type: 'color',\n label: 'background-color',\n name: 'backgroundColor',\n property: 'backgroundColor'\n }\n ],\n 'value-property': 'timeout',\n help: 'scene/component/timer'\n}\n\nexport default class Timer extends RectPath(Shape) {\n private _due?: number\n\n get nature() {\n return NATURE\n }\n\n ready() {\n if (!this.app.isViewMode) {\n return\n }\n\n var { days = 0, hours = 0, minutes = 0, seconds = 0 } = this.state\n\n this.timeout = days * 86400 + hours * 3600 + minutes * 60 + seconds\n }\n\n onchange(after: Properties) {\n if ('timeout' in after) {\n this._due = Date.now() + this.timeout * 1000\n this.counting()\n }\n }\n\n counting() {\n requestAnimationFrame(() => {\n const countdown = this.countdown\n\n if (countdown > 0) {\n this.setState('data', format(countdown, this.getState('format-run')))\n\n setTimeout(() => {\n this.counting()\n }, 1000)\n } else {\n this.setState('data', this.getState('format-stop'))\n }\n })\n }\n\n render(context: CanvasRenderingContext2D) {\n var { top, left, height, width, backgroundColor = 'transparent' } = this.state\n\n // background의 색상\n context.beginPath()\n context.rect(left, top, width, height)\n\n context.fillStyle = backgroundColor\n context.fill()\n\n // value의 색상\n context.beginPath()\n\n var progress = (this.countdown / this.timeout) * 100\n\n if (!isNaN(progress)) {\n progress = width - (width * progress) / 100\n progress = Math.max(Math.min(progress, width), 0)\n\n context.rect(left, top, progress, height)\n this.drawFill(context)\n\n context.beginPath()\n }\n\n // stroke\n context.rect(left, top, width, height)\n }\n\n postrender(context: CanvasRenderingContext2D) {\n this.drawStroke(context)\n this.drawText(context)\n }\n\n get timeout() {\n return Number(this.getState('timeout') || 0)\n }\n\n set timeout(timeout) {\n this.setState('timeout', Number(timeout) || 0)\n }\n\n get countdown() {\n const timeout = this.timeout\n if (!timeout || timeout < 0) {\n return 0\n }\n\n const due = this._due || 0\n const now = Date.now()\n\n return Math.max(Math.round((due - now) / 1000), 0)\n }\n}\n\nComponent.register('timer', Timer)\n"]}
1
+ {"version":3,"file":"timer.js","sourceRoot":"","sources":["../src/timer.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,SAAS,EAA+B,QAAQ,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAA;AAEhG,OAAO,MAAM,MAAM,eAAe,CAAA;AAElC,MAAM,MAAM,GAAoB;IAC9B,OAAO,EAAE,KAAK;IACd,SAAS,EAAE,IAAI;IACf,SAAS,EAAE,IAAI;IACf,UAAU,EAAE;QACV;YACE,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,MAAM;YACb,IAAI,EAAE,MAAM;YACZ,WAAW,EAAE,MAAM;SACpB;QACD;YACE,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,OAAO;YACd,IAAI,EAAE,OAAO;YACb,WAAW,EAAE,OAAO;SACrB;QACD;YACE,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,SAAS;YAChB,IAAI,EAAE,SAAS;YACf,WAAW,EAAE,SAAS;SACvB;QACD;YACE,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,SAAS;YAChB,IAAI,EAAE,SAAS;YACf,WAAW,EAAE,SAAS;SACvB;QACD;YACE,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,YAAY;YACnB,IAAI,EAAE,YAAY;YAClB,WAAW,EAAE,UAAU;SACxB;QACD;YACE,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,aAAa;YACpB,IAAI,EAAE,aAAa;YACnB,WAAW,EAAE,UAAU;SACxB;QACD;YACE,IAAI,EAAE,OAAO;YACb,KAAK,EAAE,gBAAgB;YACvB,IAAI,EAAE,eAAe;YACrB,QAAQ,EAAE,eAAe;SAC1B;QACD;YACE,IAAI,EAAE,QAAQ;Y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CAAC,EAAE;YAC3B,OAAO,CAAC,CAAA;SACT;QAED,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,IAAI,CAAC,CAAA;QAC1B,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAA;QAEtB,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,GAAG,GAAG,CAAC,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC,CAAA;IACpD,CAAC;IAED,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,MAAM,CAAA;IACpB,CAAC;CACF;AAED,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,KAAK,CAAC,CAAA","sourcesContent":["/*\n * Copyright © HatioLab Inc. All rights reserved.\n */\n\nimport { Component, ComponentNature, Properties, RectPath, Shape } from '@hatiolab/things-scene'\n\nimport format from './libs/format'\n\nconst NATURE: ComponentNature = {\n mutable: false,\n resizable: true,\n rotatable: true,\n properties: [\n {\n type: 'number',\n label: 'days',\n name: 'days',\n placeholder: 'days'\n },\n {\n type: 'number',\n label: 'hours',\n name: 'hours',\n placeholder: 'hours'\n },\n {\n type: 'number',\n label: 'minutes',\n name: 'minutes',\n placeholder: 'minutes'\n },\n {\n type: 'number',\n label: 'seconds',\n name: 'seconds',\n placeholder: 'seconds'\n },\n {\n type: 'string',\n label: 'format-run',\n name: 'format-run',\n placeholder: 'hh:mm:ss'\n },\n {\n type: 'string',\n label: 'format-stop',\n name: 'format-stop',\n placeholder: '--:--:--'\n },\n {\n type: 'color',\n label: 'progress-color',\n name: 'progressColor',\n property: 'progressColor'\n },\n {\n type: 'select',\n label: 'data-reflection',\n name: 'dataReflection',\n property: {\n options: ['countdown', 'round']\n }\n },\n {\n type: 'boolean',\n label: 'repeat',\n name: 'repeat'\n }\n ],\n 'value-property': 'timeout',\n help: 'scene/component/timer'\n}\n\nexport default class Timer extends RectPath(Shape) {\n private _due?: number\n private _round: number = 0\n\n get nature() {\n return NATURE\n }\n\n ready() {\n if (!this.app.isViewMode) {\n return\n }\n\n var { days = 0, hours = 0, minutes = 0, seconds = 0 } = this.state\n\n this.timeout = days * 86400 + hours * 3600 + minutes * 60 + seconds\n }\n\n onchange(after: Properties) {\n if ('timeout' in after) {\n this._due = Date.now() + this.timeout * 1000\n this.counting()\n }\n }\n\n counting() {\n // @ts-ignore\n if (this.disposed) {\n return\n }\n\n const { dataReflection = 'countdown' } = this.state\n\n requestAnimationFrame(() => {\n const countdown = this.countdown\n\n if (countdown > 0) {\n const text = format(countdown, this.getState('format-run'))\n this.text = text\n\n if (dataReflection != 'round') {\n this.setState('data', text)\n }\n\n setTimeout(() => {\n this.counting()\n }, 1000)\n } else {\n const text = format(countdown, this.getState('format-stop'))\n this.text = text\n\n this.setState('data', dataReflection != 'round' ? text : ++this._round)\n\n if (this.state.repeat) {\n this._due = Date.now() + this.timeout * 1000\n this.counting()\n }\n }\n })\n }\n\n render(context: CanvasRenderingContext2D) {\n var { top, left, height, width, progressColor = 'transparent' } = this.state\n\n // progress의 색상\n context.beginPath()\n context.rect(left, top, width, height)\n this.drawFill(context)\n\n // value의 색상\n context.beginPath()\n\n var progress = (this.countdown / this.timeout) * 100\n\n if (!isNaN(progress)) {\n progress = width - (width * progress) / 100\n progress = Math.max(Math.min(progress, width), 0)\n\n context.rect(left, top, progress, height)\n context.fillStyle = progressColor\n context.fill()\n\n context.beginPath()\n }\n\n // stroke\n context.rect(left, top, width, height)\n }\n\n postrender(context: CanvasRenderingContext2D) {\n this.drawStroke(context)\n this.drawText(context)\n }\n\n get timeout() {\n return Number(this.getState('timeout') || 0)\n }\n\n set timeout(timeout) {\n this.setState('timeout', Number(timeout) || 0)\n }\n\n get countdown() {\n const timeout = this.timeout\n if (!timeout || timeout < 0) {\n return 0\n }\n\n const due = this._due || 0\n const now = Date.now()\n\n return Math.max(Math.round((due - now) / 1000), 0)\n }\n\n get round() {\n return this._round\n }\n}\n\nComponent.register('timer', Timer)\n"]}
@@ -7,7 +7,7 @@
7
7
  카운트다운 과정의 format-run, format-stop 에 의한 결과값이 data 속성에 설정된다.
8
8
 
9
9
  또한, 듀타이머 컴포넌트는 심플한 수평형 프로그레스바의 표현기능을 제공한다.
10
- fill-color에 설정된 색상이 카운트다운에 따라 표현된다.
10
+ progress-color에 설정된 색상이 카운트다운에 따라 표현된다.
11
11
 
12
12
  ![fill-color]
13
13
 
@@ -15,22 +15,27 @@ fill-color에 설정된 색상이 카운트다운에 따라 표현된다.
15
15
 
16
16
  ## properties
17
17
 
18
- - due
18
+ - 종료시간(due)
19
19
  - timestamp (UTC 기준으로 1970년 1월 1일 0시 0분 0초부터 현재까지 경과된 밀리 초) : 듀 타이머 컴포넌트의 종료시간 타임스탬프 값이다.
20
20
  - 듀 타이머 컴포넌트의 value property 이므로, 듀 타이머의 value 속성(due)에 세팅값을 설정할 수 있다.
21
21
  - getter: 타이머 종료시간을 가지고 있다.
22
22
  - setter: 타이머 종료시간을 설정할 수 있다.
23
- - format-run
23
+ - 카운트다운 포맷(format-run)
24
24
  - string
25
25
  - format : hh:mm:ss
26
26
  - 카운트다운 결과 표현형식
27
- - format-stop
27
+ - 멈춤 포맷(format-stop)
28
28
  - string
29
29
  - format : --:--:--
30
30
  - 카운트다운이 종료되었을 때 표현형식
31
- - background color
31
+ - 진도 색상(progress color)
32
32
  - string, rgb color
33
- - 컴포넌트의 배경 색상
33
+ - 카운트다운 진도 색상
34
+ - 데이타 반영(data reflection)
35
+ - countdown : 매초 카운트다운할 때마다 남은 시간을 '카운트다운 포맷' 또는 '멈춤 포맷' 에 설정된 포맷으로 data에 반영된다.
36
+ - round : 매회차 카운트다운이 끝나면 해당 회차수가 data에 반영된다.(이 경우에 countdown 중에선 데이타값이 변하지 않는다.)
37
+ - 반복(repeat)
38
+ - 이 설정이 체크되고, 매번 카운트다운이 끝나면, 자동으로 다시 시작한다.
34
39
 
35
40
  ## hidden properties
36
41
 
@@ -39,3 +44,8 @@ fill-color에 설정된 색상이 카운트다운에 따라 표현된다.
39
44
  - readonly
40
45
  - number (seconds)
41
46
  - 타이머 설정값 세팅 시점부터 카운트다운된 현재 값을 가지고 있다.
47
+
48
+ - round
49
+ - readonly
50
+ - number
51
+ - 카운트다운의 회차수
@@ -5,7 +5,7 @@ this component that counts down the set timeout value every second.
5
5
  - To set statically, you can set during modeling, options in days, hours, minutes, and seconds.
6
6
  - To set it dynamically, set the timeout(seconds) value in the value property during execution.
7
7
  - The result value by format-run and format-stop of the countdown process is set in the data property.
8
- - In addition, the timer component provides a simple horizontal progress bar expression function, you can set fill style on color setting.
8
+ - In addition, the timer component provides a simple horizontal progress bar expression function, you can set progress-color on color setting.
9
9
 
10
10
  ![fill-color]
11
11
 
@@ -28,13 +28,25 @@ this component that counts down the set timeout value every second.
28
28
  - string
29
29
  - format : --:--:--
30
30
  - count down format on stop
31
- - background color
32
- - string, rgb color
33
- - component background color
31
+ - progress color
32
+
33
+ - Type: string, RGB color
34
+ - Description: Color of the progress in countdown.
35
+
36
+ - data reflection
37
+
38
+ - Countdown: Every second during the countdown, the remaining time is reflected in the data according to the format set in 'Countdown Format' or 'Stop Format'.
39
+ - Round: After each countdown round is completed, the round number is reflected in the data. (In this case, the data value remains unchanged during countdown.)
34
40
 
35
41
  ## hidden properties
36
42
 
37
43
  - countdown
44
+
38
45
  - readonly
39
46
  - number (seconds)
40
47
  - when timer set, count down will start automatically
48
+
49
+ - round
50
+ - readonly
51
+ - number
52
+ - number of rounds in countdown
@@ -5,8 +5,8 @@
5
5
  - 静态 : 可以在建模时以天,小时,分钟和秒为单位静态设置时间值。
6
6
  - 动态 : 在运行时在 value 属性中设置时间(seconds)值。
7
7
  - 在数据属性中设置倒计时过程的,按格式运行和按格式停止的结果值。
8
- - 时间格式, 停止格式在运行和结束时以对应的格式设置为data
9
- - 另外,计时器组件提供了简单的水平进度条功能。填充《填充颜色》中设置的颜色将会表示对应时间的进度条。
8
+ - 时间格式, 停止格式在运行和结束时以对应的格式设置为 data
9
+ - 另外,倒计时器组件还提供了简单的水平进度条显示功能。进度颜色设置将随着倒计时的进行而显示。
10
10
 
11
11
  ![fill-color]
12
12
 
@@ -15,7 +15,8 @@
15
15
  ## 属性
16
16
 
17
17
  - due (截止时间)
18
- - timestamp (以UTC时间为准从1970-01-01 0点0分0秒开始到现在为止的毫秒) : 是DUE计时器组件的结束时间的时间戳
18
+
19
+ - timestamp (以 UTC 时间为准从 1970-01-01 0 点 0 分 0 秒开始到现在为止的毫秒) : 是 DUE 计时器组件的结束时间的时间戳
19
20
  - 因为是计时器的 value 属性, 可以把数据传递到 value 属性(due)中设置数据值
20
21
 
21
22
  - 时间格式,
@@ -23,12 +24,20 @@
23
24
  - format : hh:mm:ss
24
25
  - 计时结果表现格式
25
26
  - 停止格式
27
+
26
28
  - string
27
29
  - format : --:--:--
28
30
  - 计时结束后显示的时间格式
29
- - 背景颜色
30
- - string, rgb color
31
- - 组件背景颜色
31
+
32
+ - 进度颜色(Progress Color)
33
+
34
+ - 类型:字符串,RGB 颜色
35
+ - 描述:倒计时中进度的颜色。
36
+
37
+ - 数据反映(Data Reflection)
38
+
39
+ - 倒计时:在倒计时期间的每一秒,剩余时间都会按照“倒计时格式”或“停止格式”中设置的格式反映在数据中。
40
+ - 圆形:在每个倒计时循环完成后,循环数会反映在数据中。(在此情况下,在倒计时期间数据值保持不变。)
32
41
 
33
42
  ## 隐藏属性
34
43
 
@@ -37,3 +46,8 @@
37
46
  - readonly
38
47
  - number (seconds)
39
48
  - 从设置定时器设置值开始,它就将当前值递减计数。
49
+
50
+ - round
51
+ - 只读
52
+ - 数字
53
+ - 倒计时的回合数
@@ -7,7 +7,7 @@
7
7
  카운트다운 과정의 format-run, format-stop 에 의한 결과값이 data 속성에 설정된다.
8
8
 
9
9
  또한, 타이머 컴포넌트는 심플한 수평형 프로그레스바의 표현기능을 제공한다.
10
- fill-color에 설정된 색상이 카운트다운에 따라 표현된다.
10
+ progress-color에 설정된 색상이 카운트다운에 따라 표현된다.
11
11
 
12
12
  ![fill-color]
13
13
 
@@ -15,29 +15,36 @@ fill-color에 설정된 색상이 카운트다운에 따라 표현된다.
15
15
 
16
16
  ## properties
17
17
 
18
- - days
18
+ - 일(days)
19
19
  - number
20
20
  - 타임아웃 날자 설정값(0- )
21
- - hours
21
+ - 시간(hours)
22
22
  - number
23
23
  - 타임아웃 시간 설정값(0-23)
24
- - minutes
24
+ - 분(minutes)
25
25
  - number
26
26
  - 타임아웃 분 설정값(0-59)
27
- - seconds
27
+ - 초(seconds)
28
28
  - number
29
29
  - 타임아웃 초 설정값(0-59)
30
- - format-run
30
+ - 카운트다운 포맷(format-run)
31
31
  - string
32
32
  - format : hh:mm:ss
33
33
  - 카운트다운 결과 표현형식
34
- - format-stop
34
+ - '데이타반영' 속성이 'countdown' 이고 countdown > 0 인 경우에 이 포맷의 값이 data에 반영된다.
35
+ - 멈춤 포맷(format-stop)
35
36
  - string
36
37
  - format : --:--:--
37
38
  - 카운트다운이 종료되었을 때 표현형식
38
- - background color
39
+ - '데이타반영' 속성이 'countdown' 이고 countdown = 0 인 경우에 이 포맷의 값이 data에 반영된다.
40
+ - 진도 색상(progress color)
39
41
  - string, rgb color
40
- - 컴포넌트의 배경 색상
42
+ - 카운트다운 진도 색상
43
+ - 데이타 반영(data reflection)
44
+ - countdown : 매초 카운트다운할 때마다 남은 시간을 '카운트다운 포맷' 또는 '멈춤 포맷' 에 설정된 포맷으로 data에 반영된다.
45
+ - round : 매회차 카운트다운이 끝나면 해당 회차수가 data에 반영된다.(이 경우에 countdown 중에선 데이타값이 변하지 않는다.)
46
+ - 반복(repeat)
47
+ - 이 설정이 체크되고, 매번 카운트다운이 끝나면, 자동으로 다시 시작한다.
41
48
 
42
49
  ## hidden properties
43
50
 
@@ -59,6 +66,12 @@ fill-color에 설정된 색상이 카운트다운에 따라 표현된다.
59
66
  [databind]: ../images/timer-data-bind.png
60
67
 
61
68
  - countdown
69
+
62
70
  - readonly
63
71
  - number (seconds)
64
72
  - 타이머 설정값 세팅 시점부터 카운트다운된 현재 값을 가지고 있다.
73
+
74
+ - round
75
+ - readonly
76
+ - number
77
+ - 카운트다운의 회차수