Stylish Wave Animation Effects in CSS for iPad Native Application

The ripple effect on the iPad Native app is malfunctioning.

  1. The effect is mistakenly applied to all buttons in the navigation instead of just the li elements.

Please identify the error and provide a solution.

(function (window, $) {
  
  $(function() {
    
    $('.ripple').on('click', function (event) {
      event.preventDefault();
      
      var $div = $('<div/>'),
          btnOffset = $(this).offset(),
          xPos = event.pageX - btnOffset.left,
          yPos = event.pageY - btnOffset.top;
      $div
        .addClass('circle')
        .css({
          top: yPos - 15,
          left: xPos - 15
        }) 
        .appendTo($(this));

      window.setTimeout(function(){
        $div.remove();
      }, 1000);
    });
    
  });
  
})(window, jQuery);
nav {
  position: relative;
  width: 1024px;
  background-color: #25518b;
  bottom: 0;
  height: 60px;
}

#home-btn {
  position: absolute;
  width: 79px;
  height: 60px;
  left: 0;
  background: url(../images/home.png) no-repeat center center;
  background-size: 28px 27px;
}

ul.navi {
  margin: 0;
  padding: 0;
  list-style-type: none;
  width: 945px;
  position: absolute;
  left: 79px;
}

ul.navi li {
  float: left;
  width: 188px;
  height: 60px;
  border-left: 1px #959595 solid;
  font-size: 16.5px;
  font-family: "HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif;
  color: white;
  text-align: center;
  display: table;
}

ul.navi li a {
  display: table-cell;
  vertical-align: middle;
  text-decoration: none;
  color: white;
}


/* Ripple Effect for navigation */

.circle {
  position: absolute;
  width: 30px;
  height: 30px;
  background: white;
  border-radius: 50%;
  -webkit-animation: scale-circle 2.5s;
          animation: scale-circle 2.5s;
}

@-webkit-keyframes scale-circle {
  from {
    -webkit-transform: scale(0.2);
            transform: scale(0.2);
    opacity: 0.6;
  }
  to {
    -webkit-transform: scale(100);
            transform: scale(100);
    opacity: 0;
  }
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<nav>
    <div id="home-btn"></div>
    <ul class="navi">
      <li class=""><a href="#" class="ripple active">Link1</a></li>
      <li><a class="ripple" href="#">Link2</a></li>
      <li><a class="ripple" href="#">Link3</a></li>
      <li><a class="ripple" href="#">Link4</a></li>
      <li><a class="ripple" href="#">Link5</a></li>
    </ul>
  </nav>


View the code here: http://codepen.io/Ashish9342/pen/wzqEdO

Answer №1

To create a ripple effect, consider utilizing the ripple css animation. Ensure that your div with the class circle is properly positioned and has the correct width and height. For a practical demonstration, you can refer to this CodePen link.

(function (window, $) {
  
  $(function() {
    
    $('.ripple').on('click', function (event) {
      event.preventDefault();
            var parent = $(this).parent();
             var height = parent.height();
             var width = parent.width();
      var $div = $('<div/>'),
          btnOffset = $(this).parent().offset(),      
          maxW = $("li").width(),
          xPos = $(this).position().left; //event.pageX - btnOffset.left,
          yPos =  $(this).position().top; // event.pageY - btnOffset.top;
          
      $div
        .addClass('circle')
        .css({
           width: width,
           height: height,
          top: yPos,
          left: xPos
        }) 
        .appendTo($(this));

      window.setTimeout(function(){
        $div.remove();
      }, 1000);
    });
    
  });
  
})(window, jQuery);
nav {
  position: relative;
  width: 1024px;
  background-color: #25518b;
  bottom: 0;
  height: 60px;
}

#home-btn {
  position: absolute;
  width: 79px;
  height: 60px;
  left: 0;
  background: url(../images/home.png) no-repeat center center;
  background-size: 28px 27px;
}

ul.navi {
  margin: 0;
  padding: 0;
  list-style-type: none;
  width: 945px;
  position: absolute;
  left: 79px;
}

ul.navi li {
  float: left;
  width: 188px;
  height: 60px;
  border-left: 1px #959595 solid;
  font-size: 16.5px;
  font-family: "HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif;
  color: white;
  text-align: center;
  display: table;
}

ul.navi li a {
  display: table-cell;
  vertical-align: middle;
  text-decoration: none;
  color: white;
}


/* Ripple Effect for navigation */

.circle {
  position: absolute;
  z-index: 1;
  width: 30px;
  height: 30px;
  background: white;
  border-radius: 50%;
  -webkit-animation: ripple 1s ease-out;
          animation: ripple 1s ease-out;
          opacity: 0.5;


}


@keyframes ripple {
  0% {
    transform: scale(0);
  }
  20% {
    transform: scale(1);
  }
  100% {
    opacity: 0;
    transform: scale(1);
  }
}
 <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>

   <!-- Latest compiled and minified JavaScript -->
    <script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.2/js/bootstrap.min.js"></script>  

    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.2/css/bootstrap.min.css">

    <link rel="stylesheet" href="css/styles.css">
    <script src="js/script.js"></script>
</head>

