mirror of
				https://github.com/gyurix1968/guacamole-client.git
				synced 2025-10-31 00:53:21 +00:00 
			
		
		
		
	GUAC-963: Clean up guacViewport upon destruction.
This commit is contained in:
		| @@ -28,11 +28,11 @@ angular.module('client').directive('guacViewport', [function guacViewport() { | |||||||
|     return { |     return { | ||||||
|         // Element only |         // Element only | ||||||
|         restrict: 'E', |         restrict: 'E', | ||||||
|         scope: false, |         scope: {}, | ||||||
|         transclude: true, |         transclude: true, | ||||||
|         templateUrl: 'app/client/templates/guacViewport.html', |         templateUrl: 'app/client/templates/guacViewport.html', | ||||||
|         controller: ['$window', '$document', '$element', |         controller: ['$scope', '$window', '$document', '$element', | ||||||
|             function guacViewportController($window, $document, $element) { |             function guacViewportController($scope, $window, $document, $element) { | ||||||
|  |  | ||||||
|             /** |             /** | ||||||
|              * The fullscreen container element. |              * The fullscreen container element. | ||||||
| @@ -55,8 +55,12 @@ angular.module('client').directive('guacViewport', [function guacViewport() { | |||||||
|              */ |              */ | ||||||
|             var currentAdjustedHeight = null; |             var currentAdjustedHeight = null; | ||||||
|  |  | ||||||
|             // Fit container within visible region when window scrolls |             /** | ||||||
|             $window.onscroll = function fitScrollArea() { |              * Resizes the container element inside the guacViewport such that | ||||||
|  |              * it exactly fits within the visible area, even if the browser has | ||||||
|  |              * been scrolled. | ||||||
|  |              */ | ||||||
|  |             var fitVisibleArea = function fitVisibleArea() { | ||||||
|  |  | ||||||
|                 // Pull scroll properties |                 // Pull scroll properties | ||||||
|                 var scrollLeft   = document.body.scrollLeft; |                 var scrollLeft   = document.body.scrollLeft; | ||||||
| @@ -82,6 +86,14 @@ angular.module('client').directive('guacViewport', [function guacViewport() { | |||||||
|  |  | ||||||
|             }; |             }; | ||||||
|  |  | ||||||
|  |             // Fit container within visible region when window scrolls | ||||||
|  |             $window.addEventListener('scroll', fitVisibleArea); | ||||||
|  |  | ||||||
|  |             // Clean up event listener on destroy | ||||||
|  |             $scope.$on('$destroy', function destroyViewport() { | ||||||
|  |                 $window.removeEventListener('scroll', fitVisibleArea); | ||||||
|  |             }); | ||||||
|  |  | ||||||
|         }] |         }] | ||||||
|     }; |     }; | ||||||
| }]); | }]); | ||||||
		Reference in New Issue
	
	Block a user