Pulsating animation not functioning correctly within Bootstrap modal

My pulse effect is working perfectly on a regular page, but it's not functioning inside the bootstrap modal. I can't figure out why the modal seems to be blocking this effect. What steps should I take to resolve this issue?

$(document).ready(function() {
  // Heart Beat
  var timeoutThrottle, back = true;
  $('#seventyfive').on('transitionend', function(e) {
    clearTimeout(timeoutThrottle);
    timeoutThrottle = setTimeout(function() {
      back = !back;
      pulse(back);
    }, 0);
  });
  var pulse = (function pulse(back) {
    $('#seventyfive').toggleClass('heartBeat', back);
    return pulse;
  })(back);
});
.heart {
  color: #eb5e28;
  -webkit-animation: heathing 1s ease infinite;
  animation: heathing 1s ease infinite;
  position: absolute;
  font-weight: bold;
  width: auto;
  height: 15px !important;
}

#seventyfive {
  position: absolute;
  font-weight: bold;
  /* margin-left: -22px; */
  /* margin-top: 3px; */
  font-size: 15px;
  opacity: 1;
  -moz-transform: scale(1);
  -webkit-transform: scale(1);
  -o-transform: scale(1);
  transform: scale(1);
  transition: all .7s ease-in-out;
  -webkit-transition: all .7s ease-in-out;
  -moz-transition: all .7s ease-in-out;
  -ms-transition: all .7s ease-in-out;
}

#seventyfive.heartBeat {
  font-size: 16px;
  opacity: .5;
  -moz-transform: scale(1.1);
  -webkit-transform: scale(1.1);
  -o-transform: scale(1.1);
  transform: scale(1.1);
  transition: all .7s ease-in-out;
  -webkit-transition: all .7s ease-in-out;
  -moz-transition: all .7s ease-in-out;
  -ms-transition: all .7s ease-in-out;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.bundle.min.js" integrity="sha384-6khuMg9gaYr5AxOqhkVIODVIvm9ynTT5J4V1cfthmT+emCG6yVmEZsRHdxlotUnm" crossorigin="anonymous"></script>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#exampleModalCenter">Launch demo modal</button>
<div class="modal fade" id="exampleModalCenter" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle" aria-hidden="true">
  <div class="modal-dialog modal-dialog-centered" role="document">
    <div class="modal-content">
      <div class="modal-body new-match">
        <div class="title">Hi Love <i class="fa fa-heart heart" id="seventyfive"></i></div>
      </div>
    </div>
  </div>
</div>

Answer №1

To implement this functionality, you can utilize Bootstrap's modal events such as shown.bs.modal and hidden.bs.modal.

$('#exampleModalCenter').on('shown.bs.modal', function (e) {
  $('#seventyfive').addClass('heartBeat');
})
$('#exampleModalCenter').on('hidden.bs.modal', function (e) {
  $('#seventyfive').removeClass('heartBeat');
})

Upon the modal being displayed, the heartBeat class will be added dynamically, and it will be removed once the modal is hidden.

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

Building an HTML table dynamically with JavaScript

Can anyone help me figure out why my JavaScript code isn't populating the HTML body table as expected? var shepard = { name: "Commander", victories: 3, ties: 1, defeats: 6, points: 0 }; var lara = { name: "RaiderOfTombs", victories: ...

Using classes to override CSS

I've been going through the Material UI Overrides documentation in an attempt to customize the color of each radio button, but I'm having trouble grasping it conceptually. If I start with Material UI's default setup for radio buttons, how ca ...

Displaying two dropdown menus with just a single coding component

Hey everyone, I'm having a problem with the dropdown list. I added an ASP dropdown list to a modal popup using a Bootstrap theme, but when the modal pops up, the dropdown list appears twice. Check out this image for reference: https://i.stack.imgur.co ...

Dynamically assigning anchor tags to call JavaScript functions

Creating a list dynamically, full of <span class="infa9span"><img src="/csm/view/include/images/foldericon.png"/><a id="infa9Service">'+servicename+'</a><br/></span> tags. This list is then appended to a div. ...

