Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
gaearon committed Oct 21, 2014
1 parent 9b4fcec commit 0e94426
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -280,17 +280,22 @@ getImageUrlsToPreload() {
}

// You can now use `this.hasPreloadedImage(url)` and `this.getPreloadedImage(url)` in your `dragSource`:
// ...
// canDrag() {
// return this.hasPreloadedImage('some-img-url1');
// },
//
// beginDrag() {
// return {
// item: ...,
// dragPreivew: this.getPreloadedImage('some-img-url1');
// };
// }
configureDragDrop(registerType) {
registerType(ItemTypes.IMAGE, {
dragSource: {
canDrag() {
return this.hasPreloadedImage('some-img-url1');
},

beginDrag() {
return {
item: ...,
dragPreivew: this.getPreloadedImage('some-img-url1');
};
}
}
});
}
```
Above code will load the images after `componentDidMount` is executed, and cache them until component unmounted.
Expand All @@ -300,11 +305,6 @@ Note that, for best results, you want to use `this.calculateDragPreviewSize({ wi
It will return the exact size of image you need to download, considering browser differences in handling Retina screens.
Of course you can only use this if you have some kind of custom image resizer.
===================
TODO: describe how to use it for preloading drag thumbnails
## Thanks
Expand Down

0 comments on commit 0e94426

Please sign in to comment.