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 505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
516 var maxY = clipRect.top + clipRect.height; | 516 var maxY = clipRect.top + clipRect.height; |
517 | 517 |
518 // Returns a handler. | 518 // Returns a handler. |
519 return function(newScreenX, newScreenY, shiftKey) { | 519 return function(newScreenX, newScreenY, shiftKey) { |
520 var newX = this.viewport_.screenToImageX(newScreenX); | 520 var newX = this.viewport_.screenToImageX(newScreenX); |
521 var newY = this.viewport_.screenToImageY(newScreenY); | 521 var newY = this.viewport_.screenToImageY(newScreenY); |
522 | 522 |
523 // Check new crop. | 523 // Check new crop. |
524 if (this.dragMode_.newcrop) { | 524 if (this.dragMode_.newcrop) { |
525 this.dragMode_.newcrop = false; | 525 this.dragMode_.newcrop = false; |
526 this.bounds_.left = this.bounds_.right = newX; | 526 this.bounds_.left = this.bounds_.right = initialX; |
527 this.bounds_.top = this.bounds_.bottom = newY; | 527 this.bounds_.top = this.bounds_.bottom = initialY; |
528 mouseBiasX = 0; | 528 mouseBiasX = 0; |
529 mouseBiasY = 0; | 529 mouseBiasY = 0; |
530 } | 530 } |
531 | 531 |
532 // Update X coordinate. | 532 // Update X coordinate. |
533 if (this.dragMode_.xSide !== DraggableRect.NONE) { | 533 if (this.dragMode_.xSide !== DraggableRect.NONE) { |
534 this.bounds_[this.dragMode_.xSide] = | 534 this.bounds_[this.dragMode_.xSide] = |
535 ImageUtil.clamp(clipRect.left, newX + mouseBiasX, maxX); | 535 ImageUtil.clamp(clipRect.left, newX + mouseBiasX, maxX); |
536 if (this.bounds_.left > this.bounds_.right) { | 536 if (this.bounds_.left > this.bounds_.right) { |
537 var left = this.bounds_.left; | 537 var left = this.bounds_.left; |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
663 break; | 663 break; |
664 case 'bottom': | 664 case 'bottom': |
665 this.bounds_.bottom = this.bounds_.top + newHeight; | 665 this.bounds_.bottom = this.bounds_.top + newHeight; |
666 break; | 666 break; |
667 case 'none': | 667 case 'none': |
668 this.bounds_.top = middle - newHeight / 2; | 668 this.bounds_.top = middle - newHeight / 2; |
669 this.bounds_.bottom = middle + newHeight / 2; | 669 this.bounds_.bottom = middle + newHeight / 2; |
670 break; | 670 break; |
671 } | 671 } |
672 }; | 672 }; |
OLD | NEW |