<body>
  <nav>
    <div id="home-btn"></div>
    <ul class="navi">
      <li class=""><a href="#" class="ripple active">Link1</a></li>
      <li><a class="ripple" href="#">Link2</a></li>
      <li><a class="ripple" href="#">Link3</a></li>
      <li><a class="ripple" href="#">Link4</a></li>
      <li><a class="ripple" href="#">Link5</a></li>
    </ul>
  </nav>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

After clearing the option, the onChange function stops functioning

I'm facing an issue with the following code: success: function (data) { $('#' + idDivRefresh).endLoading(); if (data.message != '@Geral.Sucesso') { $('#' + idDropDown + ...

When an image is placed inside a parent div, the link should extend to the entire width of the div, rather than just hovering over

Essentially, I have a div that spans the entire width of its container, inside it is an image link. The image's width is set to adjust automatically with a fixed height of 600px. The link covers the whole width of the div, which in this case is the wi ...

Issue with box-sizing border-box not applying to top and bottom borders

Currently, I am in the process of developing my own responsive website. However, I have encountered an issue with the box-sizing border-box on the top and bottom borders of one specific image. The layout consists of two columns with images of varying heigh ...

Error: The "map" property cannot be read if it is undefined in a Django and React application

While I was following the react and django tutorial, I encountered an issue when I added some code for concern with. The error message 'Cannot read property 'map' of undefined' keeps getting thrown. The error location is pointed out ...

Adjusting Text Color on Buttons

I am looking for a simple button with clear color and black text, but the default button has white text. I need a way to change the text color. Check out my current app <View style={styles.fastlog}> <Button style={styles.bouton} title= "Con ...

Select the hidden HTML option value automatically according to the previous option selected

I am working on a form that includes 2 select tags with the options male and female. The first select, "gender", is visible to the user while the second select, "age", is hidden. <select name="gender"> <option value="1">Male</option> ...

Navigation bar in reactjs remains visible even after clicking on an icon button, causing a temporary issue with

I'm facing an issue with my navigation bar created using material-ui. I have an onClick function set up so that when the user clicks the icon button, the navigation redirects to a new page and then should close. However, no matter what I try, the navi ...

Setting up an image DIV for a dynamic overlay effect

Here is a JSFiddle that works correctly with fixed height and width: http://jsfiddle.net/69td39ha/2/. The animation activates correctly when hovered over. I attempted to adapt the above example to be responsive without fixed dimensions. However, I'm ...

Unable to insert menu links into the container

Currently, I have a logo and image slider placed next to each other in a container. However, I am facing difficulty in adding 3 menu links horizontally under the logo. Every time I try to do so, the links end up going above the image slider, causing it to ...

Transforming PHP Arrays into JavaScript Objects

I am facing some challenges with my code due to my limited understanding of JSON and JS. Here's the code snippet I have been working on: $markersData = array(); $x = 0; while ($row = @mysqli_fetch_assoc($result)) { $type = $row['type']; ...

Encountering a TypeError with DataTables and Tabledit

I've been attempting to integrate DataTables with Tabledit, but I keep encountering the error message "TypeError: Cannot set properties of undefined (setting 'nTf')". The number of tags also matches up. Interestingly, if I comment out the " ...

JQuery Ajax: The loaded content flickers into view, revealing old content momentarily

Having an issue with my ajax code. I am working on a project that involves some links and a content area. The idea is that when a user clicks on a link, the content area should be hidden, load new data, and then show the updated content. However, I have no ...

Challenges with Vuex and updating arrays using axios

I am currently facing a challenge with VueJS Vuex and Axios: The issue arises when I retrieve an array with Axios and loop through it to populate its children this way: "Rubriques" has many self-relations, so one rubrique can have multiple child rubriques ...

Unable to send JSON object using the Jquery.post() method

I have a specific object that is created within my javascript application. poll_data[active_question] = { 'question': $('div.question_wrap textarea').attr('value'), 'answers': [ $(&a ...

What could be causing my node.js postgres function to return undefined even though I verified the value is displayed in the console?

Currently, I am in the process of developing a node.js application with a PostgreSQL backend. I have implemented a pool of connections and made an INSERT query to the database where I anticipate the last inserted ID to be returned. However, while the query ...

Displaying entries of input data

I have an application that includes a modal window with filters, but I am looking to add another type of filter. However, I am struggling with implementing it in React and would appreciate any help with the code or recommended links. Essentially, I want t ...

Challenges with unique scrollbar designs and dynamic tab loading using AJAX

Hello to all amazing members of stackoverflow, I'm facing some major challenges getting my custom scrollbar to function properly with ajax-based tabs. Any assistance you can provide would be immensely helpful. I have most of it set up and operational ...

Assist me in minimizing redundant code in a basic jQuery function

I successfully created a carousel using the jQuery cycle plugin with 4 links that correspond to different slides. Currently, I have separate blocks of code for each link, but I'm looking to optimize by creating a single function. $('#features-sl ...

Troubleshooting issues with drawing images on HTML5 canvas: experiencing unexpected outcomes

As I am diving into learning how to use the HTML5 canvas element, I have had success in drawing rectangles, utilizing getImageData, manipulating pixels, and then using putImageData to witness the color changes of the rectangles, among other capabilities. ...

Preventing page reload by using event.preventDefault() does not work with Ajax Form

I've been working on a code snippet to submit a form using Ajax without any page reloads: $( document ).on('submit', '.login_form', function( event ){ event.preventDefault(); var $this = $(this); $.ajax({ data: ...