@@ -34,13 +34,13 @@ module.exports = {
34
34
#### Via CDN
35
35
You can include the CDN build of this plugin as a ` <script> ` tag to your site:
36
36
``` 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 >
38
38
```
39
39
40
40
#### Via NPM
41
41
Alternatively, you can add the plugin to your JavaScript bundle:
42
42
``` js
43
- import Observer from ' tailwindcss-intersect' ;
43
+ import { Observer } from ' tailwindcss-intersect' ;
44
44
45
45
Observer .start ();
46
46
```
@@ -53,20 +53,47 @@ Use the `intersect:` variant in your classes like you would with every other Tai
53
53
<div class =" bg-cyan-500 intersect:bg-indigo-600 transition-colors" ></div >
54
54
```
55
55
56
- ### The once utility
56
+ ## Modifiers
57
+
58
+ ### intersect-once
57
59
You can use ` intersect-once ` if you want to trigger the event only on the first appearance of an element.
58
60
``` html
59
61
<div class =" intersect:animate-spin intersect-once" ></div >
60
62
```
61
63
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
63
77
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.
64
78
``` html
65
79
<div class =" intersect custom-class" ></div >
66
80
```
67
81
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
+
68
95
---
69
96
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 >
71
98
<a href =" https://www.npmjs.com/package/tailwindcss-intersect " ><img src =" https://img.shields.io/npm/v/tailwindcss-intersect?style=for-the-badge " ></a >
72
99
<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