From c1a136f590ee105d0cd144ee0a3d63b54a626d4a Mon Sep 17 00:00:00 2001 From: spaciecat <5057054+spaciecat@users.noreply.github.com> Date: Thu, 12 Sep 2019 16:23:41 +1000 Subject: [PATCH] move the "click to advance" text the click to advance text is now moved into the right location using css transforms! this still runs every frame when we're forcing a specific text position. but it's getting better! --- scripts/game/Game.js | 16 ++++++++++------ scripts/game/Options.js | 5 ----- styles/game.css | 1 - 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/scripts/game/Game.js b/scripts/game/Game.js index 3b3c522..148d2e8 100644 --- a/scripts/game/Game.js +++ b/scripts/game/Game.js @@ -322,16 +322,20 @@ Game.WORDS_HEIGHT_BOTTOM = -1; if(updated) return updated = true + let advanceTextPosition = 0 if(Game.FORCE_TEXT_Y != -1){ Game.wordsDOM.style.transform = `translateY(${Game.FORCE_TEXT_Y}px)`; - return + advanceTextPosition = Game.wordsDOM.clientHeight + Game.FORCE_TEXT_Y + 5 + } else { + const wordsHeight = Game.wordsDOM.clientHeight; + let diff = wordsHeight - (Game.WORDS_HEIGHT_BOTTOM - offset) + if(diff < 0) diff = 0 + Game.wordsDOM.style.transform = `translateY(${offset - diff}px)`; + advanceTextPosition = offset - diff + wordsHeight + 5 } - const wordsHeight = Game.wordsDOM.clientHeight; - let diff = wordsHeight - (Game.WORDS_HEIGHT_BOTTOM - offset) - if(diff < 0) diff = 0 - - Game.wordsDOM.style.transform = `translateY(${offset - diff}px)`; + // Also, move click_to_advance DOM + $('#click_to_advance').style.transform = `translateY(${Math.round(advanceTextPosition)}px)`; } if(Game.wordsDOM.children.length != lastCount){ diff --git a/scripts/game/Options.js b/scripts/game/Options.js index 29f7f57..7dff887 100644 --- a/scripts/game/Options.js +++ b/scripts/game/Options.js @@ -111,11 +111,6 @@ Loader.addSounds([ } } - // Also, move click_to_advance DOM - var wordsTop = parseInt($("#game_words").style.top); - var wordsHeight = $("#game_words").getBoundingClientRect().height; - click_to_advance.style.top = Math.round(wordsTop+wordsHeight+5) + "px"; - }; var _timeoutCallbacks = []; diff --git a/styles/game.css b/styles/game.css index dfe9da7..3886614 100644 --- a/styles/game.css +++ b/styles/game.css @@ -564,7 +564,6 @@ OPTIONS position: absolute; text-align: center; width: 100%; - top: 254px; color:#fff; }