mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 21:27:40 +00:00
GUACAMOLE-724: Add per-tile visual indication of drag/drop.
This commit is contained in:
@@ -532,27 +532,63 @@ angular.module('client').directive('guacClient', [function guacClient() {
|
||||
if ($scope.client.clientProperties.focused)
|
||||
client.sendKeyEvent(0, keysym);
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* Ignores the given event.
|
||||
*
|
||||
* @param {Event} e The event to ignore.
|
||||
* Whether a drag/drop operation is currently in progress (the user has
|
||||
* dragged a file over the Guacamole connection but has not yet
|
||||
* dropped it).
|
||||
*
|
||||
* @type boolean
|
||||
*/
|
||||
function ignoreEvent(e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
}
|
||||
|
||||
// Handle and ignore dragenter/dragover
|
||||
displayContainer.addEventListener("dragenter", ignoreEvent, false);
|
||||
displayContainer.addEventListener("dragover", ignoreEvent, false);
|
||||
|
||||
// File drop event handler
|
||||
displayContainer.addEventListener("drop", function(e) {
|
||||
$scope.dropPending = false;
|
||||
|
||||
/**
|
||||
* Displays a visual indication that dropping the file currently
|
||||
* being dragged is possible. Further propogation and default behavior
|
||||
* of the given event is automatically prevented.
|
||||
*
|
||||
* @param {Event} e
|
||||
* The event related to the in-progress drag/drop operation.
|
||||
*/
|
||||
var notifyDragStart = function notifyDragStart(e) {
|
||||
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
|
||||
$scope.$apply(() => {
|
||||
$scope.dropPending = true;
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Removes the visual indication that dropping the file currently
|
||||
* being dragged is possible. Further propogation and default behavior
|
||||
* of the given event is automatically prevented.
|
||||
*
|
||||
* @param {Event} e
|
||||
* The event related to the end of the former drag/drop operation.
|
||||
*/
|
||||
var notifyDragEnd = function notifyDragEnd(e) {
|
||||
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
|
||||
$scope.$apply(() => {
|
||||
$scope.dropPending = false;
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
main.addEventListener('dragenter', notifyDragStart, false);
|
||||
main.addEventListener('dragover', notifyDragStart, false);
|
||||
main.addEventListener('dragleave', notifyDragEnd, false);
|
||||
|
||||
// File drop event handler
|
||||
main.addEventListener('drop', function(e) {
|
||||
|
||||
notifyDragEnd(e);
|
||||
|
||||
// Ignore file drops if no attached client
|
||||
if (!$scope.client)
|
||||
return;
|
||||
|
@@ -127,3 +127,11 @@ body.client {
|
||||
padding-left: 2.5em;
|
||||
background-image: url('images/x.svg');
|
||||
}
|
||||
|
||||
.client .drop-pending .display {
|
||||
background: #3161a9;
|
||||
}
|
||||
|
||||
.client .drop-pending .display > *{
|
||||
opacity: 0.5;
|
||||
}
|
@@ -1,5 +1,8 @@
|
||||
<div class="main" guac-resize="mainElementResized"
|
||||
guac-touch-drag="clientDrag" guac-touch-pinch="clientPinch">
|
||||
<div class="main"
|
||||
ng-class="{ 'drop-pending': dropPending }"
|
||||
guac-resize="mainElementResized"
|
||||
guac-touch-drag="clientDrag"
|
||||
guac-touch-pinch="clientPinch">
|
||||
|
||||
<!-- Display -->
|
||||
<div class="displayOuter">
|
||||
|
Reference in New Issue
Block a user