Skip to content

Commit

Permalink
ability to use custom classes
Browse files Browse the repository at this point in the history
  • Loading branch information
heidkaemper committed Feb 14, 2023
1 parent 82cba02 commit f4fc2bd
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,9 @@ You can use `intersect-once` if you want to trigger the event only on the first
```html
<div class="intersect:animate-spin intersect-once"></div>
```

### Custom classes
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.
```html
<div class="intersect custom-class"></div>
```
2 changes: 1 addition & 1 deletion docs/examples/styles.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tailwindcss-intersect",
"version": "1.0.3",
"version": "1.0.4",
"description": "Tailwind CSS with Intersection Observer variants",
"author": "Lars Heidkämper",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion src/observer.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const Observer = {
},

observe() {
const elements = document.querySelectorAll('[class*=" intersect:"],[class*=":intersect:"],[class^="intersect:"]');
const elements = document.querySelectorAll('[class*=" intersect:"],[class*=":intersect:"],[class^="intersect:"],[class="intersect"],[class*=" intersect "],[class^="intersect "],[class$=" intersect"]');

elements.forEach(element => {
let observer = new IntersectionObserver(entries => {
Expand Down

0 comments on commit f4fc2bd

Please sign in to comment.