X-Git-Url: http://git.shiar.nl/sheet.git/blobdiff_plain/7581b5c3f07dcb43414160f7c3b6a294ce838904..140051e24ff5a74421e8b437cdc12ca8570995cd:/word/memory.js?ds=sidebyside diff --git a/word/memory.js b/word/memory.js index 89fd853..ac1e829 100644 --- a/word/memory.js +++ b/word/memory.js @@ -60,11 +60,13 @@ class WordMemory extends WordQuiz { let cards; if (this.words) { - const formstyle = window.getComputedStyle(this.form) - const gridsize = [ - formstyle['grid-template-rows'], formstyle['grid-template-columns'] - ].map(val => val.match(/ /g).length + 1).reduce((x, y) => x * y) / 2; - cards = this.words.splice(0, gridsize || 6).map(row => row[2]); + const aspect = this.form.clientWidth / window.innerHeight; + //TODO image ratio + let count = 35; + let cols = Math.round(Math.sqrt(count) * aspect**.5); + count = cols * Math.ceil(count / cols); + this.form.style['grid-template-columns'] = `repeat(${cols}, 1fr)`; + cards = this.words.splice(0, count>>1).map(row => row[2]); cards.push(...cards.map(val => -val)); } else {