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

  • Home
  • SEARCH
  • 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 6936685
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T12:15:57+00:00 2026-05-27T12:15:57+00:00

I want to use some animation in my page,so I google "javascript animation",I found

  • 0

I want to use some animation in my page,so I google "javascript animation",I found this wonderful tutorial:

The JavaScript animation is implemented as gradual changing of DOM element styles or canvas objects.

The whole process is split into pieces, and each piece is called by
timer. Because the timer interval is very small, the animation looks
continuous.

So it seems that the dom animation is implemented by set the size of the element step by step.

This is the The generic animation provided by the tutorial:

function animate(opts) {
  
  var start = new Date   

  var id = setInterval(function() {
    var timePassed = new Date - start
    var progress = timePassed / opts.duration

    if (progress > 1) progress = 1
    
    var delta = opts.delta(progress)
    opts.step(delta)
    
    if (progress == 1) {
      clearInterval(id)
    }
  }, opts.delay || 10)
  
}

However I found that if an element in the page does not have the "width or height" property in its "style" property. How can we use them??

Now,suppose I have an element in the page with id "tip_info" who does not show at first,when I click an button,I want it opend with the animation.

<div id="wrapper" sytle="display:none">the content</div>
<input type="button" onclick="animate()" value="open"/>

Now,I try to use the generic animation:

var ele=document.getElementById('wrapper');

animate({
    delay: 10,
    duration: duration || 1000, // 1 sec by default
    delta: delta,
    step: function(delta) {
      ele.style.width= The_Final_Width*delta + "px";
      ele.style.height= The_Final_Height*delta + "px"    
    }
  });

But how can I know the "The_Final_Width" and "The_Final_Height" value???

Its width and height should be changed according to the content inner the element.

Even when the animation complete,normally,the element does not need the "width" and "height" attrubutes,it just need the "display=’block’".

So does it mean that an element want to be animated must have the explict size?

  • 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-27T12:15:58+00:00Added an answer on May 27, 2026 at 12:15 pm

    I would do it in three steps:

    • Use a jQuery function or a custom function to quickly display:block the div, get its size (width/height), and display:none again. It would be so fast that a human eye can’t see it.
    • Animate with the width/height I got previously
    • At the end of the animation, I would set width/height to auto or initial. So if you add some content in it, it will increase its size automatically.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I m creating a game, in that i want to use some animation, but
I want to use some animation on my links, while preserving the RESTful routes
I can use follow css code to do some simple animation, but I want
i want use some data from a website with web service. i have a
I want to use some Python libraries to replace MATLAB. How could I import
I want to use some thing unique for a licensing system. i decided to
I want to use some NSAssert stuff and other things to enable better debugging
I want to use some kind of trigger to change a button in my
I want to use some basic struct in C like the following: struct p
I want to use some features of python like as Tuples and Sets in

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.