File tree Expand file tree Collapse file tree 2 files changed +75
-0
lines changed
src/components/example-scale Expand file tree Collapse file tree 2 files changed +75
-0
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ sidebar_position: 2
4
4
5
5
import { ExampleRotation } from ' /src/components/example-rotation' ;
6
6
import { RotationAxis } from ' /src/components/rotation-axis' ;
7
+ import { ExampleScale } from ' /src/components/example-scale' ;
7
8
8
9
# Scroll Effects
9
10
@@ -57,3 +58,38 @@ const Component = () => {
57
58
```
58
59
59
60
<RotationAxis />
61
+
62
+ ## Scale
63
+
64
+ You can [ scale] ( /docs/usage/parallax-props#available-css-effects ) an element up or down and along any axis.
65
+
66
+ ``` tsx
67
+ const Component = () => {
68
+ const mage = useParallax <HTMLDivElement >({
69
+ scale: [0.5 , 1 , ' easeInQuad' ],
70
+ });
71
+
72
+ const frog = useParallax <HTMLDivElement >({
73
+ scaleX: [1 , 0 , ' easeInQuad' ],
74
+ });
75
+
76
+ const moon = useParallax <HTMLDivElement >({
77
+ scale: [1.5 , 1 , ' easeInQuad' ],
78
+ });
79
+ return (
80
+ <div className = " spinner" >
81
+ <div className = " mage" ref = { mage .ref } >
82
+ 🧙🏻♂️
83
+ </div >
84
+ <div className = " frog" ref = { frog .ref } >
85
+ 🐸
86
+ </div >
87
+ <div className = " moon" ref = { moon .ref } >
88
+ 🌚
89
+ </div >
90
+ </div >
91
+ );
92
+ };
93
+ ```
94
+
95
+ <ExampleScale />
Original file line number Diff line number Diff line change
1
+ import React from 'react' ;
2
+ import cx from 'classnames' ;
3
+ import { useParallax } from 'react-scroll-parallax' ;
4
+ import { BgContainer } from '../bg-container' ;
5
+
6
+ const shared =
7
+ 'bg-blue-100 border-2 border-blue-500 border-solid rounded-lg h-32 w-32 flex items-center justify-center' ;
8
+
9
+ export const ExampleScale = ( ) => {
10
+ const parallaxUp = useParallax < HTMLDivElement > ( {
11
+ scale : [ 0.5 , 1 , 'easeInQuad' ] ,
12
+ shouldAlwaysCompleteAnimation : true ,
13
+ } ) ;
14
+
15
+ const parallaxAxisX = useParallax < HTMLDivElement > ( {
16
+ scaleX : [ 1 , 0 , 'easeInQuad' ] ,
17
+ shouldAlwaysCompleteAnimation : true ,
18
+ } ) ;
19
+
20
+ const parallaxDown = useParallax < HTMLDivElement > ( {
21
+ scale : [ 1.5 , 1 , 'easeInQuad' ] ,
22
+ shouldAlwaysCompleteAnimation : true ,
23
+ } ) ;
24
+ return (
25
+ < BgContainer >
26
+ < div className = "flex items-center gap-sm md:gap-2xl justify-center text-8xl" >
27
+ < div className = { cx ( shared ) } ref = { parallaxUp . ref } >
28
+ 🧙🏻♂️
29
+ </ div >
30
+ < div className = { cx ( shared ) } ref = { parallaxAxisX . ref } >
31
+ 🐸
32
+ </ div >
33
+ < div className = { cx ( shared ) } ref = { parallaxDown . ref } >
34
+ 🌚
35
+ </ div >
36
+ </ div >
37
+ </ BgContainer >
38
+ ) ;
39
+ } ;
You can’t perform that action at this time.
0 commit comments