Skip to content

Support for leaveFor #9

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

Open
goffioul opened this issue Feb 7, 2018 · 2 comments
Open

Support for leaveFor #9

goffioul opened this issue Feb 7, 2018 · 2 comments

Comments

@goffioul
Copy link

goffioul commented Feb 7, 2018

I've used js-spatial-navigation in another project that wasn't using react. Now I'm considering using it again for a react-based project, hence I ended up finding your library. One feature I'd probably miss is the ability to specify leaveFor in sections. Conceptually, that means that you'd need a way to specify the section ID in the component properties, instead of auto-generating them. Is this something you've considered?

@acontreras89
Copy link

I've had to do this in a project of mine.

// FocusableSection.js
getChildContext() {
  return { focusableSectionId: this.sectionId }
}
// ...
componentWillMount() {
  this.sectionId = this.props.id ? this.props.id : `section-${sectionsIds++}`
}
// ...
JsSpatialNavigation.add({
  leaveFor: this.props.leaveFor, // TODO: Add more options like this
  id: this.sectionId,
  selector: selector,
  enterTo: enterTo,
  defaultElement: defaultElement
})

Some bits may be missing but you get the idea :)

@chwagssd
Copy link

I have a PR open, did it via RenderProps and added a neighborLeft/neighborRight/neighborDown/neighborUp as well as a sectionId property which is needed. It all maps through to the sectionId and leaveFor: {neighborLeft, neighborRight, neighborDown, neighborUp} which gets passed to js-spatial-navigation

You can yarn add https://github.com/chwagssd/react-js-spatial-navigation.git if you like for now, until PR #11 gets merged by @dead

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

No branches or pull requests

3 participants