Ways to set Material UI tabs as active exclusively for particular URLs

Looking for a solution to address a conflict arising from the active tab indicator being located on the right tab. Within my navbar, I have tabs leading to three different routes, two of which are quite similar. <Tabs indicatorColor="primary" ...

Solving the Color Change Mystery in Your Dash Application

My goal is to design a sleek black dashboard, so I acquired a CSS stylesheet that should give my dashboard a black theme. Following the instructions, I created an assets folder in the root directory of my app and added my CSS and JavaScript files there. Da ...

Assign the jQuery library to a variable

I've been attempting to load a script tag via ajax, and one way to achieve this is by appending it using the .html function in jQuery. Here's an example of what I tried: jQuery(document).ready(function($) { var flexsliderThumg = "jQuery(doc ...

What is the best way to access attributes from a div element?

I am currently working on extracting attributes from within a div tag, specifically the custom attributes of the first child element. I am using web scraping techniques with Node.js and Puppeteer. My goal is to retrieve the custom attributes data-ticker, d ...

The redirection of the URL after form submission is not functioning correctly

I'm attempting to develop a pair of dropdown lists in Elementor where the second dropdown's options depend on what is selected in the first, and the second contains URLs linked to a GO button that redirects to the chosen URL. However, I've f ...

Is there a way to apply an event function after adding elements through append?

When I click the button, a div is appended inside the body. However, I am trying to make it so that when I click on this newly appended div, an alert message pops up. I have tried implementing this with a highlighted area, but have been unsuccessful. How c ...

Turn off the default automatic AJAX request for DataTables server-side paging

Currently, my dataTable is set up with server-side paging and it works correctly. The table fetches data via ajax during initialization. However, I now require the table to be empty initially and load data only when a button is clicked using either the loa ...

Using JQuery, you can predominantly focus on an html element by referencing its title tag

Is it possible to target an HTML element based on its title tag? Consider the following example: <a class="cat" title="categoryName">categoryName</a> How can we select this anchor element by its title tag and then add some text to it? I att ...

Navigate to a fresh HTML page upon form submission

I'm completely new to the world of web apps and JavaScript, and I'm facing an issue where my form submission doesn't redirect me to a thank you page. Instead, it just leads to a blank page every time. I've tried researching solutions on ...

Angular has the capability to rewrite URLs in CSS, providing a unique way

An issue arises in Angular when using a base set and html5mode with SVGs. This causes things like filter: url(#url) to be rewritten as filter: url(/base/#url). https://github.com/angular/angular.js/issues/8934 Disabling html5 mode and removing the base d ...

Challenges with HTML and Session Handling

It's not functioning properly! <?php session_start(); ?> <p class="username"><?php echo $_SESSION['name']; ?></p> ...

Dynamic background image coupled with navigation buttons

Within the realm of Bootstrap 3, I've crafted a navbar that showcases a background image alongside a series of menu items positioned below said image: The following snippet of CSS handles the background image: .navbar-fixed-bottom .navbar-collapse ...

Activate the jQuery UI datepicker with a trigger

Within my code, I have a span element that displays a date in the format mm/dd/yyyy. <span class="editableDateTxt">06/10/2014</span> My goal is to have an inline editable date popup or utilize jQuery UI's datepicker when this span elemen ...

Dispose the inputpicker filter after setting the value

I am currently utilizing the "Jquery inputpicker plugin" for creating dropdown menus. More information about this plugin can be found here. To initialize my dropdown, I use the following code: $('#test').inputpicker({ data:[ {value:"1 ...

I am having trouble aligning the element perfectly in the center

I'm working on a radio input design featuring a circle in the middle, achieved via the pseudo element ::before However, I've noticed that when the input size is an odd number, the centering isn't quite perfect This issue seems more promine ...

Showing Div content from AngularJS response

Query -- I am currently using a Controller in AngularJs that performs an $http.get request and receives data as a response. The data includes an HTML DivID and corresponding classes. How can I extract this DivID from the response and transfer it to the vi ...