File tree 3 files changed +27
-3
lines changed
tests/integration/components
3 files changed +27
-3
lines changed Original file line number Diff line number Diff line change @@ -123,12 +123,18 @@ Called after `on-change` when the user moves a step (backwards or
123
123
forward) in the introduction. Gives the current step, the introJS
124
124
component isntance, and the element of the current step.
125
125
126
- ### on-exit (step, introJSComponent)
126
+ ### on-before- exit (step, introJSComponent)
127
127
128
128
Called when the user quits the intro via the "Skip" button, hitting
129
129
` escape ` , or clicking outside the overlay. Given the current step, and
130
130
the introJS component.
131
131
132
+ ### on-exit (step, introJSComponent)
133
+
134
+ Called after ` on-before-exit ` when the user quits the intro via the "Skip" button, hitting
135
+ ` escape ` , or clicking outside the overlay. Given the current step, and
136
+ the introJS component.
137
+
132
138
### on-complete (step, introJSComponent)
133
139
134
140
Called when the user finishes the intro by clicking "Done" or hitting
Original file line number Diff line number Diff line change @@ -144,6 +144,7 @@ export default Component.extend({
144
144
intro . oncomplete ( bind ( this , this . _onComplete ) ) ;
145
145
intro . onexit ( bind ( this , this . _onExit ) ) ;
146
146
intro . onskip ( bind ( this , this . _onSkip ) ) ;
147
+ intro . onbeforeexit ( bind ( this , this . _onBeforeExit ) ) ;
147
148
} ,
148
149
149
150
_setIntroJS ( introJS ) {
@@ -185,6 +186,10 @@ export default Component.extend({
185
186
this . _sendAction ( 'on-complete' , [ this . get ( 'currentStep' ) ] ) ;
186
187
} ,
187
188
189
+ _onBeforeExit ( ) {
190
+ this . _sendAction ( 'on-before-exit' , [ this . get ( 'currentStep' ) , this ] ) ;
191
+ } ,
192
+
188
193
_setCurrentStep ( step ) {
189
194
this . set ( 'currentStep' , this . _getStep ( step ) ) ;
190
195
} ,
Original file line number Diff line number Diff line change @@ -73,7 +73,20 @@ module('Integration | Component | intro js', function(hooks) {
73
73
} ) ;
74
74
} ) ;
75
75
76
- module ( 'when existing' , function ( ) {
76
+ module ( 'when exiting' , function ( ) {
77
+
78
+ test ( 'fires the on-before-exit action' , async function ( assert ) {
79
+ assert . expect ( 2 ) ;
80
+
81
+ this . set ( 'onBeforeExit' , ( step ) => {
82
+ assert . equal ( step , this . steps [ 0 ] )
83
+ } ) ;
84
+
85
+ await render ( hbs `{{intro-js steps=steps start-if=true on-before-exit=(action onBeforeExit)}}` ) ;
86
+
87
+ await introJSSkip ( ) ;
88
+ } ) ;
89
+
77
90
test ( 'fires the on-exit action' , async function ( assert ) {
78
91
assert . expect ( 3 ) ;
79
92
@@ -84,7 +97,7 @@ module('Integration | Component | intro js', function(hooks) {
84
97
await render ( hbs `{{intro-js steps=steps start-if=true on-exit=(action myExit)}}` ) ;
85
98
86
99
await introJSSkip ( ) ;
87
- } )
100
+ } ) ;
88
101
} ) ;
89
102
90
103
module ( 'when skiping' , function ( ) {
You can’t perform that action at this time.
0 commit comments