暂存
This commit is contained in:
parent
065df5cc9e
commit
1a7e373aa1
@ -46,6 +46,7 @@ export function Avatar(options) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function UploadMusic(options) {
|
export function UploadMusic(options) {
|
||||||
|
let dragStats = null
|
||||||
const drop = createElement({
|
const drop = createElement({
|
||||||
textContent: '点击或拖拽音乐到此处共享您的音乐',
|
textContent: '点击或拖拽音乐到此处共享您的音乐',
|
||||||
style: {
|
style: {
|
||||||
@ -95,14 +96,24 @@ export function UploadMusic(options) {
|
|||||||
onmouseleave: event => {
|
onmouseleave: event => {
|
||||||
drop.style.display = 'none'
|
drop.style.display = 'none'
|
||||||
},
|
},
|
||||||
// 如果拖拽到了子元素上, 也要触发父元素的事件
|
|
||||||
ondragover: event => {
|
ondragover: event => {
|
||||||
console.log('dragover')
|
console.log('dragover')
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
event.stopPropagation()
|
event.stopPropagation()
|
||||||
|
if(dragStats) return
|
||||||
event.dataTransfer.dropEffect = 'copy'
|
event.dataTransfer.dropEffect = 'copy'
|
||||||
drop.style.display = 'block'
|
drop.style.display = 'block'
|
||||||
},
|
},
|
||||||
|
ondragleave: event => {
|
||||||
|
event.preventDefault()
|
||||||
|
event.stopPropagation()
|
||||||
|
if(dragStats) return
|
||||||
|
clearTimeout(dragStats)
|
||||||
|
dragStats = setTimeout(() => {
|
||||||
|
drop.style.display = 'none'
|
||||||
|
dragStats = null
|
||||||
|
}, 1000)
|
||||||
|
},
|
||||||
ondrop: event => {
|
ondrop: event => {
|
||||||
console.log('drop')
|
console.log('drop')
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
@ -112,11 +123,6 @@ export function UploadMusic(options) {
|
|||||||
console.log('files', files)
|
console.log('files', files)
|
||||||
options.onchange(files)
|
options.onchange(files)
|
||||||
},
|
},
|
||||||
ondragleave: event => {
|
|
||||||
event.preventDefault()
|
|
||||||
event.stopPropagation()
|
|
||||||
drop.style.display = 'none'
|
|
||||||
},
|
|
||||||
children: [
|
children: [
|
||||||
// 绘制一个云朵上传图标(别放弃...还有我呢!)
|
// 绘制一个云朵上传图标(别放弃...还有我呢!)
|
||||||
createElement({
|
createElement({
|
||||||
|
Loading…
Reference in New Issue
Block a user