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

Add support for PageUp, PageDown, Home, and End keys #10

Closed
jwahyoung opened this issue Oct 16, 2015 · 4 comments
Closed

Add support for PageUp, PageDown, Home, and End keys #10

jwahyoung opened this issue Oct 16, 2015 · 4 comments

Comments

@jwahyoung
Copy link
Contributor

The plugin supports scrolling by keyboard but does not capture non-arrow keypresses. Quick fix for this is as follows in scrollHandler.js:

  keyDown(event) {
    var delta = 0;
    switch(event.keyCode) {
      case 36: // Home key
        delta = Number.POSITIVE_INFINITY;
        break;
      case 35: // End key
        delta = Number.NEGATIVE_INFINITY;
        break;
      case 33: // Page up
        delta = this.pageStep;
        break;
      case 34: // Page down
        delta = -this.pageStep;
        break;
      case 38: // Up arrow
        delta = this.keyStep;
        break;
      case 40: // Down arrow
        delta = -this.keyStep;
        break;
    }
@rquast
Copy link

rquast commented Oct 20, 2015

Thanks, Jedd. That works for me.

I used the code in my fork plus I added a onmouseover="focus()" for the template so it gets the key events when a mouse is hovered over it, without having to click on it first.

For the key and page steps, maybe there's some way we can measure the rendered height of the custom element and use that instead of a magic number? That way page down will be a page, and not skip pages.

@jwahyoung
Copy link
Contributor Author

@rquast Indeed. I actually mentioned this in the comments section of #12. At first I thought the height would have to be passed to the scrollhandler initialize function, but it looks like the first argument to that is a DOM element, so it might actually be possible to grab the height from that and use that as the page length. Offhand, I'm not sure how to handle the container resizing. There's an event for that in virtual-repeat.js but I haven't yet looked deeply into changing the page scroll height.

Edit: Whoops, accidentally clicked "Close" instead of "Comment".

@jwahyoung jwahyoung reopened this Oct 20, 2015
@rquast
Copy link

rquast commented Oct 21, 2015

virtual-repeat contains an updated scroll container height. I've passed it in, but I think I need to work on the delta (it doesn't do a full page down even though it sends container height).

https://github.com/rquast/ui-virtualization/commit/92b5e2d51067c6b88e4bc446777137d38abd37af

@martingust
Copy link
Contributor

@rquast @jedd-ahyoung Wow I'm glad to see the activity and work you guys putting into the plugin. Will go over the PRs soon, thanks!

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

No branches or pull requests

3 participants