Skip to content

Commit

Permalink
support multiple file drag
Browse files Browse the repository at this point in the history
  • Loading branch information
memelotsqui committed Oct 22, 2023
1 parent fdd8315 commit c319220
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions src/components/FileDropComponent.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
import React, { useEffect, useState } from 'react';
import styles from './FileDropComponent.module.css';

export default function FileDropComponent ({onFileDrop}){
export default function FileDropComponent ({onFilesDrop}){
const [isDragging, setIsDragging] = useState(false);

useEffect(() => {
const handleDrop = (event) => {
event.preventDefault();
setIsDragging(false);
const file = event.dataTransfer.files[0];
if (onFileDrop) {
onFileDrop(file);
const files = event.dataTransfer.files;
if (onFilesDrop) {
onFilesDrop(files);
}
};

Expand Down
6 changes: 3 additions & 3 deletions src/pages/Appearance.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ function Appearance({
// Translate hook
const { t } = useContext(LanguageContext)

const handleFileDrop = async(file) => {
const handleFilesDrop = async(files) => {
const file = files[0];
// Check if the file has the .fbx extension
if (file && file.name.toLowerCase().endsWith('.fbx')) {
const animName = getFileNameWithoutExtension(file.name);
Expand Down Expand Up @@ -111,7 +112,6 @@ function Appearance({


const jsonSelection = {name: jsonName, thumb:thumbLocation,attributes:jsonAttributes}
console.log(jsonSelection);
setJsonSelection(jsonSelection);

jsonContent.attributes.forEach(attribute => {
Expand Down Expand Up @@ -155,7 +155,7 @@ function Appearance({
</div>
<div className={"sectionTitle"}>{t("pageTitles.chooseAppearance")}</div>
<FileDropComponent
onFileDrop={handleFileDrop}
onFilesDrop={handleFilesDrop}
/>
<Editor
animationManager={animationManager}
Expand Down

0 comments on commit c319220

Please sign in to comment.