Last updated: First published:
The Cam-Shaft
PREREQUISITE
What is it?
This tools is intended to avoid the pseudo-smooth-scroll effect.
See the interactive demo of the effect and the interactive demo of the solution using the cam-shaft.
Installation
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.
- Install
@vtbag/cam-shaft@latest
from npm. - In your project, add
@vtbag/cam-shaft/index.js
as an inline script at the beginning of the<head>
element on all pages of your site.
Details depend on your project setup and the frameworks used, but it can be as simple as:
You can load the script from CDNs such as jsdelivr.net or unpkg.com. Place the script inline at the beginning of the <head>
element on all pages where you need avoid pseudo-smooth-scrolling.
Using jsdeliver.net
:
or alternatively using unpkg.com
:
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)
:
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.