Vue Bootstrap Intersection Observer MDB Pro component

Vue Intersection Observer - Bootstrap 4 & Material Design

Note: This documentation is for an older version of Bootstrap (v.4). A newer version is available for Bootstrap 5. We recommend migrating to the latest version of our product - Material Design for Bootstrap 5.
Go to docs v.5

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>