mirror of
https://github.com/Xevion/power-math.git
synced 2025-12-17 14:12:46 -06:00
new incorrect answer shake feedback
This commit is contained in:
25
src/App.vue
25
src/App.vue
@@ -5,7 +5,7 @@
|
|||||||
<div class="columns is-centered">
|
<div class="columns is-centered">
|
||||||
<div class="column is-three-fifths">
|
<div class="column is-three-fifths">
|
||||||
<b-field id="input" @keyup.native.enter="checkAnswer()">
|
<b-field id="input" @keyup.native.enter="checkAnswer()">
|
||||||
<b-input v-model="answer"></b-input>
|
<b-input :custom-class="input_shake" v-model="answer"></b-input>
|
||||||
</b-field>
|
</b-field>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -14,6 +14,8 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
|
@import "./src/scss/shake.scss";
|
||||||
|
|
||||||
html, body, #app {
|
html, body, #app {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
min-height: 100%;
|
min-height: 100%;
|
||||||
@@ -62,6 +64,10 @@ a, p, span {
|
|||||||
user-select: none;
|
user-select: none;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.notices .toast {
|
||||||
|
padding: 0.6em 1.35em !important;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
@@ -73,13 +79,17 @@ export default {
|
|||||||
return {
|
return {
|
||||||
answer: null,
|
answer: null,
|
||||||
currentQuestion: null,
|
currentQuestion: null,
|
||||||
correctTimeout: false
|
correctTimeout: false,
|
||||||
|
shakeInput: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
expression() {
|
expression() {
|
||||||
return this.currentQuestion != null ? this.currentQuestion.text : "error";
|
return this.currentQuestion != null ? this.currentQuestion.text : "error";
|
||||||
},
|
},
|
||||||
|
input_shake() {
|
||||||
|
return this.shakeInput ? "shake" : "";
|
||||||
|
}
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
window.addEventListener('keyup', (e) => {
|
window.addEventListener('keyup', (e) => {
|
||||||
@@ -112,7 +122,7 @@ export default {
|
|||||||
this.$buefy.toast.open({
|
this.$buefy.toast.open({
|
||||||
message: 'Correct!',
|
message: 'Correct!',
|
||||||
type: 'is-success',
|
type: 'is-success',
|
||||||
duration: 6000
|
duration: 600
|
||||||
})
|
})
|
||||||
this.nextQuestion();
|
this.nextQuestion();
|
||||||
this.answer = "";
|
this.answer = "";
|
||||||
@@ -121,9 +131,16 @@ export default {
|
|||||||
this.$buefy.toast.open({
|
this.$buefy.toast.open({
|
||||||
message: 'Incorrect.',
|
message: 'Incorrect.',
|
||||||
type: 'is-danger',
|
type: 'is-danger',
|
||||||
duration: 5000
|
duration: 500
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// Shake input
|
||||||
|
this.shakeInput = true;
|
||||||
|
setTimeout(this.stopShake, 500);
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
stopShake() {
|
||||||
|
this.shakeInput = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
27
src/scss/shake.scss
Normal file
27
src/scss/shake.scss
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
@keyframes shake {
|
||||||
|
0% {
|
||||||
|
border-color: rgba(#df4160, 10%);
|
||||||
|
transform: translate(0);
|
||||||
|
}
|
||||||
|
20% {
|
||||||
|
transform: translate(0.2em);
|
||||||
|
}
|
||||||
|
40% {
|
||||||
|
transform: translate(-0.2em);
|
||||||
|
}
|
||||||
|
60% {
|
||||||
|
border-color: rgba(#df4160, 15%);
|
||||||
|
transform: translate(0.2em);
|
||||||
|
}
|
||||||
|
80% {
|
||||||
|
transform: translate(-0.2em);
|
||||||
|
}
|
||||||
|
100% {
|
||||||
|
transform: translate(0);
|
||||||
|
border-color: hsl(0, 0%, 20%);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#input input.shake {
|
||||||
|
animation: shake 0.5s;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user