From ad6794a8ae8b14d639470b34bda64e4088b7016e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonardo=20Mur=C3=A7a?= Date: Fri, 11 Nov 2022 11:12:39 -0300 Subject: [PATCH] Add event modifiers --- src/lib/FileViewer.svelte | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/src/lib/FileViewer.svelte b/src/lib/FileViewer.svelte index 08d98aa..586b32d 100644 --- a/src/lib/FileViewer.svelte +++ b/src/lib/FileViewer.svelte @@ -5,10 +5,7 @@ const acceptedFiles = [".pes"]; const maxFileSize = 700000; - function onSubmitHandler(evt) { - evt.stopPropagation(); - evt.preventDefault(); - + function onSubmitHandler() { for (var i = 0, file; (file = files[i]); i++) { const canvasContainer = document.getElementById("canvas-container"); const canvasCard = document.createElement(`div`); @@ -42,14 +39,7 @@ document.getElementById("selected-files-container").remove(); } - function handleDragOver(evt) { - evt.stopPropagation(); - evt.preventDefault(); - } - function onDropHandler(evt) { - evt.stopPropagation(); - evt.preventDefault(); onChangeFileHandler(evt); } @@ -71,7 +61,7 @@ files = filesToUpload; } - function handleOnClick(evt) { + function handleOnClick() { document.getElementById("file-input").click(); } @@ -82,7 +72,11 @@ } -
+

Upload files

Max file size is {maxFileSize / 1000}kb. Accepted formats: @@ -95,8 +89,8 @@ tabindex={0} on:keydown={handleOnKeydown} on:click={handleOnClick} - on:dragover={handleDragOver} - on:drop={onDropHandler} + on:dragover|preventDefault|stopPropagation + on:drop|preventDefault|stopPropagation={onDropHandler} >