Update asynchronous example
Browse files
readme.md
CHANGED
@@ -150,7 +150,7 @@ You can also hide the buttons and control the introductions programmatically by
|
|
150 |
|
151 |
### Asynchronous Actions – [Demo](http://kamranahmed.info/driver)
|
152 |
|
153 |
-
|
154 |
|
155 |
```javascript
|
156 |
const driver = new Driver();
|
@@ -173,13 +173,14 @@ driver.defineSteps([
|
|
173 |
position: 'top'
|
174 |
},
|
175 |
onNext: () => {
|
176 |
-
//
|
177 |
driver.preventMove();
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
|
|
183 |
}
|
184 |
},
|
185 |
{
|
|
|
150 |
|
151 |
### Asynchronous Actions – [Demo](http://kamranahmed.info/driver)
|
152 |
|
153 |
+
For any asynchronous actions between the transition steps, you may delay the execution till the action completes. All you have to do is stop the transition using `driver.preventMove()` in your `onNext` or `onPrevious` callbacks and initiate it manually using `driver.moveNext()`. Here is a sample implementation where it will stop at the second step for four seconds and then move on to the next step.
|
154 |
|
155 |
```javascript
|
156 |
const driver = new Driver();
|
|
|
173 |
position: 'top'
|
174 |
},
|
175 |
onNext: () => {
|
176 |
+
// Prevent moving to the next step
|
177 |
driver.preventMove();
|
178 |
+
|
179 |
+
// Perform some action or create the element to move to
|
180 |
+
// And then move to that element
|
181 |
+
setTimeout(() => {
|
182 |
+
driver.moveNext();
|
183 |
+
}, 4000);
|
184 |
}
|
185 |
},
|
186 |
{
|