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!
This commit is contained in:
spaciecat 2019-09-12 16:23:41 +10:00
parent c56eea3b49
commit c1a136f590
3 changed files with 10 additions and 12 deletions

View File

@ -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){

View File

@ -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 = [];

View File

@ -564,7 +564,6 @@ OPTIONS
position: absolute;
text-align: center;
width: 100%;
top: 254px;
color:#fff;
}