NetanelBasal
11/12/2016 - 7:32 PM

shave2.ts

import shave, { IShaveOptions } from "shave";

@Directive({
  selector: "[shave]"
})
export class ShaveDirective {
  private _shaveOptions : IShaveOptions = {};
  private _maxHeight = 100;

  @Input()
  set shave( val ) {
    if( val ) {
      this._shaveOptions = val;
    }
    this._runShave();
  }

  @Input()
  set shaveMaxHeight( val ) {
    if( val ) {
      this._maxHeight = val;
    }
    this._runShave();
  }

  constructor( private ele : ElementRef ) {
  }

  private _runShave() {
    shave(this.ele.nativeElement, this._maxHeight, this._shaveOptions);
  }
}