Skip to content

Commit

Permalink
feat: add a class to the ghost element
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt Lewis committed May 12, 2017
1 parent 1eb4c18 commit 54be6b7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/resizable.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ const RESIZE_LEFT_HOVER_CLASS: string = 'resize-left-hover';
const RESIZE_RIGHT_HOVER_CLASS: string = 'resize-right-hover';
const RESIZE_TOP_HOVER_CLASS: string = 'resize-top-hover';
const RESIZE_BOTTOM_HOVER_CLASS: string = 'resize-bottom-hover';
const RESIZE_GHOST_ELEMENT_CLASS: string = 'resize-ghost-element';

export const MOUSE_MOVE_THROTTLE_MS: number = 50;

Expand Down Expand Up @@ -487,6 +488,7 @@ export class Resizable implements OnInit, OnDestroy, AfterViewInit {
this.renderer.setStyle(currentResize.clonedNode, 'height', `${currentResize.startingRect.height}px`);
this.renderer.setStyle(currentResize.clonedNode, 'width', `${currentResize.startingRect.width}px`);
this.renderer.setStyle(currentResize.clonedNode, 'cursor', getResizeCursor(currentResize.edges, resizeCursors));
this.renderer.addClass(currentResize.clonedNode, RESIZE_GHOST_ELEMENT_CLASS);
}
this.zone.run(() => {
this.resizeStart.emit({
Expand Down
14 changes: 14 additions & 0 deletions test/resizable.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1100,6 +1100,20 @@ describe('resizable directive', () => {

});

it('should add a class to the ghost element', () => {

const fixture: ComponentFixture<TestCmp> = createComponent();
fixture.detectChanges();
const elm: HTMLElement = fixture.componentInstance.resizable.elm.nativeElement;
triggerDomEvent('mousedown', elm, {
clientX: 100,
clientY: 200
});
expect(elm.classList.contains('resize-ghost-element')).to.be.false;
expect(elm.nextSibling['classList'].contains('resize-ghost-element')).to.be.true;

});

describe('absolute positioning', () => {
let domEvents: Array<any>;
beforeEach(() => {
Expand Down

0 comments on commit 54be6b7

Please sign in to comment.