Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/vtbag/website. The @vtbag website. ⭐️ Please star to support this work! ⭐️
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374---title: The Cam-Shaftdescription: "Bump your view transition images into position to avoid that unexpected pseudo-smooth-scrolling."head: - tag: meta attrs: property: "og:image" content: "/shaft-og.png"---import { Steps } from "@astrojs/starlight/components";import Logo from "../../../components/Logo.astro";import CTA from "../../../components/CTA.astro";import shaft from "../../../assets/shaft.png";
<Logo alt="The Cam-Shaft" image={shaft}>Bump your view transition images into position to avoid that unexpected pseudo-smooth-scrolling.
The Cam-Shaft is about an issue we already resolved for Astro's ViewTransitions (see [here](https://events-3bg.pages.dev/jotter/starlight/inner-workings/transitions/#the-pseudo-scrolling-main-area) and [here](https://events-3bg.pages.dev/library/PageOffset/)), but it still requires support for browser-native cross-document view transitions.
</Logo><CTA>[Instant Scrolling!](/shaft-demo2/1/)</CTA>
## PREREQUISITE
:::tip[View Transition API]The Camshaft is designed to address an issue with browser-native cross-document view transitions. In browsers that haven't implemented the API yet, it simply does nothing, as there's no problem to solve.:::
## What is it?
This tools is intended to avoid the [pseudo-smooth-scroll effect](/tips/pseudo-smooth-scrolling/).
See the [interactive demo of the effect](/shaft-demo/1/) and the [interactive demo of the solution using the cam-shaft](/shaft-demo2/1/).
## Installation:::tipIf you want to use the Cam-Shaft with an Astro project, see [astro-vtbot](https://events-3bg.pages.dev/library/CamShaft/) for reusable components you can easily use in your project.:::
To use the Cam-Shaft, you can install the npm package in your project. Alternatively you can load the script from one of the global content delivery networks that provide npm packages.
<Steps>1. Install `@vtbag/cam-shaft from npm2. In your project, add `@vtbag/cam-shaft/index.js` as an external script at the beginning of the `<head>` element on all pages of your site.</Steps>
Details depend on your project setup and the frameworks used, but with a bundler like `vite` it can be as simple as:
```jsximport shaft from "@vtbag/cam-shaft?url";<html> <head> <script src={shaft}></script> ... </head> ...</html>```
## Configuration and Usage
The Cam-Shaft script needs to know which view transition name's images it should bump and nudge. By default, it assumes it should handle `::view-transition-group(main)`.
If you need to target a different view transition name, you can use the `data-view-transition-names` attribute in the script tag. For example, the following will instruct the script to handle images for `::view-transition-group(content)`:
```html<script src=... data-view-transition-names="content"/>```
As you may have guessed from the plural form, you can specify multiple view transition names by separating them with spaces, allowing the script to manage several groups.