Interrupting an SVG animation

Is there a way to stop an SVG animation using jQuery? The SVG image is dynamically inserted in the DOM using viewHelper (like Typo3Fluid). I tried adding a class .stop with animation-play-state: paused; but it didn't work.

Here's the JavaScript code:

    var bulletlist = function (container) {
    var self = this;
    this.container = container;

    $(".x-control", self.container).click(function() {
        //Toggle play and pause button
        $(".x-control").toggleClass("x-play");

        //Start and stop SVG animation
        $(".wv_bulletlist svg").toggleClass("stop");
        //$(".wv_bulletlist svg").css("animation-play-state", "paused");

        return false;
    });
};

$(function () {
    $('.wv_bulletlist').each(function () {
        new bulletlist(this);
    });
});

And here's the CSS:

<style>path {
  stroke-dasharray: 125;
  stroke-dashoffset: 0;
  animation: dash 4s .01s linear forwards infinite;
}
#t-horizontal, #t-vertical {
  stroke-dasharray: 30;
  stroke-dashoffset: 0;
  animation-name: dash-short;
}
#t, #t-horizontal, #t-vertical {
  animation-delay: .5s;
}
#s {
  animation-delay: 1s;
}
@keyframes dash-short {
  from, 30% {
    stroke-dashoffset: 30;
  }
  76%, to {
    stroke-dashoffset: 0;
  }
}
@keyframes dash {
  from {
    stroke-dashoffset: 125;
  }
  67%, to {
    stroke-dashoffset: 0;
  }
}</style>

I need a solution that works on IE 11 and can handle any SVG inserted into the container. Any insights or advice would be greatly appreciated.

Thanks!

Answer №1

The animated sequence is linked to one or multiple <path> elements, while your stop class is applied to an element identified by the selector ".wv_bulletlist svg". Keep in mind that CSS animation properties do not carry over to other elements. To pause the animation, you need to specifically include animation-play-state: paused on the corresponding path element(s) where the animation is active.

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

Use JavaScript to find any text enclosed within [quote] and [/quote] tags and then replace it with <div class="quote-text">foo text</div>

Hey there! I have a specific text format that looks like this: [quote]foo text[/quote] and I would like to convert it to the following: <div class="quote-text">foo text</div> Do you have any idea how I can achieve this using JavaScript? Cu ...

Can a LiveCode translator be developed for my app that can translate all text within the application?

I'm interested in developing a translator within my LiveCode app that can translate any text. I attempted to integrate Google Translate, but it didn't work as expected. Thank you! ...

Create objects in the gallery

I recently developed a React Material-UI component using Typescript: <Grid container direction="row" justifyContent="flex-start" alignItems="flex-start"> <Grid item xs={5}> <B ...

Is there a way to solve the issue of Textarea restricting users to input only one character on iOS devices?

Working with Framework7 and Cordova has been great overall. However, I have encountered an issue specifically on IOS devices (both simulator and real device) where I am unable to enter text completely into a textarea. Whenever I try to input text using th ...

The console is encountering XML parsing errors while trying to load content from one HTML file into another

I am currently using the latest version of Firefox to locally view my static web page, index.html, as I work on developing it. My approach in organizing my web page content involves having multiple HTML files for easier maintenance and reduced client-side ...

Why is my Bootstrap row exceeding the page width when I resize it?

As a newcomer to Bootstrap, I have been following tutorials to learn more about it. Currently, I am attempting to recreate the layout of Google's homepage. However, I am facing challenges with the grid system's responsiveness. I have managed to ...

The ajax call is not yielding a successful response, consistently redirecting to the error function

My attempt to retrieve JSON data from a servlet is resulting in an error block response for every call, even though the backend is providing the correct response. Here is my JavaScript code: $(document).ready(function() { $("#submit").on("click", fun ...

The speed of generating sparklines is causing delays and freezing the browser

Sparklines are amazing little inline graphs. However, if the container they're in is hidden, you can't just draw them behind the scenes and then show them. You have to first display the container and then call the $.sparkline_display_visible meth ...

Tips for utilizing SeleniumRC within JUnit framework for elements with dynamically changing IDs

I'm currently in the process of automating a workflow and I need to click on a link within a table row. The challenge is that all links within the rows share the same element ID, and the source code has a JavaScript code snippet like this: ("Element I ...

Can an <option> element in WebKit be customized by adding an icon to it?

I have integrated a WebView into one of my software applications, and within the HTML page it is rendering, there is a <select> tag. I am interested in enhancing the <option> elements within this select tag by adding icons to them: (The shadow ...

Animating rows to smoothly glide across the screen

I have created a container with four rows, each containing a different number of columns. When I click on a row, it should move to the next row. However, when I click on the final row (which is in the last position), it should wrap around and move to the ...

Create a page turning effect in React that simulates scrolling a certain amount at a time

Is there a way to disable default scrolling and have the page automatically scroll to the next item? For example, if I have element2 below element1, how can I set it up so that when I scroll down once, the page scrolls directly to the position of element2 ...

Is it possible to still alter options in a read-only Select component in Twitter Bootstrap

Even though I have set my bootstrap select to readonly="true", I am still able to change the selected option. I tried using disabled="true", but then the select is not included when submitted. Is there a way to achieve a combination where the selected op ...

Conceal the block quotes while substituting with a newline

My HTML page contains numerous comments enclosed in blockquotes. I attempted to implement a feature that allows users to hide all the comments with just one click by using the following JavaScript code: const blockQuotes = document.getElementsByTagName(& ...

Issue with jQuery AJAX requests

Appreciate all the assistance provided so far, you guys are awesome! :D Currently facing an issue with using jQuery and AJAX. I am fetching all user photos from my database, displaying them in a grid, and implementing a jQuery pagination plug-in 'pa ...

Tips for creating an indent in a new line

https://i.stack.imgur.com/O8Xbv.png I've been trying to figure out how to make the text indent on each new line when it's pushed to a new line due to screen resizing. I've tried using 'display:block' but it doesn't seem to wo ...

"Can anyone tell me why my index.html file isn't recognizing the style.css file located in my css directory

In the directory structure below, I have the following files: mywebsite/ ├── css/ │ ├── style.css │ ├── index.html This is my HTML code: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8 ...

Use CSS media queries to swap out the map for an embedded image

Looking to make a change on my index page - swapping out a long Google Map for an embedded image version on mobile. The map displays fine on desktop, but on mobile it's too lengthy and makes scrolling difficult. I already adjusted the JS setting to "s ...

What is the relationship between $.when, apply(), and $.done() within the scope of this function?

I recently received this function from a helpful SO user that allows for returning a variable number of jQuery $.get() requests. The initial part seems pretty straightforward, but I am struggling to understand how $.when(), apply(), and $.done() are inte ...

Navigate through elements in jQuery by scrolling both up and down

Is there a way to create a scroll function similar to WhatsApp's search feature? When the user clicks on the search (located at the bottom), I want it to automatically scroll to the last element. For example, if the user clicks the up button, it sho ...