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

feat(custom-dnd-backend): Add props to override react-dnd backend #19

Merged
merged 1 commit into from Feb 20, 2022
Merged

feat(custom-dnd-backend): Add props to override react-dnd backend #19

merged 1 commit into from Feb 20, 2022

Conversation

robbertkl
Copy link
Contributor

My last one for now, I promise 😉

I realise this is a bit of a power user feature, but I was in need of using the react-dnd's TouchBackend instead of MultiBackend+HTML5toTouch. The reason is I'm using sound effects and the HTML5 drags for some reason don't count as user interaction, so modern browsers will disallow audio playing if it's not triggered by user interaction. TouchBackend (with mouse enabled) works perfectly fine for me, even though it has a note about being buggy and it is recognized as user interaction.

Anyway, only using TouchBackend might not be for everyone, so for this PR I decided to add a prop (or 2 actually) to be able to swap out the backend for a different one.

Usage:

import { Chessboard } from 'react-chessboard';
import { TouchBackend } from 'react-dnd-touch-backend';

...

<Chessboard
  ...
  customDndBackend={TouchBackend}
  customDndBackendOptions={{ enableMouseEvents: true }}
/>

Of course, leaving out these props will keep the existing behavior of using MultiBackend+ HTML5toTouch.

@vercel
Copy link

vercel bot commented Feb 19, 2022

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/clariity/react-chessboard/84h4NsqZ1Xyro18zCwGHbUmvC2tp
✅ Preview: https://react-chessboard-git-fork-robbertkl-custom-dnd-backend-clariity.vercel.app

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

2 participants