Posts Learn Components Snippets Categories Tags Tools new About
/

Install and Use Alpine JS Intersect Plugin

Learn how to integrate Alpine JS Intersect plugin

Created on Jul 26, 2021

309 views

Install Using Yarn / Npm
To install Alpine Js intersect plugin use yarn / npm.
yarn add @alpinejs/intersect

npm install @alpinejs/intersect

Initialize the Plugin
Then initialize it from your bundle.
import Alpine from 'alpinejs'
import intersect from '@alpinejs/intersect'

Alpine.plugin(intersect)

Use the Plugin
To use the plugin just call the x-intersect directive and now once the user sees the section / intersect, the code will run.
<div x-data x-intersect="console.log('hello world')">
  <!-- your content here -->
</div>

<div x-data x-intersect="@this.call('loadMoreData')">
  <!-- your content here -->
</div>

Related Snippet

If you like our tutorial, do make sure to support us by being our Patreon or buy us some coffee ☕️

Load comments for Install and Use Alpine JS Intersect Plugin

)