Skip to content
This repository was archived by the owner on May 21, 2025. It is now read-only.

Commit b4c109d

Browse files
authored
docs: update element and animation options
1 parent 362595b commit b4c109d

File tree

1 file changed

+18
-15
lines changed

1 file changed

+18
-15
lines changed

README.md

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,19 @@ Add static CSS to each element, for example:
177177
}
178178
```
179179

180+
#### `onUpdate: (driverValues: Object, domElement: DomElement) => void`
181+
A method called every frame with the current driverValues and domElement. This could be used to toggle classes on an element or set innerHTML. See it in action [here](https://alexfox.dev/lax.js/examples/on-update).
182+
183+
The driver values are formatted as follows:
184+
```js
185+
{
186+
scrollY: [ // Driver name
187+
100, // Driver value
188+
0 // Driver inertia
189+
]
190+
}
191+
```
192+
180193
# Going deeper
181194

182195
## Custom animations
@@ -206,7 +219,7 @@ The name of the driver you want to use as a source of values to map to your anim
206219
### CSS property
207220
The name of the CSS property you want to animate, for example `opacity` or `rotate`. See a list of supported properties [here](#css-properties).
208221

209-
> Some css properties, for example `box-shadow`, require a custom function to build the style string. To do this use the [cssFn](#cssfn-value-number--string) element option.
222+
> Some CSS properties, for example `box-shadow`, require a custom function to build the style string. To do this use the [cssFn](#cssfn-value-number--string) element option.
210223
211224
### Value maps
212225
The value maps are used to interpolate the driver value and output a value for your CSS property. For example:
@@ -270,20 +283,7 @@ Use in combination with `inertia`. If set to `absolute` the inertia value will a
270283
Define the unit to be appended to the end of the value, for example
271284
For example `px` `deg`
272285

273-
#### `onUpdate: (driverValues: Object, domElement: DomElement) => void`
274-
A method called every frame with the current driverValues and domElement. This could be used to toggle classes on an element or set innerHTML. See it in action [here](https://alexfox.dev/lax.js/examples/on-update).
275-
276-
The driver values are formatted as follows:
277-
```js
278-
{
279-
scrollY: [ // Drivr name
280-
100, // Driver value
281-
0 // Driver inertia
282-
]
283-
}
284-
```
285-
286-
#### `cssFn: (value: number) => string`
286+
#### `cssFn: (value: number, domElement: DomElement) => number | string`
287287
Some CSS properties require more complex strings as values. For example, `box-shadow` has multiple values that could be modified by a lax animation.
288288

289289
```javascript
@@ -293,6 +293,9 @@ Some CSS properties require more complex strings as values. For example, `box-sh
293293
};
294294
```
295295

296+
#### `easing: string`
297+
See a list of available values [here](#supported-easings).
298+
296299
## Optimising performance
297300
Lax.js has been designed to be performant but there are a few things to bare in mind when creating your websites.
298301
- Smaller elements perform better.

0 commit comments

Comments
 (0)