### Install Swup Documentation Locally
Source: https://github.com/swup/docs/blob/main/README.md
Clone the repository, navigate to the directory, and install dependencies using npm.
```sh
git clone git@github.com:swup/docs.git
cd ./docs
npm install
```
--------------------------------
### Install Swup with npm
Source: https://github.com/swup/docs/blob/main/src/docs/getting-started/installation.md
Use this command to install Swup via npm if you are using a bundler in your project.
```shell
npm install swup
```
--------------------------------
### Initialize Swup with a Bundler
Source: https://github.com/swup/docs/blob/main/src/docs/getting-started/installation.md
After installing Swup with a bundler, import it and create a new instance in your application.
```javascript
import Swup from 'swup';
const swup = new Swup();
```
--------------------------------
### Basic Swup Animation Demo
Source: https://github.com/swup/docs/blob/main/src/docs/getting-started/demos.md
Demonstrates default swup installation with two containers and a fade animation between pages.
```html
https://swup-demos.onrender.com/basic/
Swup Demo: Basic
```
--------------------------------
### Complete Basic Swup Setup
Source: https://github.com/swup/docs/blob/main/src/docs/getting-started/example.md
Combines HTML structure, CSS transitions, and swup initialization for a functional fade animation.
```html
Welcome
Lorem ipsum dolor sit amet.
```
--------------------------------
### Include Swup from CDN and Initialize
Source: https://github.com/swup/docs/blob/main/src/docs/getting-started/installation.md
For quick setup without a bundler, include the minified production file from a CDN and initialize Swup in your main script.
```html
```
--------------------------------
### Install Scroll Plugin via npm
Source: https://github.com/swup/docs/blob/main/src/docs/plugins/plugins.md
Install the scroll plugin using npm. This is the first step before importing and enabling it.
```shell
npm install @swup/scroll-plugin
```
--------------------------------
### Install Latest swup Version
Source: https://github.com/swup/docs/blob/main/src/docs/getting-started/upgrading.md
Install the latest version of swup using npm. This command updates swup to the most recent release.
```shell
npm install swup@latest
```
--------------------------------
### delegateEvent
Source: https://github.com/swup/docs/blob/main/src/docs/api/helpers.md
Install a delegated event listener on the document using [delegate-it](https://github.com/fregante/delegate-it).
```APIDOC
## delegateEvent
### Description
Install a delegated event listener on the document using [delegate-it](https://github.com/fregante/delegate-it).
### Parameters
- **selector** (string) - The selector for the elements to delegate events on.
- **event** (string) - The event to listen for.
- **handler** (function) - The event handler function.
### Returns
An object with a `destroy` method to stop listening for events.
### Example
```javascript
const delegation = delegateEvent('form', 'submit', (event) => {
console.log('Form submitted');
});
// To stop listening for events:
delegation.destroy();
```
```
--------------------------------
### Visit object structure example
Source: https://github.com/swup/docs/blob/main/src/docs/lifecycle/visit.md
An example of the visit object's structure, detailing properties like `id`, `from`, `to`, `containers`, `animation`, `trigger`, `cache`, `history`, and `scroll`. This object is available in all hook handlers.
```javascript
{
id: 1042739, /* A unique ID to identify this visit */
from: {
url: '/home',
hash: ''
},
to: {
url: '/about',
hash: '#anchor',
html: undefined, /* The HTML string of /about, when it's loaded */,
document: undefined /* The parsed document of /about, when it's loaded */,
},
containers: [
'#swup'
],
animation: {
animate: true,
name: 'fade'
},
trigger: {
el: /*