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 8790181
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T22:35:08+00:00 2026-06-13T22:35:08+00:00

I need simple animation on simple js. I think jquery too much for that.

  • 0

I need simple animation on simple js. I think jquery too much for that. I need to increase or decrease the height of the block by pressing the buttons, but this work only on Opera (.

Example

function global_animate(element, property_to_map, duration, callback) {
   duration = duration || 1000;
   var delta = function (a) { return a; };
   var start = new Date().getTime();
   var property_from_map = {};
    var property_units_map = {};

    for (var property in property_to_map) {
        property_from_map[property] = window.getComputedStyle(element, null)[property] || element.currentStyle[property];
        property_units_map[property] = parseUnits(property_from_map[property]);
        property_from_map[property] = parseInt(property_from_map[property]);
        property_to_map[property] = parseInt(property_to_map[property]);
    }

    function parseUnits(a) {
        try {
        return a.match(/^\d+(\w{2}|%);?$/i)[1];
        } catch (e) {
        return "";
        }                   
    }

    setTimeout(function() {
    var now = (new Date().getTime()) - start;
    var progress = now / duration; 

    for (var property in property_to_map) {
        var result = (property_to_map[property] - property_from_map[property]) * delta(progress) + property_from_map[property];
        element.style[property] = result.toFixed(2) + property_units_map[property];
    }

    if (progress < 1)
        setTimeout(arguments.callee, 10);
    else
        if (typeof callback == 'function')
        callback();
    }, 10);
}
  • 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-06-13T22:35:09+00:00Added an answer on June 13, 2026 at 10:35 pm

    you need to change the regexp from

    alert("23.2px".match(/^\d+(\w{2}|%);?$/i));​ // alert null
    

    to something like this

    alert("23.2px".match(/^\d+\.*\d*(\w{2}|%);?$/i));​ // alert ["23.2px", "px"]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to do something that I thought was simple but I need
I need to understand how to create a simple animation in HTML 5 or
I need something simple like date , but in seconds since 1970 instead of
I need a simple application, preferably a cross-platform one, that enables sending of files
I need a simple proxy PHP function/script that can download a file from a
I am trying to do a very simple animation, but it is giving me
Many times I found out that I need a software to create simple educational
I have just created a simple animation. Lets say that in one frame I
I need to do a simple animation in OpenGL. I want an object to
I'm looking for a simple & semantic way to code jQuery event handlers that

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.