GUAC-807 Moved usage of safeApply to a more sane place.

This commit is contained in:
James Muehlner
2014-11-05 23:59:12 -08:00
parent e33fff4730
commit c2521b1b15

View File

@@ -136,27 +136,27 @@ angular.module('client').directive('guacClient', [function guacClient() {
* size and "auto-fit" setting. * size and "auto-fit" setting.
*/ */
$scope.updateDisplayScale = function() { $scope.updateDisplayScale = function() {
$scope.safeApply(function() {
var guac = $scope.attachedClient;
if (!guac)
return;
// Calculate scale to fit screen var guac = $scope.attachedClient;
$scope.clientProperties.minScale = Math.min( if (!guac)
$scope.main.offsetWidth / Math.max(guac.getDisplay().getWidth(), 1), return;
$scope.main.offsetHeight / Math.max(guac.getDisplay().getHeight(), 1)
);
// Calculate appropriate maximum zoom level // Calculate scale to fit screen
$scope.clientProperties.maxScale = Math.max($scope.clientProperties.minScale, 3); $scope.clientProperties.minScale = Math.min(
$scope.main.offsetWidth / Math.max(guac.getDisplay().getWidth(), 1),
$scope.main.offsetHeight / Math.max(guac.getDisplay().getHeight(), 1)
);
// Clamp zoom level, maintain auto-fit // Calculate appropriate maximum zoom level
if (guac.getDisplay().getScale() < $scope.clientProperties.minScale || $scope.clientProperties.autoFit) $scope.clientProperties.maxScale = Math.max($scope.clientProperties.minScale, 3);
$scope.clientProperties.scale = $scope.clientProperties.minScale;
// Clamp zoom level, maintain auto-fit
if (guac.getDisplay().getScale() < $scope.clientProperties.minScale || $scope.clientProperties.autoFit)
$scope.clientProperties.scale = $scope.clientProperties.minScale;
else if (guac.getDisplay().getScale() > $scope.clientProperties.maxScale)
$scope.clientProperties.scale = $scope.clientProperties.maxScale;
else if (guac.getDisplay().getScale() > $scope.clientProperties.maxScale)
$scope.clientProperties.scale = $scope.clientProperties.maxScale;
});
}; };
/** /**
@@ -599,7 +599,7 @@ angular.module('client').directive('guacClient', [function guacClient() {
// If the window is resized, attempt to resize client // If the window is resized, attempt to resize client
$window.addEventListener('resize', function onResizeWindow() { $window.addEventListener('resize', function onResizeWindow() {
$scope.updateDisplayScale(); $scope.safeApply($scope.updateDisplayScale());
}); });
var show_keyboard_gesture_possible = true; var show_keyboard_gesture_possible = true;