You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
PostCSS plugin to replace `spring()` functions with a `linear()` easing function. Inspired by [postcss-easings](https://github.com/postcss/postcss-easings).
9
+
Want your CSS animations to bounce and boogie 🕺 ? You've come to the right place!
10
+
11
+
This PostCSS plugin gives your CSS the superpower to create "spring" animations, bringing your websites to life! Inspired by [postcss-easings](https://github.com/postcss/postcss-easings), it replaces `spring()` functions with a `linear()` easing function.
12
+
13
+
14
+
Here's a glimpse of how you can use it in your CSS:
10
15
11
16
```css
12
17
.snake {
@@ -17,6 +22,8 @@ PostCSS plugin to replace `spring()` functions with a `linear()` easing function
17
22
}
18
23
```
19
24
25
+
And here's what it looks like once `postcss-spring-easing` works its magic:
26
+
20
27
```css
21
28
.snake {
22
29
--spring-duration: 1333.33ms;
@@ -30,11 +37,16 @@ PostCSS plugin to replace `spring()` functions with a `linear()` easing function
30
37
31
38
> _**Note**: all the easings [spring-easing](https://github.com/okikio/spring-easing) supports `postcss-spring-easing` supports as well._
32
39
33
-
<!-- > You can also read the [blog post](https://blog.okikio.dev/postcss-spring-easing), created for it's launch. -->
40
+
## Why use postcss-spring-easing? 🤔
34
41
35
-
You can create animation's like this with `postcss-spring-easing`,
42
+
CSS is great for designing your websites, including adding animations. But there are certain animation types, like a "spring" animation (imagine a bouncy ball), which CSS alone can't pull off.
36
43
37
-
<imgsrc="media/assets/spring-easing-demo-video.gif"width="1920"loading="lazy"alt="A demo of the various postcss-spring-easings available"align="center"style="border-radius: 1rem; aspect-ratio: auto1920 / 899;" />
44
+
> **Fun fact**: "spring" animations are how Apple is able to create smooth animations for the iPhone.
45
+
46
+
47
+
<!-- > You can also read the [blog post](https://blog.okikio.dev/postcss-spring-easing), created for it's launch. -->
48
+
49
+
<imgsrc="media/assets/spring-easing-demo-video.gif"width="1280"loading="lazy"alt="A demo of the various postcss-spring-easings available"align="center"style="border-radius: 1rem; aspect-ratio: auto1280 / 920;" />
> _Check out the spring easing variants on [Codepen](https://codepen.io/okikio/pen/MWEMEgJ)._
58
+
> _Check out more examples on [Codepen](https://codepen.io/okikio/pen/MWEMEgJ)._
59
+
60
+
`postcss-spring-easing` comes to your rescue! It's a plugin for PostCSS, which enhances the capabilities of your CSS. This plugin helps you craft spring animations effortlessly.
61
+
62
+
In a nutshell, `postcss-spring-easing` is a simple and effective tool for creating bouncy animations with minimum fuss, making your web pages more dynamic and fun.
Check your project for an existing PostCSS config: `postcss.config.js` in the project root,`"postcss"` section in the `package.json` or `postcss` in your bundle config.
106
111
107
112
Add the plugin to plugins list:
@@ -133,6 +138,35 @@ var output = postcss()
133
138
```
134
139
Checkout [tests](./tests/) for more examples.
135
140
141
+
142
+
## Usage
143
+
144
+
To create a spring animation, you just need to write your CSS transitions as usual, but replace the timing function with one of the following:
145
+
146
+
*`spring`
147
+
*`spring-in`
148
+
*`spring-out`
149
+
*`spring-in-out`
150
+
*`spring-out-in`
151
+
152
+
Each of these represents a different type of spring effect.
153
+
154
+
For example:
155
+
156
+
```css
157
+
.box {
158
+
transition: transform 1s spring-out;
159
+
}
160
+
```
161
+
162
+
This will give a spring effect to the transform transition of the `.box` element.
163
+
164
+
The `spring-out` function here means that the animation will start slowly and end quickly, like a spring being released. Similarly, `spring-in` would start quickly and end slowly, and `spring-in-out` would start and end slowly with a quick middle, resembling the movement of a bouncing spring.
165
+
166
+
Now your animations are ready to bounce!
167
+
168
+
Have questions? Or just wanna talk--leave a message on [GitHub Discussions](https://github.com/okikio/postcss-spring-easing/discussions/1)
169
+
136
170
## Showcase
137
171
138
172
A couple sites/projects that use `postcss-spring-easing`:
0 commit comments