mirror of
https://github.com/gradio-app/gradio.git
synced 2024-12-09 02:00:44 +08:00
1419538ea7
* asd * changes * fix everything * cleanup * add changeset * fix casing * lockfile * fix casing * fix ci, enable linting * fix test * add changeset * add changeset * delete changeset * fix dirs * fix casing * fix notebooks * fix casing * fix casing * fix casing * fix casing * fix casing * fix casing * fix casing * fix casing --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
34 lines
663 B
Svelte
34 lines
663 B
Svelte
<svelte:options accessors={true} />
|
|
|
|
<script lang="ts">
|
|
import Cropper from "cropperjs";
|
|
import { onMount, createEventDispatcher } from "svelte";
|
|
|
|
export let image: string;
|
|
let el: HTMLImageElement;
|
|
|
|
const dispatch = createEventDispatcher();
|
|
let cropper: Cropper;
|
|
|
|
export function destroy(): void {
|
|
cropper.destroy();
|
|
}
|
|
|
|
export function create(): void {
|
|
if (cropper) {
|
|
destroy();
|
|
}
|
|
cropper = new Cropper(el, {
|
|
autoCropArea: 1,
|
|
cropend(): void {
|
|
const image_data = cropper.getCroppedCanvas().toDataURL();
|
|
dispatch("crop", image_data);
|
|
}
|
|
});
|
|
|
|
dispatch("crop", image);
|
|
}
|
|
</script>
|
|
|
|
<img src={image} bind:this={el} alt="" />
|