Skip to content

Commit

Permalink
fix: reset element styles on mousedown if there was a previous uncanc…
Browse files Browse the repository at this point in the history
…elled resize
  • Loading branch information
Matt Lewis committed Jun 6, 2016
1 parent 053fb0e commit a8e5cd3
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions src/resizable.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,21 @@ export class Resizable implements OnInit {
}
});

const resetElementStyles = () => {
for (let key in currentResize.originalStyles) {
const value: string = currentResize.originalStyles[key];
if (typeof value !== 'undefined') {
this.renderer.setElementStyle(this.elm.nativeElement, key, currentResize.originalStyles[key]);
}
}
};

this.mousedown.subscribe(({mouseX, mouseY}) => {
const resizeEdges: Edges = this.getResizeEdges({mouseX, mouseY});
if (Object.keys(resizeEdges).length > 0) {
if (currentResize) {
resetElementStyles();
}
const startingRect: BoundingRectangle = this.elm.nativeElement.getBoundingClientRect();
currentResize = {
startCoords: {
Expand Down Expand Up @@ -166,12 +178,7 @@ export class Resizable implements OnInit {
mouseY - currentResize.startCoords.mouseY
)
});
for (let key in currentResize.originalStyles) {
const value: string = currentResize.originalStyles[key];
if (typeof value !== 'undefined') {
this.renderer.setElementStyle(this.elm.nativeElement, key, currentResize.originalStyles[key]);
}
}
resetElementStyles();
currentResize = null;
}
});
Expand Down

0 comments on commit a8e5cd3

Please sign in to comment.