Animate On Scroll

Vue Bootstrap Animate on Scroll - Bootstrap 4 & Material Design

Note: We are transitioning MDB4 to a legacy version and focusing on developing MDB5. While we'll continue to support for the transition period, we encourage you to migrate to MDB5. We're offering a 50% discount on MDB5 PRO to help with your transition, enabling you to leverage the full potential of the latest version. You can find more information here.
get 50% discount on MDB5 PRO

The mdb-animate-on-scroll directive allows to activate the animation after the element was scrolled into the viewport.

Live Preview

Basic usage

Step 1: Import mdbAnimateOnScroll directive from 'mdbvue'

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

Step 2: Add mdbAnimateOnScroll to directives

        
            
      <script>
        import {
          mdbAnimateOnScroll
        } from "mdbvue";
        export default {
          name: "AnimationsPage",
          directives: {
            mdbAnimateOnScroll
          }
        };
      </script>
      
        
    

Step 3: Pick an animation style from the list of animations and set the directive equal to its name:

        
            
      <template>
        <img src="https://mdbootstrap.com/img/logo/mdb-transparent-250px.webp" alt="Transparent MDB Logo"
          v-mdb-animate-on-scroll="'fadeIn'" />
      </template>
      
        
    
        
            
      <script>
        import {
          mdbAnimateOnScroll
        } from "mdbvue";
        export default {
          name: "AnimationsPage",
          directives: {
            mdbAnimateOnScroll
          }
        };
      </script>
      
        
    

Step 4: Customize your animation according to your needs by passing an object to a v-mdb-animate-on-scroll directive. Apart from animation class you can specify delay or position - delay takes time as an argument (in milliseconds) while position is an additional percent of a view port height user has to scroll before an animation starts.

        
            
      <template>
        <img src="https://mdbootstrap.com/img/logo/mdb-transparent-250px.webp" alt="Transparent MDB Logo"
          v-mdb-animate-on-scroll="{animation: 'fadeInRight', delay: 100, position: 12}" />
      </template>
      
        
    
        
            
      <script>
        import {
          mdbAnimateOnScroll
        } from "mdbvue";
        export default {
          name: "AnimationsPage",
          directives: {
            mdbAnimateOnScroll
          }
        };
      </script>
      
        
    

Example

        
            
      <template>
        <section>
          <div class="mb-5">
            <mdb-row class="mb-4">
              <mdb-col>
                <img src="https://mdbootstrap.com/img/Photos/Horizontal/Nature/4-col/img%20(31).webp" alt="Sample image"
                  class="img-fluid" v-mdb-animate-on-scroll="{animation: 'bounceInLeft', delay: 300, position: 20}" />
              </mdb-col>
              <mdb-col>
                <img src="https://mdbootstrap.com/img/Photos/Horizontal/Nature/4-col/img%20(32).webp" alt="Sample image"
                  class="img-fluid" v-mdb-animate-on-scroll="'tada'" />
              </mdb-col>
              <mdb-col>
                <img src="https://mdbootstrap.com/img/Photos/Horizontal/Nature/4-col/img%20(73).webp" alt="Sample image"
                  class="img-fluid" v-mdb-animate-on-scroll="{animation: 'fadeInLeft', delay: 200}" />
              </mdb-col>
            </mdb-row>
            <mdb-row class="mb-4">
              <mdb-col>
                <img src="https://mdbootstrap.com/img/Photos/Horizontal/Nature/4-col/img%20(34).webp" alt="Sample image"
                  class="img-fluid" v-mdb-animate-on-scroll="'fadeInRight'" />
              </mdb-col>
              <mdb-col>
                <img src="https://mdbootstrap.com/img/Photos/Horizontal/Nature/4-col/img%20(14).webp" alt="Sample image"
                  class="img-fluid" v-mdb-animate-on-scroll="'fadeIn'" />
              </mdb-col>
              <mdb-col>
                <img src="https://mdbootstrap.com/img/Photos/Horizontal/Nature/4-col/img%20(35).webp" alt="Sample image"
                  class="img-fluid" v-mdb-animate-on-scroll="'rollIn'" />
              </mdb-col>
            </mdb-row>
          </div>
        </section>
      </template>
      
        
    
        
            
      <script>
        import {
          mdbRow,
          mdbCol,
          mdbAnimateOnScroll
        } from "mdbvue";
        export default {
          name: "AnimationsPage",
          components: {
            mdbRow,
            mdbCol
          },
          directives: {
            mdbAnimateOnScroll
          }
        };
      </script>