Skip to content

Add wheel helper to events #6

Open

Description

@web-padawan

This was added as part of vaadin/web-components#321

export const wheel = (target, deltaX, deltaY, ctrlKey) => {
  const e = new CustomEvent('wheel', { bubbles: true, cancelable: true });
  e.deltaX = deltaX;
  e.deltaY = deltaY;
  e.ctrlKey = ctrlKey;
  target.dispatchEvent(e);
  return e;
};

And the other one, which is quite similar although not the same:

  function wheel({
    element = scrollTarget,
    deltaX = 0,
    deltaY = 0,
    deltaMode = WheelEvent.DOM_DELTA_PIXEL,
    skipFlush = false,
    ctrlKey = false
  }) {
    const e = new CustomEvent('wheel', { bubbles: true, cancelable: true });
    e.deltaY = deltaY;
    e.deltaX = deltaX;
    e.deltaMode = deltaMode;
    e.ctrlKey = ctrlKey;
    element.dispatchEvent(e);
    if (!skipFlush) {
      virtualizer.flush();
    }
  }

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions