Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

slider does not emit an event on slider being set. #45

Open
kylebakerio opened this issue Jan 6, 2021 · 2 comments
Open

slider does not emit an event on slider being set. #45

kylebakerio opened this issue Jan 6, 2021 · 2 comments

Comments

@kylebakerio
Copy link
Collaborator

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.

@kylebakerio
Copy link
Collaborator Author

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%
})

@kylebakerio
Copy link
Collaborator Author

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)
				`],

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant