luke-chang / js-spatial-navigation

A javascript-based implementation of Spatial Navigation.
Mozilla Public License 2.0
370 stars 117 forks source link

Allow navigation with Mousewheel too #21

Closed onigetoc closed 6 years ago

onigetoc commented 6 years ago

How can i implement and add mousewheel navigation with spatial navigation? May be with this jQuery plugin https://plugins.jquery.com/mousewheel/ https://stackoverflow.com/questions/29652911/catch-mousewheel-up-or-down-with-jquery-js-without-actually-scrolling/29656088#29656088

luke-chang commented 6 years ago

Yeah, it's a good option. Maybe you can do something like:

$(window).mousewheel(function(turn, delta) {
  if (delta == 1) {
    SpatialNavigation.move("down");
  } else {
    SpatialNavigation.move("up");
  }
  return false;
});
onigetoc commented 6 years ago

Thank you, this is exactly what i did yesterday and it's working. Mousewheel + Sound navigation. Far from perfect, i will try to center focused element on overflow. http://tvcast.top/scripts/js-spatial-navigation-master/demo/3.2_like_youtube_tv-mousewheel.html

luke-chang commented 6 years ago

Good to know it works. :)