Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7659475
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T13:20:16+00:00 2026-05-31T13:20:16+00:00

So, I can create an location animation of an element by doing something like

  • 0

So, I can create an location animation of an element by doing something like this:

Widget.style.left = Dest.x;
Widget.style["-webkit-transition"] = "left 0.3s ease-in-out";

This works fantastically so long as the widget already exists. The problem is when I create a new widget, and want to start it off screen, there doesn’t seem to be an obvious and elegant way to set the start location.

Predictably, if I try this:

Widget.style.left = Src.x;
Widget.style.left = Dest.x;
Widget.style["-webkit-transition"] = "left 0.3s ease-in-out";

The source location is ignored seems to have no effect.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T13:20:17+00:00Added an answer on May 31, 2026 at 1:20 pm

    This is both a problem and a feature with CSS transitions. The browser only sees the “state” of an object that it can use for a transition when your javascript is done executing so only when that happens can the “initial” state of an object be set and likewise, only then can the final state of an object for transitions be seen by the browser. That means that:

    Widget.style.left = Src.x;
    Widget.style.left = Dest.x;
    

    won’t do anything. If the object is brand new, the only state the browser will see (for the purposes of transitions is Dest.x and that will be treated as the initial state (thus no transition).

    The only way I’ve found around it is to let my javascript finish and use a timer to kick off the transition:

    // create Widget
    Widget.style.left = Src.x;
    Widget.style["-webkit-transition"] = "left 0.3s ease-in-out";
    // user a timer to get the current location marked as the starting location
    // and then set the new location
    setTimeout(function() {
        Widget.style.left = Dest.x;  // trigger transition from Src.x to Dest.x
    }, 0);
    

    I say this is both a feature and a problem because it has its benefits along with its problems. If you move an object around a couple times in the middle of one piece of javascript, the object won’t transition between all those intermediate locations, it will only transition to the final location. But, it does create problems like what you’re running into.

    Edit: This post Cannot dynamically set initial element translation before transition in same call stack suggests that there is a work-around that forces a browser layout by accessing any one of a number of specific properties after you set the start position before you set the final position. I have not tried it myself.

    This work-around seems to work here in Chrome: http://jsfiddle.net/jfriend00/VqTHV/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got a directory location, how can I create all the directories? e.g. C:\Match\Upload
How can create a view with mutiple images, something similiar to the photo app
Any ideas on how i can create this app? 1) i have a page
using this mark up and script I can create drag file to desktop links
I am trying to create a resize toggle animation on this simple custom TUIScrollView
I can create a menu item in the Windows Explorer context menu by adding
I can create the following and reference it using area[0].states[0] area[0].cities[0] var area =
I can create a literal long by appending an L to the value; why
I can create a contact that is not mail enabled, but how do I
One can create an anonymous object that is initialized through constructor parameters, such as

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.