Browse Source

Just some minor work on file dropping.

dev-bank
Bryan Miller 6 years ago
parent
commit
1e47e836dd
2 changed files with 28 additions and 0 deletions
  1. +25
    -0
      app/js/ctrls/CTRLIO.js
  2. +3
    -0
      app/js/main.js

+ 25
- 0
app/js/ctrls/CTRLIO.js View File

@@ -4,8 +4,33 @@ import NESBank from "/app/js/models/NESBank.js";
import NESPalette from "/app/js/models/NESPalette.js";



function HANDLE_DragOver(e){
e.stopPropagation();
e.preventDefault();
e.dataTransfer.dropEffect = 'copy';
};

function HANDLE_FileDrop(e){
e.stopPropagation();
e.preventDefault();
var files = e.dataTransfer.files;

for (let i=0; i < files.length; i++){
console.log(files[i]);
}
}

class CTRLIO{
constructor(){}

initialize(){
var e = document.querySelectorAll(".drop-zone");
for (let i=0; i < e.length; e++){
e[i].addEventListener("dragover", HANDLE_DragOver);
e[i].addEventListener("drop", HANDLE_FileDrop);
}
}
}



+ 3
- 0
app/js/main.js View File

@@ -8,6 +8,7 @@ import CTRLPainter from "/app/js/ctrls/CTRLPainter.js";
import CTRLPalettesStore from "/app/js/ctrls/CTRLPalettesStore.js";
import CTRLBanksStore from "/app/js/ctrls/CTRLBanksStore.js";
import CTRLBankTools from "/app/js/ctrls/CTRLBankTools.js";
import CTRLIO from "/app/js/ctrls/CTRLIO.js";

import NESPalette from "/app/js/models/NESPalette.js";

@@ -36,6 +37,8 @@ function initialize(DOC){

CTRLPalettesStore.initialize();
CTRLBanksStore.initialize();

CTRLIO.initialize();
}



Loading…
Cancel
Save