Skip to content

Commit

Permalink
fix: set ghost element width and height on resize start
Browse files Browse the repository at this point in the history
Fixes #53
  • Loading branch information
Matt Lewis committed May 21, 2017
1 parent da46f7b commit be5d727
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/resizable.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ function getNewBoundingRectangle(startingRect: BoundingRectangle, edges: Edges,
function getElementRect(element: ElementRef, ghostElementPositioning: string): BoundingRectangle {
if (ghostElementPositioning === 'absolute') {
return {
height: element.nativeElement.offsetHeight,
width: element.nativeElement.offsetWidth,
top: element.nativeElement.offsetTop,
bottom: element.nativeElement.offsetHeight + element.nativeElement.offsetTop,
left: element.nativeElement.offsetLeft,
Expand All @@ -84,6 +86,8 @@ function getElementRect(element: ElementRef, ghostElementPositioning: string): B
} else {
const boundingRect: BoundingRectangle = element.nativeElement.getBoundingClientRect();
return {
height: boundingRect.height,
width: boundingRect.width,
top: boundingRect.top,
bottom: boundingRect.bottom,
left: boundingRect.left,
Expand Down
13 changes: 13 additions & 0 deletions test/resizable.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,19 @@ describe('resizable directive', () => {

});

it('should set the cloned elements width and height on the resize start', () => {

const fixture: ComponentFixture<TestCmp> = createComponent();
const elm: HTMLElement = fixture.componentInstance.resizable.elm.nativeElement;
triggerDomEvent('mousedown', elm, {
clientX: 100,
clientY: 200
});
expect(elm.nextSibling['style'].width).to.equal('300px');
expect(elm.nextSibling['style'].height).to.equal('150px');

});

it('should reset existing styles after a resize', () => {

const fixture: ComponentFixture<TestCmp> = createComponent();
Expand Down

0 comments on commit be5d727

Please sign in to comment.