Skip to content

Commit

Permalink
made mobile trigger width configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
cribbstechnologies committed Jan 14, 2019
1 parent 3a7e61f commit a3b9fa1
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
6 changes: 5 additions & 1 deletion src/demo/demo.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@
<button (click)="size = size - 10">Decrease size</button>
<button (click)="toggleSide()">Toggle Side</button>

<mgl-timeline [toggle]="toggle" [alternate]="alternate" [focusOnOpen]="false" [side]="side">
<button (click)="mobileWidthThreshold = mobileWidthThreshold + 10">Increase Mobile Threshold</button>
<button (click)="mobileWidthThreshold = mobileWidthThreshold - 10">Decrease Mobile Threshold</button>
Mobile Threshold: {{mobileWidthThreshold}}

<mgl-timeline [toggle]="toggle" [alternate]="alternate" [focusOnOpen]="false" [side]="side" [(mobileWidthThreshold)]="mobileWidthThreshold">
<mgl-timeline-entry *ngFor="let entry of entries; let i = index" (expand)="onExpand($event, i)">
<mgl-timeline-entry-header>
<div>{{entry.header}}</div>
Expand Down
1 change: 1 addition & 0 deletions src/demo/demo.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export class DemoComponent {
color: boolean = false;
size: number = 40;
side: string = 'left';
mobileWidthThreshold: number = 640;

entries = [
{
Expand Down
2 changes: 1 addition & 1 deletion src/demo/demo.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { DemoComponent } from './demo.component';
imports: [
BrowserModule,
BrowserAnimationsModule,
MglTimelineModule
MglTimelineModule,
],
providers: [],
bootstrap: [DemoComponent]
Expand Down
8 changes: 6 additions & 2 deletions src/timeline/timeline/timeline.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ export class MglTimelineComponent implements AfterViewInit, OnChanges, OnDestroy
@Input()
toggle: boolean = true;

@Input()
mobileWidthThreshold: number = 640;

@Input()
alternate: boolean = true;

Expand Down Expand Up @@ -56,7 +59,7 @@ export class MglTimelineComponent implements AfterViewInit, OnChanges, OnDestroy
}

ngAfterViewInit() {
this.mobile = this.elementRef.nativeElement.clientWidth < 640;
this.mobile = this.elementRef.nativeElement.clientWidth < this.mobileWidthThreshold;
setTimeout(() => this.updateContent());
this.content.changes.subscribe(changes => {
this.updateContent();
Expand Down Expand Up @@ -84,6 +87,7 @@ export class MglTimelineComponent implements AfterViewInit, OnChanges, OnDestroy

@HostListener('window:resize', ['$event'])
onResize(ev: KeyboardEvent) {
this.mobile = this.elementRef.nativeElement.clientWidth < 640;
console.log(this.mobileWidthThreshold);

This comment has been minimized.

Copy link
@VictorGaiva

VictorGaiva May 30, 2019

Contributor

Unnecessary console.log(). Please remove

this.mobile = this.elementRef.nativeElement.clientWidth < this.mobileWidthThreshold;
}
}

0 comments on commit a3b9fa1

Please sign in to comment.