web
mobile
Edit these docs Rate these docs

Vue Bootstrap Intersection Observer MDB Pro component

Vue Intersection Observer - Bootstrap 4 & Material Design

The mdb-intersect is a custom directive which allows calling a method when an element is visible on the screen.

Live Preview

Basic usage

Step 1: Import the directive from 'mdbvue'


        <script>
          import { mdbIntersect } from "mdbvue";
        </script>
      

Step 2: Add mdbIntersect to the directives object


        <script>
          import { mdbIntersect } from "mdbvue";
          export default {
            directives: {
              mdbIntersect
            }
          };
        </script>
      

Step 3: Attach the directive to an element and pass a callback


        <template>
          <div v-mdb-intersect="callback">...</div>
        </template>
      

        <script>
          import { mdbIntersect } from "mdbvue";
          export default {
            directives: {
              mdbIntersect
            },
            methods: {
              callback() {
                //...
              }
            }
          };
        </script>
      

Arguments

Name Description Example
:container The scroll event listener will be attached to a parent component instead of the window (default option). For this option to work, the parent node should have overflowY set to auto or scroll <div v-mdb-intersect:container="callback" ></div>

Modifiers

Name Description Example
.once The callback will be triggered only once <div v-mdb-intersect.once="callback" ></div>
.start The callback will be triggered every time the element is visible and once when the directive is inserted <div v-mdb-intersect.start="callback" ></div>

Streaming now live

HTML, CSS - free educational webinar for your quarantaine.

WATCH NOW

Free live lesson

Learn HTML and CSS fundamentals. Join now, and don't miss the livestream.

JOIN NOW