Skip to content

Commit

Permalink
Handle animationDelay setting after silent remove from core library
Browse files Browse the repository at this point in the history
  • Loading branch information
jornetsimon committed Nov 5, 2020
1 parent 4d1f541 commit ab3b842
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 6 deletions.
2 changes: 1 addition & 1 deletion projects/ng-rough-notation/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ng-rough-notation",
"version": "1.1.2",
"version": "1.2.0",
"description": "Angular directive wrapper for rough-notation",
"author": "Simon Jornet",
"keywords": [
Expand Down
5 changes: 5 additions & 0 deletions projects/ng-rough-notation/src/lib/rough-annotation-config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { RoughAnnotationConfig as OfficialRoughAnnotationConfig } from 'rough-notation/lib/model';

export interface RoughAnnotationConfig extends OfficialRoughAnnotationConfig {
animationDelay?: number;
}
13 changes: 11 additions & 2 deletions projects/ng-rough-notation/src/lib/rough-notation.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ import {
Output,
Renderer2,
} from '@angular/core';
import { RoughAnnotation, RoughAnnotationConfig } from 'rough-notation/lib/model';
import { RoughAnnotation } from 'rough-notation/lib/model';
import { RoughNotationService } from './rough-notation.service';
import { Subscription } from 'rxjs';
import { RoughAnnotationConfig } from './rough-annotation-config';

@Directive({
selector: '[roughNotation]',
Expand Down Expand Up @@ -74,7 +75,15 @@ export class RoughNotationDirective implements OnInit, OnDestroy {
// Instantiate RoughNotation
this.service.instantiate(this.hostElement.nativeElement);
if (this._show !== false) {
this.setVisibility(true);
const animationDelay = this.service.config.animationDelay;
if (animationDelay) {
// In case an animationDelay is specified
setTimeout(() => {
this.setVisibility(true);
}, animationDelay);
} else {
this.setVisibility(true);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { CommonModule } from '@angular/common';
import { RoughNotationDirective } from './rough-notation.directive';
import { RoughNotationService } from './rough-notation.service';
import { defaultConfig } from './utility';
import { RoughAnnotationConfig } from 'rough-notation/lib/model';
import { RoughNotationGroupComponent } from './rough-notation-group/rough-notation-group.component';
import { RoughAnnotationConfig } from './rough-annotation-config';

@NgModule({
declarations: [RoughNotationDirective, RoughNotationGroupComponent],
Expand Down
3 changes: 2 additions & 1 deletion projects/ng-rough-notation/src/lib/rough-notation.service.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { Inject, Injectable } from '@angular/core';
import { RoughAnnotation, RoughAnnotationConfig } from 'rough-notation/lib/model';
import { RoughAnnotation } from 'rough-notation/lib/model';
import { annotate } from 'rough-notation';
import { Observable, Subject } from 'rxjs';
import { filter, scan, tap } from 'rxjs/operators';
import { getDefaultTypeColor } from './utility';
import { RoughAnnotationConfig } from './rough-annotation-config';

@Injectable()
export class RoughNotationService {
Expand Down
3 changes: 2 additions & 1 deletion projects/ng-rough-notation/src/lib/utility.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { RoughAnnotationConfig, RoughAnnotationType } from 'rough-notation/lib/model';
import { RoughAnnotationType } from 'rough-notation/lib/model';
import { RoughAnnotationConfig } from './rough-annotation-config';

export const defaultColors: Record<RoughAnnotationType, string> = {
highlight: '#FFF176',
Expand Down

0 comments on commit ab3b842

Please sign in to comment.