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 nextByDirection and refactor #26

Merged
merged 2 commits into from
May 8, 2023
Merged

Conversation

borisbelmar
Copy link
Owner

@borisbelmar borisbelmar commented May 8, 2023

  • Add nextByDirection to elements, now accepts groups too
api.registerElement(element, 'group-1', {
  nextByDirection: { // This will set the next element manually
    'down': 'element-0-1', // The next element when the user press the down arrow key
    'right': { id: 'group-1', kind: 'group' }, // The next group when the user press the right arrow key
    'up': null, // If press up, no elements will be focused
    'left': undefined // undefined will keep the default behavior
  },
  onFocus: ({ current, prev, direction }) => console.log(`focused ${current.id}`), // Callback when the element is focused. The prev element is the element that was focused before the current element.
  onBlur: ({ current, next, direction }) => console.log(`blurred ${current.id}`) // Callback when the element is blurred. The next element is the element that will be focused when the focus leave the current element.
})
  • Add id to elements, thinking about a future react native adapter on the core
  • Group elements now is a set of ids that references elements on main Map in the state.
  • Deprecated nextElementByDirection

@borisbelmar borisbelmar self-assigned this May 8, 2023
@borisbelmar borisbelmar merged commit ab65588 into develop May 8, 2023
@borisbelmar borisbelmar deleted the feature/next-by-direction branch May 8, 2023 01:34
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

Successfully merging this pull request may close these issues.

None yet

1 participant