editor: grid width input safe vs NaN and trigger update on any change

This commit is contained in:
jean-emmanuel 2016-12-11 22:31:43 +01:00
parent ecd2cbeb24
commit 932558e338

View file

@ -129,8 +129,9 @@ module.exports = {
w = $('<div class="input-wrapper"><label>Grid</label></div>').appendTo(f),
i = $('<input type="number" step="1" min="1" max="100"></div>').appendTo(w)
i.val(GRIDWIDTH)
i.change(()=>{
i.on('keyup mouseup change mousewheel',()=>{
var v = Math.max(Math.min(parseInt(i.val()),100),1)
if (isNaN(v)) return
i.val(v)
GRIDWIDTH = v
document.documentElement.style.setProperty("--grid-width",GRIDWIDTH)