Adding animation to the initial loading process of a Vue application

I want to include an animation when the application's modules are loading for the first time.
I have attempted to use an image, but I am unable to add an animation to it.
Adding a CSS file did not always work as expected.
I then tried utilizing an SVG image and inserting animateTransform into the SVG element.
However, this approach also failed.
Do you have any suggestions on how to successfully add an animation to the image?

Below is the body code from my index.html file.

<body>
<noscript>
  <strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
</noscript>
<div id="app">
  <div id="loading__container">
    <svg
      xmlns="http://www.w3.org/2000/svg"
      xmlns:xlink="http://www.w3.org/1999/xlink"
      viewBox="0 0 86.03 67.01"
      class="img-logo"
      style="position: absolute;top: 50%;left: 50%;transform: translate(-50%, -50%);width: 100px;">
      <defs>
        ...
      </defs>
      <g class="cls-1">
        <animateTransform
          attributeName="transform"
          attributeType="XML"
          type="scale"
          additive="sum"
          keyTimes="0;0.5;1"
          values="0.5;1;0.5"
          dur="1s"
          repeatCount="indefinite"/>
          <g id="Layer_2" data-name="Layer 2">
            ...
          </g>
      </g>
    </svg>
  </div>
</div>
<!-- built files will be auto injected -->

Answer №1

I managed to solve the issue on my own by opting for the image element over the svg element. Here is the code snippet I used:

<div id="app" v-cloak>
  <div id="loading__container">
    <img src="<%= BASE_URL %>initial_img.png" alt="initial loading">
  </div>
</div>

Furthermore, here is the style I implemented:

<style>
  @keyframes zoom-in-zoom-out {
    0% {
      transform: scale(1, 1);
    }
    50% {
      transform: scale(1.5, 1.5);
    }
    100% {
      transform: scale(1, 1);
    }
  }
  #loading__container {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
  }
  #loading__container img{
    animation: zoom-in-zoom-out 1s ease-in infinite;
  }
</style>

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

Encountering the error message "do not mutate props directly" while also trying to render a button

Whenever I try to pass my prop to a component, I encounter an error message. The prop in question is used to display a button element in the payment section. However, there are certain components where this button should not be displayed. Unfortunately, wh ...

Utilizing geometric functions within React-Three-Fiber

Is there a way to use methods such as .rotateZ (not functioning by default) or .center (which do not require arguments) on a geometry component? <mesh position={[x, y, 0]}> <shapeBufferGeometry attach="geometry" args={[shape]} rota ...

Ways to retrieve information from JSON

I am currently trying to access the values of an object that is within an array which is inside another object. The data is structured as follows: [{ "id": "99a4e6ef-68b0-4cdc-8f2f-d0337290a9be", "stock_name": "J ...

Using JavaScript to display a line using `document.write`

I'm having trouble displaying a line using the Document.Write function in JavaScript. When I submit the form, the line briefly appears and then disappears Any ideas on why this might be happening? <!DOCTYPE html> <html> <head& ...

Leveraging the Meteor Framework for Application Monitoring

Exploring the potential of utilizing Meteor Framework in a Monitoring Application. Scenario: A Java Application operating within a cluster produces data, which is then visualized by a Web Application (charts, etc.) Currently, this process involves using ...

What is the best way to vertically align my content in the center?

Is there a way to vertically center all of the text content, especially focusing on the drop-down button and block, here? Despite my efforts to research and find solutions online, I have not been able to achieve the desired visual results. I am restricted ...

Unable to successfully display AJAX data on success

After successfully running my GradeCalc function in a MVC C# context with the grade parameter, I am facing an issue where the data is not displaying and the JavaScript alert pop up shows up blank. Can you assist me with this problem? $("#test").o ...

Populating a Listview in jqueryMobile with dynamic elements

I am struggling with my listview. Whenever I try to add or remove items from the list, the jquery mobile styling does not get applied to the new content that is added. <ul data-role="listview" id="contributionList"> <li id="l1"><a>5. ...

What is the process for implementing transitions using SASS?

When the pointer hovers over it, the transition effect kicks in smoothly. However, it reverts back to its original size abruptly when the mouse pointer is no longer hovering over it. What I aim for is for the cardLink to scale smoothly ...

Error message: Unable to locate Bootstrap call in standalone Angular project after executing 'ng add @angular/pwa' command

Having an issue while trying to integrate @angular/pwa, it keeps showing me an error saying "Bootstrap call not found". It's worth mentioning that I have removed app.module.ts and am using standalone components in various places without any module. Cu ...

A guide to categorizing and tallying JSON data based on multiple keys within the past 30 days using JavaScript/jQuery

I am facing an issue while trying to display a chart and extract specific data from an array. My goal is to generate a chart based on three columns in a JSON array: Source, Campaign, and Date. The process involves grouping the data, counting it, and then ...

Modifying the color of the tooltip arrow in Bootstrap 4: A step-by-step guide

How can I change the arrow color of the tooltip using Bootstrap 4? Here is my current code: HTML: <div class="tooltip-main" data-toggle="tooltip" data-placement="top" data-original-title="Service fee helps Driveoo run the platform and provide dedicate ...

Experiencing difficulties in linking Node JS to the local Mongo DB

Currently I am deepening my knowledge in Mongo DB, Mongoose, and Node JS, however, I am facing issues connecting my Node JS to the local Mongo DB. Below is the code snippet I am working with: dbtest.js var express = require('express'); ...

Introduction to Angular controller binding for beginners

I'm currently going through this tutorial : http://www.youtube.com/watch?v=i9MHigUZKEM At 46:32 minutes into the tutorial, this is the code I have implemented so far : <html data-ng-app="demoApp"> <body data-ng-controller="SimpleControlle ...

How does SWR affect React state changes and component re-rendering?

I am currently utilizing SWR for data fetching as outlined in the documentation: function App () { const [pageIndex, setPageIndex] = useState(0); // The API URL incorporates the page index, which is a React state. const { data } = useSWR(`/api/data? ...

Customized Grafana dashboard with scripted elements

I'm running into an issue while using grafana with graphite data. When I attempt to parse the data, I encounter an error due to the server not providing a JSON response. I am experimenting with scripted dashboards and utilizing the script found here: ...

The div structure generated through JavaScript appears distinct from its representation in the live DOM

Currently, I am facing a challenge with creating a complex nested Div structure within a JavaScript loop that iterates over JSON response objects from the Instagram API. The main goal is to set the URL for each image within a specific Bootstrap div layout. ...

Issues with the visibility of React Bootstrap components

I'm troubleshooting an issue with the carousel on my website. When I try to load the page, the carousel appears blank. To set up the carousel, I used npm to install react-bootstrap. The carousel code can be found at . Upon checking the web console, ...

Issue with Bootstrap 4 list items not displaying in block format

Based on the information from , using li tags as block elements should result in a vertical menu. However, with Bootstrap 4, when I use li tags, the menu stays horizontal on toggle for small devices. Is this the expected behavior? <ul class="nav navb ...

What is the integration between redux and next.js like?

I am currently trying to integrate Redux into an existing Next.js project, but I am struggling to grasp how the store functions server-side. I came across this example that I am following: https://github.com/vercel/next.js/blob/canary/examples/with-redux ...