@@ -15,6 +15,8 @@ export class CanvasView extends PolymerElement {
15
15
_dropTarget : Element ;
16
16
_initialWidth : number ;
17
17
_initialHeight : number ;
18
+ _downX : number ;
19
+ _downY : number ;
18
20
19
21
static get template ( ) {
20
22
return html `
@@ -105,6 +107,7 @@ export class CanvasView extends PolymerElement {
105
107
connectedCallback ( ) {
106
108
super . connectedCallback ( ) ;
107
109
110
+ addListener ( this . $ . canvas , 'down' , this . downOnElement . bind ( this ) ) ;
108
111
addListener ( this . $ . canvas , 'track' , this . trackElement . bind ( this ) ) ;
109
112
this . addEventListener ( 'click' , event => {
110
113
this . updateActiveElement ( this ) ;
@@ -155,6 +158,12 @@ export class CanvasView extends PolymerElement {
155
158
//Base.fire('refresh-view', {}, {node: this});
156
159
}
157
160
161
+ downOnElement ( event ) {
162
+ // STore initial Mouse Pos for checking if resizeing
163
+ this . _downX = event . detail . x ;
164
+ this . _downY = event . detail . y ;
165
+ }
166
+
158
167
trackElement ( event ) {
159
168
let el = event . target ;
160
169
this . _justFinishedDraggingOrDropping = false ;
@@ -168,7 +177,7 @@ export class CanvasView extends PolymerElement {
168
177
}
169
178
170
179
let rekt = el . getBoundingClientRect ( ) ;
171
- let shouldResize = this . dragShouldSize ( event , rekt ) ;
180
+ let shouldResize = this . dragShouldSize ( rekt ) ;
172
181
if ( shouldResize ) {
173
182
this . _resizing = true ;
174
183
this . _initialWidth = rekt . width ;
@@ -344,9 +353,9 @@ export class CanvasView extends PolymerElement {
344
353
this . updateActiveElement ( el ) ;
345
354
}
346
355
347
- dragShouldSize ( event , rect ) {
348
- const right = Math . abs ( rect . right - event . detail . x ) ;
349
- const bottom = Math . abs ( rect . bottom - event . detail . y ) ;
356
+ dragShouldSize ( rect ) {
357
+ const right = rect . right - this . _downX ;
358
+ const bottom = rect . bottom - this . _downY ;
350
359
return ( right < 8 && bottom < 8 ) ;
351
360
}
352
361
0 commit comments