<commit_before>/**
* @ngdoc directive
* @name umbraco.directives.directive:umbImageGravity
* @restrict E
* @function
* @description
**/
angular.module("umbraco.directives")
	.directive('umbImageGravity', function ($timeout, localizationService, $log) {
	    return {
				restrict: 'E',
				replace: true,
				templateUrl: 'views/components/imaging/umb-image-gravity.html',
				scope: {
					src: '=',
					center: "=",
                    onImageLoaded: "&",
                    onGravityChanged: "&"
				},
				link: function(scope, element, attrs) {

					//Internal values for keeping track of the dot and the size of the editor
					scope.dimensions = {
						width: 0,
						height: 0,
						left: 0,
						top: 0
					};

					scope.loaded = false;

					//elements
					var $viewport = element.find(".viewport");
					var $image = element.find("img");
                    var $overlay = element.find(".overlay");

				    scope.style = function () {
                        if (scope.dimensions.width <= 0) {
							setDimensions();
						}

						return {
							'top': scope.dimensions.top + 'px',
							'left': scope.dimensions.left + 'px'
						};
					};

					scope.setFocalPoint = function(event) {
					    scope.$emit("imageFocalPointStart");

					    var offsetX = event.offsetX - 10;
					    var offsetY = event.offsetY - 10;

					    calculateGravity(offsetX, offsetY);

					    gravityChanged();
					};

                    var setDimensions = function () {
                    if (scope.isCroppable) {
					        scope.dimensions.width = $image.width();
					        scope.dimensions.height = $image.height();
                            
					        if(scope.center){
							    scope.dimensions.left =  scope.center.left * scope.dimensions.width -10;<commit_msg>Validate both width and height<commit_after>/**
* @ngdoc directive
* @name umbraco.directives.directive:umbImageGravity
* @restrict E
* @function
* @description
**/
angular.module("umbraco.directives")
	.directive('umbImageGravity', function ($timeout, localizationService, $log) {
	    return {
				restrict: 'E',
				replace: true,
				templateUrl: 'views/components/imaging/umb-image-gravity.html',
				scope: {
					src: '=',
					center: "=",
                    onImageLoaded: "&",
                    onGravityChanged: "&"
				},
				link: function(scope, element, attrs) {

					//Internal values for keeping track of the dot and the size of the editor
					scope.dimensions = {
						width: 0,
						height: 0,
						left: 0,
						top: 0
					};

					scope.loaded = false;

					//elements
					var $viewport = element.find(".viewport");
					var $image = element.find("img");
                    var $overlay = element.find(".overlay");

				    scope.style = function () {
                        if (scope.dimensions.width <= 0 || scope.dimensions.height <= 0) {
							setDimensions();
						}

						return {
							'top': scope.dimensions.top + 'px',
							'left': scope.dimensions.left + 'px'
						};
					};

					scope.setFocalPoint = function(event) {
					    scope.$emit("imageFocalPointStart");

					    var offsetX = event.offsetX - 10;
					    var offsetY = event.offsetY - 10;

					    calculateGravity(offsetX, offsetY);

					    gravityChanged();
					};

                    var setDimensions = function () {
                    if (scope.isCroppable) {
					        scope.dimensions.width = $image.width();
					        scope.dimensions.height = $image.height();
                            
					        if(scope.center){
							    scope.dimensions.left =  scope.center.left * scope.dimensions.width -10;
{'fraction_non_alphanumeric': 0.13142700027495188, 'fraction_numerical': 0.006323893318669233, 'mean_word_length': 1.8804433887569278, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7254980', 'n_tokens_mistral': 1431, 'n_tokens_neox': 1039, 'n_words': 219}