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

Scroll wheel over image #2

Open
mbarkhau opened this issue Mar 8, 2022 · 1 comment
Open

Scroll wheel over image #2

mbarkhau opened this issue Mar 8, 2022 · 1 comment

Comments

@mbarkhau
Copy link

mbarkhau commented Mar 8, 2022

When the mouse is over the image, how hard would it be to hook up the scroll wheel, so that

  1. It switches to the 8x8 block over which the cursor is (same as a click currently)
  2. Updates the value of the slider.
@OmarShehata
Copy link
Owner

oooh, that would be a really nice UX for this! It shouldn't be too hard. The function JpegUtils.getDCTBlockFromClick should work with a mouse over event (it should be rewritten to just take in a mouse position I think to make this easier)

Here's how it's currently used to get the current block that's clicked on:

const { block, x, y } = JpegUtils.getDCTBlockFromClick(event, decodedImage, canvas);

So you'd want to wrap that code snippet up in a function so it can run either on click or on mouse wheel.

It's a similar thing for the slider. Actually, all you'd need to do is update the slider DOM element's value on mouse wheel and it will all "just work". Alternatively you can refactor it so that what the slider oninput event does can be reused on mouse wheel:

const finalIndex = e.target.value;

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

2 participants