make main buttons redraw syncronously
By main buttons I mean the "new game", "they win" and "we win" buttons. They have in common that they scroll to the bottom of the view, to make sure the user can immediately see their effect. This change fixes two bugs: 1. The scrolling did not work reliably. While it would always scroll a bit, it would usually not go to the bottom exactly. This meant that most of the time the bottom digits were only half visible. Now it scrolls reliably all the way. 2. When hitting the win buttons in rapid succession it was possible to trigger both within a single redraw cycle. This caused the UI to set a single rounds winner to both teams, which the round model rightly rejected. Now, by the time the second event is registered, the button has already been disabled, or the round been replaced by a new one.
This commit is contained in:
parent
04a84785f6
commit
eb20849bd8
@ -25,8 +25,10 @@ export default class RoundView {
|
||||
),
|
||||
m("button.wb-button.theywin._positioned",
|
||||
{
|
||||
onclick: () => {
|
||||
onclick: (event) => {
|
||||
event.redraw = false;
|
||||
model.winner = Team.They;
|
||||
m.redraw.sync();
|
||||
window.scrollTo({
|
||||
top: document.body.scrollHeight,
|
||||
behavior: "smooth",
|
||||
@ -38,8 +40,10 @@ export default class RoundView {
|
||||
),
|
||||
m("button.wb-button.wewin._positioned",
|
||||
{
|
||||
onclick: () => {
|
||||
onclick: (event) => {
|
||||
event.redraw = false;
|
||||
model.winner = Team.We;
|
||||
m.redraw.sync();
|
||||
window.scrollTo({
|
||||
top: document.body.scrollHeight,
|
||||
behavior: "smooth",
|
||||
|
||||
@ -62,8 +62,10 @@ export default class SessionView {
|
||||
: m(
|
||||
"button.wb-button._positioned",
|
||||
{
|
||||
onclick: () => {
|
||||
onclick: (event) => {
|
||||
event.redraw = false;
|
||||
model.anotherGame();
|
||||
m.redraw.sync();
|
||||
window.scrollTo({
|
||||
top: document.body.scrollHeight,
|
||||
behavior: "smooth",
|
||||
|
||||
Loading…
Reference in New Issue
Block a user