def setup
c = createCanvas(100, 100)
background(200)
textAlign(CENTER)
text('drag & drop file', width / 2, height / 2)
c.dragOver do
background(240)
text('Dragged over', width / 2, height / 2)
end
c.dragLeave do
background(200)
text('Dragged off', width / 2, height / 2)
end
c.drop do |file|
background(200)
text('dropped file:', width / 2, height / 2)
text("[#{file.type}]", width / 2, height / 2 + 30)
end
end
[p5.js] (p5.Element.obj).dragOver
ファイルが HTML要素上にドラッグされたときに実行する処理を登録します。
| 引数名 | 内容 | 備考 | オプション | デフォルト値 |
|---|---|---|---|---|
| void | 無効化 | falseが指定された場合にはブロックは実行されない | ○ | nil |
| ... | ブロック | 実行する処理 |
なし