Skip to content

Commit 5733449

Browse files
committed
walkthrough flow parameters can be changed dynamically
1 parent 8c68f59 commit 5733449

File tree

3 files changed

+45
-4
lines changed

3 files changed

+45
-4
lines changed

projects/angular-walkthrough/src/lib/walkthrough-flow.component.ts

+16-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
import { AfterViewInit, Component, ContentChildren, EventEmitter, Input, Output, QueryList } from '@angular/core';
1+
import {
2+
AfterViewInit, Component, ContentChildren, EventEmitter, Input, Output, QueryList, OnChanges, SimpleChanges
3+
} from '@angular/core';
24

35
import { WalkthroughTextI } from './walkthrough-text';
46
import { booleanValue, WalkthroughEvent } from './walkthrough-tools';
@@ -10,7 +12,7 @@ let nextUniqueId = 0;
1012
selector: 'ng-walkthrough-flow',
1113
template: '',
1214
})
13-
export class WalkthroughFlowComponent implements AfterViewInit {
15+
export class WalkthroughFlowComponent implements AfterViewInit, OnChanges {
1416
@ContentChildren(WalkthroughComponent) walkthroughComponents: QueryList<WalkthroughComponent>;
1517

1618
@Input()
@@ -55,6 +57,18 @@ export class WalkthroughFlowComponent implements AfterViewInit {
5557
});
5658
}
5759

60+
ngOnChanges(changes: SimpleChanges) {
61+
if (this.walkthroughComponents && changes) {
62+
for (const option in changes) {
63+
if (changes[option] && option !== 'id') {
64+
this.walkthroughComponents.forEach((walkthrough: WalkthroughComponent) => {
65+
walkthrough[option] = changes[option].currentValue;
66+
});
67+
}
68+
}
69+
}
70+
}
71+
5872
init() {
5973
let prevComp: WalkthroughComponent = null;
6074
this.walkthroughComponents.forEach((walkthrough: WalkthroughComponent) => {

src/app/app.component.html

+25-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,29 @@
1414
<button (click)="continue()">Continue walkthrough</button>
1515
</div>
1616
</div>
17+
<div>
18+
flow options :<br />
19+
<label>
20+
<input
21+
type="checkbox"
22+
#flowCloseAnywhereValue
23+
[checked]="flowCloseAnywhere"
24+
(change)="flowCloseAnywhere = flowCloseAnywhereValue.checked"
25+
/>
26+
CloseAnywhere {{flowCloseAnywhere}}
27+
</label><br />
28+
<label>
29+
<input
30+
type="checkbox"
31+
#flowHidePreviousValue
32+
[checked]="flowHidePrevious"
33+
(change)="flowHidePrevious = flowHidePreviousValue.checked"
34+
/>
35+
HidePrevious {{flowHidePrevious}}
36+
</label>
37+
38+
</div>
39+
1740
<div class="overflow">
1841
<div></div>
1942
<div>
@@ -329,7 +352,8 @@
329352
focusBackdrop="true"
330353
focusHighlightAnimation="true"
331354
closeButton="true"
332-
closeAnywhere="false"
355+
[closeAnywhere]="flowCloseAnywhere"
356+
[hidePrevious]="flowHidePrevious"
333357
arrowColor="#000"
334358
showArrow="true"
335359
radius="auto"

src/app/app.component.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export class AppComponent implements OnInit, OnDestroy {
2323
};
2424

2525
testClickCount = 0;
26-
testClickTexts = ['click me', "it's ok!", 'realy ok', 'ok ok...', 'stop that!'];
26+
testClickTexts = ['click me', 'it\'s ok!', 'realy ok', 'ok ok...', 'stop that!'];
2727
testPosition = 'center';
2828
alignContent = 'left';
2929
verticalAlignContent = 'top';
@@ -40,6 +40,9 @@ export class AppComponent implements OnInit, OnDestroy {
4040
step3flowDisabled = false;
4141
step4flowDisabled = false;
4242

43+
flowHidePrevious = false;
44+
flowCloseAnywhere = false;
45+
4346
hideCount = 3;
4447
private _count = 3;
4548
private _start = false;

0 commit comments

Comments
 (0)