OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 'use strict'; | 5 'use strict'; |
6 | 6 |
7 /** | 7 /** |
8 * Crop mode. | 8 * Crop mode. |
9 * | 9 * |
10 * @extends {ImageEditor.Mode} | 10 * @extends {ImageEditor.Mode} |
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
347 | 347 |
348 /** | 348 /** |
349 * Obtains the bottom position. | 349 * Obtains the bottom position. |
350 * @return {number} Position. | 350 * @return {number} Position. |
351 */ | 351 */ |
352 DraggableRect.prototype.getBottom = function() { | 352 DraggableRect.prototype.getBottom = function() { |
353 return this.bounds_[DraggableRect.BOTTOM]; | 353 return this.bounds_[DraggableRect.BOTTOM]; |
354 }; | 354 }; |
355 | 355 |
356 /** | 356 /** |
357 * Obtains the geometory of the rectangle. | 357 * Obtains the geometry of the rectangle. |
358 * @return {Rect} Geometory of the rectangle. | 358 * @return {Rect} Geometry of the rectangle. |
359 */ | 359 */ |
360 DraggableRect.prototype.getRect = function() { | 360 DraggableRect.prototype.getRect = function() { |
361 return new Rect(this.bounds_); | 361 return new Rect(this.bounds_); |
362 }; | 362 }; |
363 | 363 |
364 /** | 364 /** |
365 * Obtains the drag mode depending on the coordinate. | 365 * Obtains the drag mode depending on the coordinate. |
366 * | 366 * |
367 * @param {number} x X coordinate for cursor. | 367 * @param {number} x X coordinate for cursor. |
368 * @param {number} y Y coordinate for cursor. | 368 * @param {number} y Y coordinate for cursor. |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
444 } | 444 } |
445 var ySymbol = ''; | 445 var ySymbol = ''; |
446 switch (mode.ySide) { | 446 switch (mode.ySide) { |
447 case 'top': ySymbol = 'n'; break; | 447 case 'top': ySymbol = 'n'; break; |
448 case 'bottom': ySymbol = 's'; break; | 448 case 'bottom': ySymbol = 's'; break; |
449 } | 449 } |
450 return ySymbol + xSymbol + '-resize'; | 450 return ySymbol + xSymbol + '-resize'; |
451 }; | 451 }; |
452 | 452 |
453 /** | 453 /** |
454 * Obtains the drag handler depeding on the coordinate. | 454 * Obtains the drag handler depending on the coordinate. |
455 * | 455 * |
456 * @param {number} startScreenX X coordinate for cursor in the screen. | 456 * @param {number} startScreenX X coordinate for cursor in the screen. |
457 * @param {number} startScreenY Y coordinate for cursor in the screen. | 457 * @param {number} startScreenY Y coordinate for cursor in the screen. |
458 * @param {boolean} touch Whether the operaiton is done by touch or not. | 458 * @param {boolean} touch Whether the operation is done by touch or not. |
459 * @return {function(number,number,boolean)} Drag handler that takes x | 459 * @return {function(number,number,boolean)} Drag handler that takes x |
460 * coordinate value, y coordinate value, and shift key flag. | 460 * coordinate value, y coordinate value, and shift key flag. |
461 */ | 461 */ |
462 DraggableRect.prototype.getDragHandler = function( | 462 DraggableRect.prototype.getDragHandler = function( |
463 initialScreenX, initialScreenY, touch) { | 463 initialScreenX, initialScreenY, touch) { |
464 // Check if the initial coordinate in the clip rect. | 464 // Check if the initial coordinate in the clip rect. |
465 var initialX = this.viewport_.screenToImageX(initialScreenX); | 465 var initialX = this.viewport_.screenToImageX(initialScreenX); |
466 var initialY = this.viewport_.screenToImageY(initialScreenY); | 466 var initialY = this.viewport_.screenToImageY(initialScreenY); |
467 var initialWidth = this.bounds_.right - this.bounds_.left; | 467 var initialWidth = this.bounds_.right - this.bounds_.left; |
468 var initialHeight = this.bounds_.bottom - this.bounds_.top; | 468 var initialHeight = this.bounds_.bottom - this.bounds_.top; |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
643 break; | 643 break; |
644 case 'bottom': | 644 case 'bottom': |
645 this.bounds_.bottom = this.bounds_.top + newHeight; | 645 this.bounds_.bottom = this.bounds_.top + newHeight; |
646 break; | 646 break; |
647 case 'none': | 647 case 'none': |
648 this.bounds_.top = middle - newHeight / 2; | 648 this.bounds_.top = middle - newHeight / 2; |
649 this.bounds_.bottom = middle + newHeight / 2; | 649 this.bounds_.bottom = middle + newHeight / 2; |
650 break; | 650 break; |
651 } | 651 } |
652 }; | 652 }; |
OLD | NEW |