aframe-gui
aframe-gui copied to clipboard
slider does not emit an event on slider being set.
should probably expose a 'mouseup' event on the slider button for easy use, as you probably want to run some code once the slider is set.
happy to contribute this, but don't want to start doing a lot of pull requests while I know a lot of uncommitted code is out there waiting to be merged.
for now, I've hacked it in this way:
(await vrgc.getElement('#command-brightness-slider')).addEventListener('mouseup', async function(el) {
const newPercent = (await vrgc.getElement('#command-brightness-slider')).components['gui-slider'].data.percent;
(await vrgc.getElement('[light]')).setAttribute('light', 'intensity', newPercent * 3); // treating 3 as 100%
})
after solving it that way, I later realized a more efficient, subtle hack:
['onclick', `
console.log('old slider value', this.components['gui-slider'].data.percent, this);
(async function(el) {
await vrgc.waitForTime(1) // ms
console.log('new slider value', el.components['gui-slider'].data.percent, this);
})(this)
`],