mirror of
https://github.com/schlagmichdoch/PairDrop.git
synced 2025-04-20 15:06:15 -04:00
fix drop files when no peer is connected yet
This commit is contained in:
parent
87aa958c60
commit
35aac22fae
2 changed files with 24 additions and 7 deletions
|
@ -33,7 +33,7 @@ class PeersUI {
|
|||
this.$cancelPasteModeBtn = $('cancelPasteModeBtn');
|
||||
this.$cancelPasteModeBtn.addEventListener('click', _ => this._cancelPasteMode());
|
||||
|
||||
Events.on('dragover', _ => this._onDragOver());
|
||||
Events.on('dragover', e => this._onDragOver(e));
|
||||
Events.on('dragleave', _ => this._onDragEnd());
|
||||
Events.on('dragend', _ => this._onDragEnd());
|
||||
|
||||
|
@ -120,18 +120,21 @@ class PeersUI {
|
|||
|
||||
_onDrop(e) {
|
||||
e.preventDefault();
|
||||
if (!$$('x-peer').contains(e.target)) {
|
||||
if (!$$('x-peer') || !$$('x-peer').contains(e.target)) {
|
||||
this._activatePasteMode(e.dataTransfer.files, '')
|
||||
}
|
||||
this._onDragEnd();
|
||||
}
|
||||
|
||||
_onDragOver() {
|
||||
_onDragOver(e) {
|
||||
e.preventDefault();
|
||||
this.$xInstructions.setAttribute('drop-bg', 1);
|
||||
this.$xNoPeers.setAttribute('drop-bg', 1);
|
||||
}
|
||||
|
||||
_onDragEnd() {
|
||||
this.$xInstructions.removeAttribute('drop-bg', 1);
|
||||
this.$xNoPeers.removeAttribute('drop-bg');
|
||||
}
|
||||
|
||||
_onPaste(e) {
|
||||
|
@ -285,9 +288,7 @@ class PeerUI {
|
|||
this._callbackTouchStart = _ => this._onTouchStart()
|
||||
this._callbackTouchEnd = e => this._onTouchEnd(e)
|
||||
this._callbackPointerDown = e => this._onPointerDown(e)
|
||||
// prevent browser's default file drop behavior
|
||||
Events.on('dragover', e => e.preventDefault());
|
||||
Events.on('drop', e => e.preventDefault());
|
||||
// PasteMode
|
||||
Events.on('paste-mode-changed', _ => this._onPasteModeChanged());
|
||||
}
|
||||
|
||||
|
|
|
@ -222,6 +222,22 @@ x-peers:not(:empty)+x-no-peers {
|
|||
display: none;
|
||||
}
|
||||
|
||||
x-no-peers::before {
|
||||
color: var(--primary-color);
|
||||
font-size: 24px;
|
||||
font-weight: 400;
|
||||
letter-spacing: -.012em;
|
||||
line-height: 32px;
|
||||
}
|
||||
|
||||
x-no-peers[drop-bg]::before {
|
||||
content: "Release to select recipient";
|
||||
}
|
||||
|
||||
x-no-peers[drop-bg] * {
|
||||
display: none;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Peer */
|
||||
|
@ -827,7 +843,7 @@ x-instructions[drop-peer]:before {
|
|||
}
|
||||
|
||||
x-instructions[drop-bg]:not([drop-peer]):before {
|
||||
content: "Release to select recepient";
|
||||
content: "Release to select recipient";
|
||||
}
|
||||
|
||||
x-instructions p {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue