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

Mousewheel support #176

Open
Bilge opened this issue Jan 25, 2024 · 1 comment
Open

Mousewheel support #176

Bilge opened this issue Jan 25, 2024 · 1 comment

Comments

@Bilge
Copy link

Bilge commented Jan 25, 2024

Hi, I would use this library if it had mouse-wheel support for scrolling years.

@mymth
Copy link
Owner

mymth commented Feb 18, 2024

It doesn't seem to me that to scroll years is a preference common to many. Some may want to scroll months, others may want to move the focused date. Some may want it to work only when a modifier key is pressed, others may think it's totally unnecessary. So, I think it's better to be done by the user on their app.

You should be able to do it by something like this:

const elem = document.querySelector('.date');
const dp = new Datepicker(elem);

elem.addEventListener('wheel', (ev) => {
  const date = dp.getFocusedDate();
  const year = date.getFullYear() + (ev.deltaY > 0 ? 1 : -1);

  dp.setFocusedDate(date.setFullYear(year));
  ev.preventDefault();
});

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