Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(483)

Unified Diff: elements/designer-selection/ResizeDirection.js

Issue 877243005: Add designer-selection element (Closed) Base URL: https://github.com/PolymerLabs/designer2.git@master
Patch Set: Address more review comments Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « elements/designer-selection/README.md ('k') | elements/designer-selection/demo.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: elements/designer-selection/ResizeDirection.js
diff --git a/elements/designer-selection/ResizeDirection.js b/elements/designer-selection/ResizeDirection.js
new file mode 100644
index 0000000000000000000000000000000000000000..062fb87272463051f95a574500ffd788b7ce1ccb
--- /dev/null
+++ b/elements/designer-selection/ResizeDirection.js
@@ -0,0 +1,57 @@
+/**
+ * @license
+ * Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
+ * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
+ * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
+ * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
+ * Code distributed by Google as part of the polymer project is also
+ * subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
+ */
+
+function ResizeDirection(name, x, y) {
+ this.name = name;
+ this.x = x;
+ this.y = y;
+}
+
+ResizeDirection.prototype.toString = function() {
+ return 'ResizeDirection(' + this.name + ', ' + this.x + ', ' +
+ this.y + ')';
+};
+
+ResizeDirection.prototype.locate = function(rect) {
+ return {
+ x: rect.left + rect.width * this.x,
+ y: rect.top + rect.height * this.y
+ };
+};
+
+ResizeDirection.prototype.resizesLeft = function() {
+ return this.x == 0.0;
+},
+
+ResizeDirection.prototype.resizesRight = function() {
+ return this.x == 1.0;
+},
+
+ResizeDirection.prototype.resizesTop = function() {
+ return this.y == 0.0;
+},
+
+ResizeDirection.prototype.resizesBottom = function() {
+ return this.y == 1.0;
+},
+
+(function () {
+ var top = ResizeDirection.top = new ResizeDirection('top', 0.5, 0.0);
+ var left = ResizeDirection.left = new ResizeDirection('left', 0.0, 0.5);
+ var bottom = ResizeDirection.bottom = new ResizeDirection('bottom', 0.5, 1.0);
+ var right = ResizeDirection.right = new ResizeDirection('right', 1.0, 0.5);
+ var top_left = ResizeDirection.top_left = new ResizeDirection('top_left', 0.0, 0.0);
+ var top_right = ResizeDirection.top_right = new ResizeDirection('top_right', 1.0, 0.0);
+ var bottom_left = ResizeDirection.bottom_left = new ResizeDirection('bottom_left', 0.0, 1.0);
+ var bottom_right = ResizeDirection.bottom_right = new ResizeDirection('bottom_right', 1.0, 1.0);
+
+ ResizeDirection.all_directions = [top, left, bottom, right, top_left, top_right, bottom_left, bottom_right];
+ ResizeDirection.width_height = [bottom, right, bottom_right];
+})();
« no previous file with comments | « elements/designer-selection/README.md ('k') | elements/designer-selection/demo.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698