Skip to content

Commit 6ca2e7c

Browse files
authored
📝 Update README.md
1 parent b7b17ef commit 6ca2e7c

File tree

1 file changed

+40
-7
lines changed

1 file changed

+40
-7
lines changed

README.md

Lines changed: 40 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ const H = new Highway.Core({
188188
});
189189
```
190190

191-
Last but not least, you might want to use the same transition for all the pages across your website. This is possible by adding a `default` key to your transitions list. When you do so for each page **Highway** will look for a transition in the list related to your `router-view` name and fallback to the `default` one if none is found.
191+
Finally you might want to use the same transition for all the pages across your website. This is possible by adding a `default` key to your transitions list. When you do so for each page **Highway** will look for a transition in the list related to your `router-view` name and fallback to the `default` one if none is found.
192192

193193
```javascript
194194
// [...]
@@ -204,13 +204,46 @@ const H = new Highway.Core({
204204

205205
Check out the [**examples**](https://github.com/Dogstudio/highway#examples) for more details about transitions in **Highway**.
206206

207+
## Events
208+
209+
Last but not least, **Highway** extends [**tiny-emitter**](https://github.com/scottcorgan/tiny-emitter) to send events along the navigation process you can listen to in order to extend its capabilities. There are three events available for you:
210+
211+
- `NAVIGATE_START`: Trigger when a navigation starts.
212+
- `NAVIGATE_END`: Trigger when a navigation ends.
213+
- `NAVIGATE_ERROR`: Trigger when a error occurs in navigation process.
214+
215+
For the `NAVIGATE_START` and `NAVIGATE_END` events, some parameters are sent with the event in this order:
216+
217+
- `from`: The `router-view` from the page you come from.
218+
- `to`: The `router-view` from the page you go to.
219+
- `title`: The document title of the page you go to.
220+
- `state`: The state of **Highway** that contains all the informations about the URL of the page you go to.
221+
222+
```javascript
223+
// [...]
224+
H.on('NAVIGATE_START', (from, to, title, state) => {
225+
// [...]
226+
});
227+
228+
H.on('NAVIGATE_END', (from, to, title, state) => {
229+
// [...]
230+
});
231+
232+
H.on('NAVIGATE_ERROR', () => {
233+
// [...]
234+
});
235+
// [...]
236+
```
237+
238+
Check out the [**Basic Menu Active**](https://github.com/Dogstudio/highway/tree/master/examples/basic-menu-active) example for more details about events handling in **Highway**.
239+
207240
## Examples
208241

209-
- [Basic Setup](https://github.com/Dogstudio/highway/tree/master/examples/basic-setup)
210-
- [Basic Transition](https://github.com/Dogstudio/highway/tree/master/examples/basic-transition)
211-
- [Basic CSS Transition](https://github.com/Dogstudio/highway/tree/master/examples/basic-css-transition)
212-
- [Basic Menu Active](https://github.com/Dogstudio/highway/tree/master/examples/basic-menu-active)
213-
- [Basic Google Analytics Events](https://github.com/Dogstudio/highway/tree/master/examples/basic-google-analytics)
242+
- [**Basic Setup**](https://github.com/Dogstudio/highway/tree/master/examples/basic-setup)
243+
- [**Basic Transition**](https://github.com/Dogstudio/highway/tree/master/examples/basic-transition)
244+
- [**Basic CSS Transition**](https://github.com/Dogstudio/highway/tree/master/examples/basic-css-transition)
245+
- [**Basic Menu Active**](https://github.com/Dogstudio/highway/tree/master/examples/basic-menu-active)
246+
- [**Basic Google Analytics Events**](https://github.com/Dogstudio/highway/tree/master/examples/basic-google-analytics)
214247

215248
## Roadmap
216249

@@ -221,4 +254,4 @@ Check out the [**examples**](https://github.com/Dogstudio/highway#examples) for
221254

222255
## License
223256

224-
See the [LICENSE](https://github.com/Dogstudio/highway/blob/master/LICENSE) file for license rights and limitations (MIT).
257+
See the [**LICENSE**](https://github.com/Dogstudio/highway/blob/master/LICENSE) file for license rights and limitations (MIT).

0 commit comments

Comments
 (0)