Skip to content

Commit d60f7cc

Browse files
committed
add advanced usage
1 parent 83e95e2 commit d60f7cc

File tree

4 files changed

+55
-7
lines changed

4 files changed

+55
-7
lines changed

documentation/docs/usage/advanced.md

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,48 @@
22
sidebar_position: 2
33
---
44

5-
# Advanced
5+
# Advanced Usage
6+
7+
There are a few ways to change how the scroll progress of an element is calculated.
8+
9+
## Setting Scroll Top Values
10+
11+
You can set `startScroll` and `startScroll` representing the `scrollTop` values to animate between.
12+
13+
```ts
14+
const props = { startScroll: 0, endScroll: 1000 };
15+
16+
controller.createElement({
17+
elOuter: document.getElementById('outer'),
18+
elInner: document.getElementById('inner'),
19+
props,
20+
});
21+
```
22+
23+
## Using a Target Element
24+
25+
A different element can also be used to track scroll progress. Assign a `targetElement` when creating a new parallax element.
26+
27+
```ts
28+
const props = { targetElement: document.getElementById('target') };
29+
30+
controller.createElement({
31+
elOuter: document.getElementById('outer'),
32+
elInner: document.getElementById('inner'),
33+
props,
34+
});
35+
```
36+
37+
## Increase Scroll Bounds
38+
39+
You can add a `rootMargin` that will adjust the bounds that determine when an element is in view.
40+
41+
```ts
42+
const props = { rootMargin: { top: 100, right: 100, bottom: 100, left: 100 } };
43+
44+
controller.createElement({
45+
elOuter: document.getElementById('outer'),
46+
elInner: document.getElementById('inner'),
47+
props,
48+
});
49+
```

documentation/docs/usage/basic-usage.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Create the parallax controller first:
1010
const controller = ParallaxController.init();
1111
```
1212

13-
Then create an element with animation effects as props:
13+
Then create an element with [animation effects](./props) as props:
1414

1515
```ts
1616
controller.createElement({

documentation/docs/usage/props.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
---
2+
sidebar_position: 3
3+
---
4+
15
# Props
26

37
All available options for scroll effect animation configurations of a parallax element are defined in the `props` option.

documentation/src/css/custom.css

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66

77
/* You can override the default Infima variables here. */
88
:root {
9-
--ifm-color-primary: #4d58f1;
10-
--ifm-color-primary-dark: #404ada;
11-
--ifm-color-primary-darker: #363fbe;
9+
--ifm-color-primary: #6c75fa;
10+
--ifm-color-primary-dark: #5f68e9;
11+
--ifm-color-primary-darker: #414aca;
1212
--ifm-color-primary-darkest: #2d338a;
13-
--ifm-color-primary-light: #5b66f5;
14-
--ifm-color-primary-lighter: #717af1;
13+
--ifm-color-primary-light: #737cf8;
14+
--ifm-color-primary-lighter: #8b92f7;
1515
--ifm-color-primary-lightest: #969df5;
1616
--ifm-code-font-size: 95%;
1717
}

0 commit comments

Comments
 (0)