luke-chang / js-spatial-navigation

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

How to check the current focused Element is the last element #17

Closed nickcartery closed 7 years ago

nickcartery commented 7 years ago

Hi Luke,

How can I check the current element is the last item? I want to remove all focusable class in the list TV and add new focusable class to the left menu and reinitialize for this menu?

Take a look at my site plz: http://tv.beeb.vn

Thanks!

luke-chang commented 7 years ago

Hi,

I'm not quite sure your scenario. What did you mean the last item? Is it the item that no more items in its down direction?

nickcartery commented 7 years ago

Is it the item that no more items in its down direction? Yes :D All 4 directions, I want to check if the current item is at the end or the beginning of row, to focus to new area

luke-chang commented 7 years ago

You can listen to sn:navigatefailed event. It's fired when nothing happens upon pressing arrow keys.

Note that you might want to set straightOnly to prevent the focus from moving to elements in the oblique directions.