From 967bec99b0cbf4e1227a891eba0090b3d7a8a865 Mon Sep 17 00:00:00 2001 From: Vladimir Mandic Date: Tue, 27 Oct 2020 14:20:21 -0400 Subject: [PATCH] updated menu library --- demo/menu.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/demo/menu.js b/demo/menu.js index 493efc06..014521d9 100644 --- a/demo/menu.js +++ b/demo/menu.js @@ -133,10 +133,15 @@ class Menu { async addRange(title, object, variable, min, max, step, callback) { const el = document.createElement('div'); el.className = 'menu-item'; - el.innerHTML = `${title}`; + const arr = Array.isArray(variable); + el.innerHTML = `${title}`; this.container.appendChild(el); el.addEventListener('change', (evt) => { - object[variable] = evt.target.value; + const int = parseInt(evt.target.value) === parseFloat(evt.target.value); + const val = Array.isArray(variable) ? variable : [variable]; + for (const item of val) { + object[item] = int ? parseInt(evt.target.value) : parseFloat(evt.target.value); + } evt.target.setAttribute('value', evt.target.value); if (callback) callback(evt.target.value); });