diff --git a/src/components/text-counter.js b/src/components/text-counter.js
index 027337b..5259448 100644
--- a/src/components/text-counter.js
+++ b/src/components/text-counter.js
@@ -1,3 +1,6 @@
+/**
+ * Animate text number value.
+ */
AFRAME.registerComponent('text-counter', {
dependencies: ['text'],
@@ -14,8 +17,6 @@ AFRAME.registerComponent('text-counter', {
this.startTime = null;
this.currentValue = 0;
this.textValue = {value : ''};
- this.victoryInfoRank = document.getElementById('victoryInfoRank');
- this.victoryButtons = document.getElementById('victoryButtons');
},
decimals: function (n) {
@@ -32,18 +33,26 @@ AFRAME.registerComponent('text-counter', {
tick: function (time) {
if (this.currentValue >= this.data.value) { return; }
- if (this.startTime === null) { this.startTime = time; return; };
+
+ if (this.startTime === null) {
+ this.startTime = time;
+ return;
+ };
+
const prevValue = Math.floor(this.currentValue);
this.currentValue = this.data.value * (time - this.startTime) / this.data.dur;
+
if (Math.floor(this.currentValue) === prevValue) { return; }
+
if (this.currentValue >= this.data.value) {
this.currentValue = this.data.value;
if (this.data.emit) {
- this.victoryInfoRank.emit('textcounterdone', null, false);
- this.victoryButtons.emit('textcounterdone', null, false);
+ this.el.emit('textcounterdone', null, false);
}
}
- this.textValue.value = `${this.data.prefix} ${this.decimals(this.currentValue)} ${this.data.suffix}`;
+
+ this.textValue.value =
+ `${this.data.prefix} ${this.decimals(this.currentValue)} ${this.data.suffix}`;
this.el.setAttribute('text', this.textValue);
}
-})
\ No newline at end of file
+})
diff --git a/src/templates/victory.html b/src/templates/victory.html
index d588f89..faa080a 100644
--- a/src/templates/victory.html
+++ b/src/templates/victory.html
@@ -1,31 +1,26 @@
-
-
-
-
+ play-sound__click="event: click; sound: #confirmSound; volume: 0.25">
-
+ bind__slice9="opacity: isVictory && 0 || 0"
+ animation="property: components.slice9.material.opacity; from: 0; to: 1; startEvents: textcounterdone"
+ position="-0.56 -0.79 0.05"
+ proxy-event="event: click; to: a-scene; as: gamemenurestart"
+ slice9="opacity: 0">
+
+
-
+ proxy-event="event: click; to: a-scene; as: gamemenuexit"
+ slice9="opacity: 0">
+
-
-
-
-