diff --git a/README.md b/README.md index 3ce862e924..57ed7550c5 100644 --- a/README.md +++ b/README.md @@ -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. @@ -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