Center align your animations without using the text-align property

I'm in the process of refining this custom animation to make it smoother. Check out the live animation here.

The issue I'm encountering is that during the transition when the city name rotates up and replaces the old one, the text-align center property causes the h2 text to abruptly re-align center in a single frame. My goal is to achieve a seamless transition where it gradually eases into aligning center instead of an instant jump.

I hope that explanation clarifies things. Here's the code snippet:

HTML

<div class="coverage">
    <h2>Kellin has service in&nbsp;<span class="flip"></span></h2>
    <ul class="coverage_list">
       ...
    </ul>
</div><!-- end .coverage -->

CSS


.coverage{
   ...
}
...

JS / Jquery


var coverageVars = {
    ...
}

$(document).ready(function(){

    ...

});

I think adjusting margins and applying CSS transitions might be the solution, but I can't seem to figure it out on my own. Appreciate any guidance you can provide. Thank you!

Answer №1

Here is another concept:

  • Determine the width of your <h2> element (excluding .flip class)
  • Find out the width of the following <li> element that will be added next. Make sure the .coverage_list is not hidden using display: none, but you can set height: 0 and hide it using overflow.
  • Animate your <h2> to adjust to the new width (<h2> + <li>). Allow for a slight increase, around 1-2px, due to browser rendering.
  • Repeat steps #2 and #3, ensuring to animate the width change before appending the elements.

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

Having trouble retrieving the image from the /var/www/efs/image/ directory using the html <img src> tag

Currently, I am facing a challenge in my project where I am trying to retrieve an image based on the users ID. The image is stored in the /var/www/efs/image folder. I attempted to specify the directory using the following code: <img src={"/var/www/ ...

Enhanced functionality for Thingworx using ThreeJS

I'm currently facing an issue while developing a 3 JS extension for Thingworx, specifically with the renderHtml function when working with a 3 JS canvas (Check out the code). //runtime.ts file renderHtml(): string { let htmlString = '<div ...

Differences between an AngularJS function() and a factory function() when used in a

When it comes to Angular, I've come across directives being written in two different ways: .directive('example', function () { // Implementation }); .directive('example', function factory() { // Implementation }) Can you ...

What is the best method for achieving a pristine white floor with subtle shadows?

I'm struggling to achieve a white floor with shadows on it, but all I end up with is a lightgray floor with very thin shadow. Here's my floor and light configuration: const ModelSceneEnvironment = () => { return ( <> {/* Lig ...

Encountering a KeyError while implementing a search view with Django and AJAX

I'm in the process of enhancing my Django blog application by integrating an AJAX search feature. Below is the code snippet: search_form.html <form id="search-form" method="get" action="{% url 'search' %}"> <input type="text" ...

Open boxes with walls that don't create shadows

Currently, I am facing an issue with an open-sided box created using MeshStandardMaterial and BoxGeometry. I have configured the box to cast and receive shadows, but it is not behaving as expected. I anticipated the interior of the box to darken when the p ...

"Enhance User Experience with jQuery Autocomplete using String Arrays

Within my web form model (AdtFormModel), there is a variable: public List<String> TemoinsVille { get; set; } I opted for a list structure as I intend to allow users to dynamically add more 'TemoinsVille' inputs in the form. Currently, ...

Improving User Experience with HTML Form Currency Field: Automatically Formatting Currency to 2 Decimal Places and Setting Maximum Length

Hello there, I am currently facing an issue with the currency auto-formatting in a deposit field on my form. The formatting adds 2 decimal places (for example, when a user types 2500, the field displays 25.00). However, the script I wrote does not seem to ...

The jQuery datepicker fails to function properly on an HTML element that has been added via AJAX

In the page header, I have a jQuery datepicker function bound to the "birthday" input HTML element: <script type="text/javascript"> $(function() { $( "#birthday" ).datepicker(); }); </script> After that, some AJAX functionali ...

Handling invalid JSON data using JavaScript

Looking to extract data from this URL using Javascript. Here is a sample of the JSON content: {"ss":[["Thu","7:00","Final",,"BAL","19","ATL","20",,,"56808",,"PRE4","2015"],["Thu","7:00","Final",,"NO","10","GB","38",,,"56809",,"PRE4","2015"]]} Most tutori ...

What is the best method for deleting the 'records per page' label text from datatables?

I'm trying to customize my jQuery datatables by removing the label "Records per page." I already know that "oLanguage": { "sSearch": "" } can be used to remove the search label, but is there a similar option for hiding the results per page label? ...

The charset is failing to function properly when using the French language

Encountering an issue with the French language on a website I'm currently developing ... Specifically, there are menu bars, tabs, and text within each tab involved. Upon setting charset=ISO-8859-1, the body text functions correctly, but the menu bar ...

What is the process for validating observations with an observer confirmation?

Can you explain what the of() function creates in this scenario and how it operates? public onRemoving(tag): Observable<any> { const confirm = window.confirm('Do you really want to remove this tag?'); return Observable.of(tag).fil ...

Developing in Java Script with ENVDTE involves adding a new project to an existing solution and placing it in a designated sub-folder for organization purposes

Currently, I am working on developing a Visual Studio extension for a new C++ project template using Visual Studio 2010. The approach I am taking involves utilizing the .vsz template method and customizing the default.js code to suit my requirements. Withi ...

Using table.column as a function in jQuery datatabbe is not supported

When using jquery datatable, I encountered an error stating "table.column is not a function." <script> $(document).ready(function() { var table = $('#lsotable').dataTable(); $("#lsotable thead th").each( function ( i ) { ...

Styling in Next.js with conditions

I am attempting to create a scenario where a link becomes active if the pathname matches its href value. function Component() { const pathname = usePathname(); return ( <div className="links"> <Link href="/"> ...

One of the quirks of Angularjs is that the ng-enter animation will only be

The initial animation only occurs the first time. I am utilizing Angularjs version 1.2.22 Here is the CSS that I am using : .ng-enter { animation: bounceInUp 2s; } .ng-leave { animation: bounceOutUp 2s; } And this is the route configuration : ...

Handing off the Event Object to a Function in JQuery

Usually, I'm able to send an event to a nameless Jquery function like this: $(".click_me").on("click", function(e) { e.preventDefault(); }); But what if I want to eliminate the anonymous function and still pass the event to it: function onClickMe ...

jQuery is in a constant state of indecision when it comes to determining the best way to manage buttons

A straightforward scenario. When a checkbox is checked, it activates a disabled button. Unchecking the box disables the button again. Sample Code: jQuery -> $('#subscribe_button').attr('disabled','disabled') $("[name= ...

vuejs props become null upon page refresh

MyComponent.vue template: <ResponsiveNavigation :nav-links="navLinks" /> script data: () => ({ navLinks: [] }), created: function() { this.getSocialMediaLinks(); }, methods: { getSocialMediaLinks() { var self = this; ...