0.3.3 • Published 2 years ago

react-dnd-image-puzzle2 v0.3.3

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

React DnD Image Puzzle

(Forked from https://github.com/ferthings/react-dnd-image-puzzle)

Create a puzzle from an image

Install package

npm install react-dnd-image-puzzle2

Your app

import Puzzle from 'react-dnd-image-puzzle2';

function App() {
  const onComplete = () => {
    console.log('Puzzle is completed!');
  };

  return (
    <Puzzle
      image="https://www.laurag.tv/wp-content/uploads/2020/02/bob-esponja.jpg"
      imageWidth={800}
      imageHeight={480}
      height={100}
      width={100}
      pieces={4}
      onSwap={onSwap}
      onComplete={onComplete}
    />
  );
}

export default App;

Props

PropertyTypeRequiredDefaultDescription
imagestringyesImage for the puzzle: an absoulte image URI or an imported image
imageWidthnumberno400Source image width (to keep a.ratio)
imageHeightnumberno300Source image height (to keep a.ratio)
widthnumberno400Puzzle area width
heightnumberno300Puzzle area height
piecesnumberno3Number of pieces per side. 3x3 pieces by default
onCompletefuncitonnoCallback when the puzzle is completed
onSwapfuncitonnoCallback when the puzzle items swapped

0.3.0

2 years ago

0.3.2

2 years ago

0.3.1

2 years ago

0.3.3

2 years ago

0.2.22

2 years ago

0.2.21

2 years ago

0.2.2

2 years ago

0.2.1

2 years ago

0.2.0

2 years ago

0.1.0

2 years ago