Interactive Water Ripple Effect in jQuery

Interactive Water Ripple Effect in jQuery
Project: Water Ripple Effect
Author: Mukesh Prajapati
Edit Online: View on CodePen
License: MIT

This code snippet demonstrates a captivating interactive water ripple effect applied to a full-landing image using jQuery. The effect is achieved by utilizing the “jquery.ripples” plugin, which creates realistic ripples on the background image. You can control the number of ripples rendered, and adjust the magnitude of the ripple animation.

By incorporating this code into your projects, you can add an engaging and visually appealing water ripple effect to enhance your website’s aesthetics and user experience.

How to Create Interactive Water Ripple Effect using jQuery

1. To implement the water ripple effect, create a <div> element with the class “full-landing-image” and set the desired background image. Optionally, you can add content to this <div> to display the water ripple effect on the specified content area.

<div class="full-landing-image"></div>

2. Next, let’s set up the CSS to style our full-landing-image container. Replace "path/to/your/image.jpg" with the actual path to your desired background image.

body{
  margin:0;
  padding: 0;
}
.full-landing-image{
  width: 100%;
  height: 100vh;
  background: url('path/to/your/image.jpg') no-repeat center;
  background-size: cover;
}

3. Load jQuery and the Ripples plugin via CDN links, and add the following lines of code just before the closing </body> tag in your HTML file:

<script src='https://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/jquery.ripples/0.5.3/jquery.ripples.min.js'></script>

4. Finally, initialize the Ripples plugin with the container selector in jQuery, add the following code within a <script> tag after including the jQuery and Ripples plugin:

$(".full-landing-image").ripples({
  resolution: 256,
  perturbance: 0.01,
});

That’s it! You have successfully created an Interactive Water Ripple Effect in jQuery. If you have any questions, feedback, or suggestions, please feel free to leave a comment below. Enjoy experimenting and enhancing your web page with this captivating visual effect!

Leave a Comment

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply