Skip to content

Commit 10c64e8

Browse files
committed
update readme
1 parent 3d9fc51 commit 10c64e8

File tree

1 file changed

+32
-5
lines changed

1 file changed

+32
-5
lines changed

README.md

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ module.exports = {
3434
#### Via CDN
3535
You can include the CDN build of this plugin as a `<script>` tag to your site:
3636
```html
37-
<script defer src="https://unpkg.com/tailwindcss-intersect@1.x.x/dist/observer.min.js"></script>
37+
<script defer src="https://unpkg.com/tailwindcss-intersect@2.x.x/dist/observer.min.js"></script>
3838
```
3939

4040
#### Via NPM
4141
Alternatively, you can add the plugin to your JavaScript bundle:
4242
```js
43-
import Observer from 'tailwindcss-intersect';
43+
import { Observer } from 'tailwindcss-intersect';
4444

4545
Observer.start();
4646
```
@@ -53,20 +53,47 @@ Use the `intersect:` variant in your classes like you would with every other Tai
5353
<div class="bg-cyan-500 intersect:bg-indigo-600 transition-colors"></div>
5454
```
5555

56-
### The once utility
56+
## Modifiers
57+
58+
### intersect-once
5759
You can use `intersect-once` if you want to trigger the event only on the first appearance of an element.
5860
```html
5961
<div class="intersect:animate-spin intersect-once"></div>
6062
```
6163

62-
### Custom classes
64+
### intersect-half
65+
Use the `intersect-half` utility to trigger the event when at least half of the element is visible. (threshold is set to 0.5)
66+
```html
67+
<div class="intersect:animate-spin intersect-half"></div>
68+
```
69+
70+
### intersect-full
71+
Use the `intersect-full` utility to trigger the event when when the element is fully visible. (threshold is set to 0.99)
72+
```html
73+
<div class="intersect:animate-spin intersect-full"></div>
74+
```
75+
76+
## Custom classes
6377
If you want to define the intersection behavior in a custom class (e.g. with the @apply directive), add a `intersect` class to your HTML element.
6478
```html
6579
<div class="intersect custom-class"></div>
6680
```
6781

82+
## Migrate from 1.x
83+
If you have integrated the JavaScript snippet via NPM, change the import like this:
84+
```js
85+
// v1.x
86+
import Observer from 'tailwindcss-intersect';
87+
88+
// v2.x
89+
import { Observer } from 'tailwindcss-intersect';
90+
91+
Observer.start();
92+
```
93+
That's it! 🎉
94+
6895
---
6996

70-
<a href="https://tailwindcss.com/"><img src="https://img.shields.io/badge/Tailwind%20CSS-3+-38bdf8?style=for-the-badge"></a>
97+
<a href="https://tailwindcss.com/"><img src="https://img.shields.io/badge/Tailwind%20CSS-3.2+-38bdf8?style=for-the-badge"></a>
7198
<a href="https://www.npmjs.com/package/tailwindcss-intersect"><img src="https://img.shields.io/npm/v/tailwindcss-intersect?style=for-the-badge"></a>
7299
<a href="https://www.npmjs.com/package/tailwindcss-intersect"><img src="https://img.shields.io/npm/dt/tailwindcss-intersect?style=for-the-badge"></a>

0 commit comments

Comments
 (0)