@terrahq/design-system 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -121
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,123 +1,3 @@
|
|
|
1
|
-
# @terrahq/
|
|
1
|
+
# @terrahq/design-system
|
|
2
2
|
|
|
3
|
-
Javascript module for animate elements written in Vanilla js.
|
|
4
|
-
[> examples](https://terra-revealit.netlify.app//)
|
|
5
3
|
|
|
6
|
-
## Usage
|
|
7
|
-
|
|
8
|
-
### Install
|
|
9
|
-
|
|
10
|
-
```sh
|
|
11
|
-
npm install @terrahq/reveal-it
|
|
12
|
-
```
|
|
13
|
-
|
|
14
|
-
### Import
|
|
15
|
-
|
|
16
|
-
```javascript
|
|
17
|
-
import RevealIt from "@terrahq/reveal-it";
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
### Initialize
|
|
21
|
-
### JS
|
|
22
|
-
```javascript
|
|
23
|
-
let example = new RevealIt({
|
|
24
|
-
element: document.querySelector('.js--reveal-it'),
|
|
25
|
-
// Optional: Customize options here
|
|
26
|
-
});
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
### Markup
|
|
30
|
-
|
|
31
|
-
#### Minimum markup
|
|
32
|
-
|
|
33
|
-
```html
|
|
34
|
-
<div class="js--reveal-it">
|
|
35
|
-
<p>
|
|
36
|
-
Lorem ipsum dolor sit amet consectetur adipisicing elit.
|
|
37
|
-
Ea deleniti nisi maxime sequi corporis labore repellat impedit,
|
|
38
|
-
id vel, esse ad, culpa praesentium? Nobis quam fugiat natus,
|
|
39
|
-
at nisi cumque.
|
|
40
|
-
</p>
|
|
41
|
-
</div>
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
## Initialize with options
|
|
45
|
-
|
|
46
|
-
### JS
|
|
47
|
-
```javascript
|
|
48
|
-
const example = document.querySelector(".js--reveal-it-w-options");
|
|
49
|
-
const revealWithCallbacks = new RevealIt({
|
|
50
|
-
element: example,
|
|
51
|
-
options: {
|
|
52
|
-
duration: 1,
|
|
53
|
-
opacity: 0,
|
|
54
|
-
yoyo: false,
|
|
55
|
-
repeat: 2,
|
|
56
|
-
onStart: function () {
|
|
57
|
-
example.classList.remove('animation-completed');
|
|
58
|
-
example.classList.add('animation-started');
|
|
59
|
-
},
|
|
60
|
-
onComplete: function () {
|
|
61
|
-
example.classList.add('animation-completed');
|
|
62
|
-
example.classList.remove('animation-started');
|
|
63
|
-
},
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
```
|
|
67
|
-
## Options
|
|
68
|
-
|
|
69
|
-
| Option Name | Type | Default | Desc |
|
|
70
|
-
|-------------------|------------------------------------------|---------------------------|--------------------------------------------------------------------------------------------------------------------------|
|
|
71
|
-
| opacity | number | 0 | Initial opacity of the element before the animation starts. |
|
|
72
|
-
| duration | number | 1 | Duration of the animation in seconds. |
|
|
73
|
-
| rotate | number | - | Degrees to rotate the element. Not set by default. |
|
|
74
|
-
| scale | number | - | Factor by which to scale the element. Not set by default. |
|
|
75
|
-
| y | number | - | Vertical movement in pixels. Not set by default. |
|
|
76
|
-
| x | number | - | Horizontal movement in pixels. Not set by default. |
|
|
77
|
-
| repeat | number | - | Number of times the animation repeats. `-1` for infinite. |
|
|
78
|
-
| ease | string | "none" | GSAP easing function to control animation pacing. |
|
|
79
|
-
| scrollTrigger | object | start: "top center", markers: false, toggleActions: 'play pause resume pause', | Configuration object for GSAP's ScrollTrigger plugin. |
|
|
80
|
-
| onStart | function | console.log("start") | Callback function that runs at the start of the animation. |
|
|
81
|
-
| onComplete | function | console.log("finish") | Callback function that runs upon completion of the animation. |
|
|
82
|
-
|
|
83
|
-
## Initialize with options and breakpoints
|
|
84
|
-
|
|
85
|
-
### JS
|
|
86
|
-
```javascript
|
|
87
|
-
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
## Methods
|
|
91
|
-
|
|
92
|
-
### getAnimation()
|
|
93
|
-
|
|
94
|
-
Retrieves the GSAP animation instance for further manipulation. This allows direct access to GSAP's animation methods such as `.restart()`, `.pause()`, `.play()`, and more.
|
|
95
|
-
|
|
96
|
-
#### Usage
|
|
97
|
-
|
|
98
|
-
```javascript
|
|
99
|
-
// If we want to restart the animation
|
|
100
|
-
revealit.getAnimation().restart;
|
|
101
|
-
```
|
|
102
|
-
|
|
103
|
-
### refresh()
|
|
104
|
-
|
|
105
|
-
Refreshes the ScrollTrigger instance associated with the animation. This method is useful when the DOM changes in a way that affects the size or position of the animated element, ensuring the scroll animations remain accurate.
|
|
106
|
-
|
|
107
|
-
#### Usage
|
|
108
|
-
|
|
109
|
-
```javascript
|
|
110
|
-
revealit.refresh();
|
|
111
|
-
```
|
|
112
|
-
|
|
113
|
-
### destroy()
|
|
114
|
-
|
|
115
|
-
Destroys the ScrollTrigger instance linked to the animation, effectively removing the scroll-triggered behaviors and listeners. Use this method to clean up when an animation is no longer needed to prevent memory leaks and ensure optimal performance.
|
|
116
|
-
|
|
117
|
-
#### Usage
|
|
118
|
-
|
|
119
|
-
```javascript
|
|
120
|
-
revealit.destroy();
|
|
121
|
-
```
|
|
122
|
-
|
|
123
|
-
## License
|