Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ let rightPressed = false;
let leftPressed = false;
```

The default value for both is `false` because at the beginning the control buttons are not pressed. To listen for key presses, we will set up two event listeners. Add the following lines just above the `setInterval()` line at the bottom of your JavaScript:
The default value for both is `false` because at the beginning the control buttons are not pressed. To listen for key presses, we will set up two event listeners. Add the following lines just above the `drawBall` function definition:

```js
document.addEventListener("keydown", keyDownHandler);
Expand Down
2 changes: 2 additions & 0 deletions files/en-us/web/api/navigation/transition/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ browser-compat: api.Navigation.transition

The **`transition`** read-only property of the {{domxref("Navigation")}} interface returns a {{domxref("NavigationTransition")}} object representing the status of an in-progress navigation, which can be used to track it.

`Navigation.transition` is only populated while the [`intercept()`](/en-US/docs/Web/API/NavigateEvent/intercept) handler is unresolved (i.e., during a [navigation interception](/en-US/docs/Web/API/Navigation/navigate_event#handling_a_navigation_using_intercept)), and is otherwise `null`.

## Value

A {{domxref("NavigationTransition")}} object, or `null` if no navigation is currently in progress.
Expand Down
5 changes: 4 additions & 1 deletion files/en-us/web/api/navigationtransition/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ browser-compat: api.NavigationTransition

{{APIRef("Navigation API")}}

The **`NavigationTransition`** interface of the {{domxref("Navigation API", "Navigation API", "", "nocode")}} represents an ongoing navigation, that is, a navigation that hasn't yet reached the {{domxref("Navigation/navigatesuccess_event", "navigatesuccess")}} or {{domxref("Navigation/navigateerror_event", "navigateerror")}} stage.
The **`NavigationTransition`** interface of the {{domxref("Navigation API", "Navigation API", "", "nocode")}} represents an ongoing navigation a navigation that hasn't yet reached the {{domxref("Navigation/navigatesuccess_event", "navigatesuccess")}} or {{domxref("Navigation/navigateerror_event", "navigateerror")}} stage.

It is accessed via the {{domxref("Navigation.transition")}} property.
Note that this property is only populated while the [`intercept()`](/en-US/docs/Web/API/NavigateEvent/intercept) handler is unresolved (i.e., during a [navigation interception](/en-US/docs/Web/API/Navigation/navigate_event#handling_a_navigation_using_intercept)), and is otherwise `null`.

{{InheritanceDiagram}}

Expand All @@ -21,6 +22,8 @@ It is accessed via the {{domxref("Navigation.transition")}} property.
- : Returns the {{domxref("NavigationHistoryEntry")}} that the transition is coming from.
- {{domxref("NavigationTransition.navigationType", "navigationType")}} {{ReadOnlyInline}}
- : Returns the type of the ongoing navigation.
- {{domxref("NavigationTransition.to", "to")}} {{ReadOnlyInline}} {{Experimental_Inline}}
- : Returns the {{domxref("NavigationDestination")}} that the transition is navigating to.

## Examples

Expand Down
44 changes: 44 additions & 0 deletions files/en-us/web/api/navigationtransition/to/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---
title: "NavigationTransition: to property"
short-title: to
slug: Web/API/NavigationTransition/to
page-type: web-api-instance-property
status:
- experimental
browser-compat: api.NavigationTransition.to
---

{{APIRef("Navigation API")}}{{seecompattable}}

The **`to`** read-only property of the {{domxref("NavigationTransition")}} interface returns the {{domxref("NavigationDestination")}} that the transition is navigating to.

This mirrors the {{domxref("NavigateEvent.destination")}} property but, unlike that, is available outside of the {{domxref("Navigation.navigate_event", "navigate")}} event handler. It is especially useful when calling functions prior to the URL changing (e.g., during precommit or on error).

## Value

A {{domxref("NavigationDestination")}} object.

## Examples

### Handling a navigation error

```js
navigation.onnavigateerror = (e) => {
if (navigation.transition?.to?.url === login_page_url) {
/* do something when failing to go to login page */
}
};
```

## Specifications

{{Specifications}}

## Browser compatibility

{{Compat}}

## See also

- [Modern client-side routing: the Navigation API](https://developer.chrome.com/docs/web-platform/navigation-api/)
- [Navigation API explainer](https://github.com/WICG/navigation-api/blob/main/README.md)
42 changes: 21 additions & 21 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
"cspell-group-by-file-reporter": "^1.0.1",
"env-cmd": "11.0.0",
"fdir": "^6.5.0",
"file-type": "^21.3.4",
"file-type": "^22.0.0",
"fs-extra": "^11.3.4",
"gray-matter": "^4.0.3",
"imagemin": "^9.0.1",
Expand Down