|
206 | 206 | cropImageNaturalHeight = cropImageElement.naturalHeight; |
207 | 207 | resetCrop(); |
208 | 208 | }} |
| 209 | + on:error={() => { |
| 210 | + cropImageNaturalWidth = 0; |
| 211 | + cropImageNaturalHeight = 0; |
| 212 | + error = 'Could not read this image. Try saving it as a JPEG or PNG first.'; |
| 213 | + }} |
209 | 214 | /> |
210 | | - <div |
211 | | - class="crop-box" |
212 | | - style={cropBoxStyle} |
213 | | - role="presentation" |
214 | | - on:pointerdown={startCropDrag} |
215 | | - on:pointermove={dragCrop} |
216 | | - on:pointerup={stopCropDrag} |
217 | | - on:pointercancel={stopCropDrag} |
218 | | - > |
219 | | - {#each cropResizeHandles as handle} |
220 | | - <button |
221 | | - type="button" |
222 | | - class={`crop-handle ${handle}`} |
223 | | - aria-label={`Resize crop ${handle}`} |
224 | | - on:pointerdown={(event) => startCropResize(event, handle)} |
225 | | - on:pointermove={resizeCrop} |
226 | | - on:pointerup={stopCropResize} |
227 | | - on:pointercancel={stopCropResize} |
228 | | - ></button> |
229 | | - {/each} |
230 | | - </div> |
| 215 | + {#if cropImageNaturalWidth && cropImageNaturalHeight} |
| 216 | + <div |
| 217 | + class="crop-box" |
| 218 | + style={cropBoxStyle} |
| 219 | + role="presentation" |
| 220 | + on:pointerdown={startCropDrag} |
| 221 | + on:pointermove={dragCrop} |
| 222 | + on:pointerup={stopCropDrag} |
| 223 | + on:pointercancel={stopCropDrag} |
| 224 | + > |
| 225 | + {#each cropResizeHandles as handle} |
| 226 | + <button |
| 227 | + type="button" |
| 228 | + class={`crop-handle ${handle}`} |
| 229 | + aria-label={`Resize crop ${handle}`} |
| 230 | + on:pointerdown={(event) => startCropResize(event, handle)} |
| 231 | + on:pointermove={resizeCrop} |
| 232 | + on:pointerup={stopCropResize} |
| 233 | + on:pointercancel={stopCropResize} |
| 234 | + ></button> |
| 235 | + {/each} |
| 236 | + </div> |
| 237 | + {/if} |
231 | 238 | </div> |
232 | 239 | <div class="crop-controls"> |
233 | 240 | <span>Drag the edges or corners to crop.</span> |
|
0 commit comments