Determining the current state of a CSS3 animation with jQuery

For example, I have this code snippet:

@-webkit-keyframes anim {
    0%   {
        -webkit-transform: translate(-100px,0px) rotate(5deg);
    }
    50%   {
        -webkit-transform: translate(-140px,-5px) rotate(10deg);
    }
    100%   {
        -webkit-transform: translate(200px,-30px) rotate(40deg);
    }
}

Is there a way to determine the exact moment when the animation reaches the 50% mark? Simply detecting when it ends doesn't provide the precise information needed.

One possible approach could be timing the animation since it lasts for 3 seconds, but that method may not be entirely reliable.

Any suggestions or insights would be greatly appreciated. Thank you!

Answer №1

It seems like there aren't built-in notification events for the middle stages of a single animation.

One potential solution is to string together two separate animations (triggering the second one to start when the first one ends using JavaScript) and utilize the event at the end of the first animation to determine when the middle point of the entire sequence has been reached.

If you're interested, here's an article outlining a workaround:

Check out this article on CSS Animation Keyframe Events with a JavaScript solution

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

Adaptable positioned picture

I'm trying to figure out how to make a series of positioned images adjust to the window's dimensions. Should the images be relative and the page wrap absolute, or vice versa? I've been experimenting on jsfiddle but can't seem to get it ...

How can I make text wrap instead of overflowing to ellipsis in a list when using vue-material?

Question: <md-list-item> <md-icon v-bind:style="{color: transcript.color}">account_circle</md-icon> <div class="md-list-item-text"> <p>{{ transcript.text }}</p> </di ...

Can flex-basis be used with percentage in IE11?

Encountering an issue with flexbox and IE10/11. Trying to utilize min-width/max-width values, but IE11 is not cooperating. Discovered flex-basis and used a percentage value, which functions as intended in Chrome but fails in IE11. Experimented with adding ...

How do I go about uploading the code as instructed on the platform's e-commerce details page?

.mk_01{ color: #000000; font-size: 30px; font-style: normal; font-family: Baskerville, "Palatino Linotype", Palatino, "Century Schoolbook L", "Times New Roman", serif; text-align: center; } .mk_02{ color: #000000; fon ...

Is there a way to use JavaScript to alter the existing URL?

Currently, I am utilizing a select tag to allow users to choose the number of 'rows' displayed on the table. <%=select_tag :per_page, options_for_select([10,20,50,100]....some more code...., onchange => "if (this.value) {windows.location=& ...

CSS/Jade/HTML: struggling to get boxes to align properly on the same line

I'm currently working with a Jade template that looks like this: extends layout block content h2 Characters and Portraits div(id="portraitsBox") - var portraits = ["Clown-Fox", "Dragon-Bear", "Fish-Bear", "Deer-Wolf", "Salamander-Ant", "Sid ...

Text transitions in a gentle fade effect, appearing and disappearing with each change

I want to create a smooth fade in and out effect for the text within a div when it changes or hides. After researching on Google and Stack Overflow, I found that most solutions involve adding a 'hide' CSS class and toggling it with a custom func ...

The cookie was not successfully initialized

Working with asp.net xss scripting, I encountered a situation where one page sent a post request and received a cookie in the response. However, even though the header indicated that the cookie was returned, the browser failed to set it, resulting in docum ...

Issue with spacing when assigning a JavaScript array variable to a value within input tags during a loop

Having some trouble with JavaScript code where the value is not passing in its entirety if there are spaces between the words. How can I make sure the full string or array object gets passed into the input tag's value? This is how I am trying to assi ...

Having trouble repositioning a div element in CSS

I am having an issue with my code. The problem I'm facing is that I am unable to move the green div.free_space below the other two divs, div.main_pic and div.navigation. I don't understand why this is happening. As I am still learning, I would g ...

What steps can be taken to turn this html code and css into a mobile application?

I have begun working on my HTML and CSS but need some guidance to create a mobile app without needing to resize it when accessed through the web. Additionally, I would like to make it responsive in CSS. Can you provide me with the necessary code? @c ...

Create custom sign board buttons using CSS styling

Check out the button design linked below: I attempted to recreate this design using before and after, but I want the arrow to be softer. I tried skewing it as well. I also searched for references, but couldn't find similar examples online even though ...

What is the purpose of making a "deep copy" when adding this HTML content?

My canvas-like element is constantly changing its contents. I am attempting to execute a function on each change that captures the current content and adds it to another element, creating a history of all changes. window.updateHistory = func ...

The overflow:scroll property fails to function properly after I insert additional content into the div

My webpage includes a div element with initial styles and no content: #chatwindow { width: 500px; height: 50px; overflow-y: scroll; ...

Avoiding interference with adjacent elements caused by long content in a div

Hey there, I could really use some help with my CSS layout, I'm pretty new to CSS and Flexbox and I'm trying to create a simple layout. The issue I'm running into is how to stop long content inside a pre tag from pushing other divs. Here& ...

What is the best way to position a Button at the bottom of a div using jQuery?

Within my HTML, I have divided into two col-md-6 sections. On the left side, there is a picture and on the right side, there is text. I am considering using jQuery .height() for this layout. <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7 ...

Top Margin: Supported by Chrome and Safari

After troubleshooting why the margin-top is not working on Safari, but works fine on Chrome, I discovered a discrepancy. Chrome Upon hovering over an item in the image, the cursor changes as expected. This feature operates smoothly in Chrome. https://i. ...

Reacting like sticky bottoms and tops

I'm working on a react/tailwind project that involves a component I want to be fixed at both the top and bottom of the screen. In simpler terms, there's an element that I need to always stay visible even when the user scrolls up or down the page ...

CSS cascading not happening

Within the usersettings.css.erb file, line numbers are provided for easier reference. 11 #userSettingMain .form-horizontal .controls { 12 13 margin-left: 30px; 14 } 15 16 #user_birthday_3i{ 17 18 margin-left: 0px; 19 } U ...

AngularJS: when ng-route clashes with Bootstrap datetimepicker

I have nearly completed my calendar app and I am looking to integrate the datetimepicker for updating events. You can find the datetimepicker that I am using at this link: Below is an example of how I have utilized it in HTML: <div class="dropdown" s ...