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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T06:12:43+00:00 2026-05-18T06:12:43+00:00

I have a image which i would like to animate on my web page.

  • 0

I have a image which i would like to animate on my web page.

Currently i am using a gif.

http://dev.thepenline.com/TEMP/Hol_10_swingingBell.gif

I would like to have more control on its animation, which js lib/framework would be best to help me out?

Should i use canvas or SVG?
Which (small) library is best to use?

I happen to know a little raphael.js
But i am not sure how to get this effect done.

  • 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-18T06:12:44+00:00Added an answer on May 18, 2026 at 6:12 am

    I’ve done something with SVG that’s close to what you’re trying to achieve: http://live.echo-flow.com/stackoverflow/clock.svg

    In case I ever take the example down, here’s the relevant code.

    clock.svg:

    <?xml version="1.0"?>
    <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="100%" height="100%" viewBox="0 0 100 100">
    
    <rect x="0" y="0" height="100" width="100" fill="none" stroke="blue" id="border"/>
    
    <script type="text/ecmascript" xlink:href="clock.js"></script>
    
    </svg>
    

    clock.js:

    var svgRoot = document.documentElement;
    var svgNS = "http://www.w3.org/2000/svg";
    
    var ident = svgRoot.createSVGMatrix();
    
    function Pendulum(thetaZero,period,tempo,fillColor){
    
            //sensible default values
            thetaZero = thetaZero || 0;
            period = period || 20;
            tempo = tempo || 20;
            fillColor = fillColor || "red";
    
            if(fillColor == "randomize"){
                    fillColor = "rgb(" + Math.random() * 254 +
                                    "," + Math.random() * 254 +
                                    "," + Math.random() * 254 + ")";
            }
    
            //construct his representation in DOM
            var g = document.createElementNS(svgNS,"g");
            g.setAttributeNS(null,"transform","translate(50,20) rotate(" + thetaZero + ")");
    
            var rotateTransform = g.transform.baseVal.getItem(1);
    
            var path = document.createElementNS(svgNS,"line");
            path.setAttributeNS(null,"x1",0);
            path.setAttributeNS(null,"y1",0);
            path.setAttributeNS(null,"x2",0);
            path.setAttributeNS(null,"y2",40);
            path.setAttributeNS(null,"stroke","black");
    
            var c = document.createElementNS(svgNS,"circle");
            var styleString = "fill:" +fillColor;
            //console.log(styleString);
            c.setAttributeNS(null,"cx",0);
            c.setAttributeNS(null,"cy",50);
            c.setAttributeNS(null,"r",10);
            c.setAttributeNS(null,"style",styleString);
            c.setAttributeNS(null,"stroke","black");
            c.setAttributeNS(null,"opacity",.5);
            g.appendChild(path);
            g.appendChild(c);
    
            svgRoot.appendChild(g);
    
            this.node=g;
    
            //timeout
    
            var timeStep = 10; //in milliseconds
            var timeCount = 0;
            var _animateTimeStep = function(){
                    timeCount++;
    
                    var adjustedTimeCount = timeCount/tempo;
    
                    //compute theta
                    //theta(t) = period * sin(t + thetaZero)
                    var theta = period * Math.sin(adjustedTimeCount  + thetaZero);
    
                    //set his current rotate transformation to the new theta
                    rotateTransform.setMatrix(ident.rotate(theta));
            }
    
            var timerId = null;
    
            //method definitions
            this.go=function(){
                    timerId = window.setInterval(_animateTimeStep,timeStep);
            };
    
            this.stop=function(){
                    window.clearInterval(timerId);
            };
    }
    
    
    //Pendulum(thetaZero,period,tempo,fillColor)
    var p1 = new Pendulum(-10,20,40,"red");
    p1.go();
    
    var p2 = new Pendulum(20,20,40,"yellow");
    p2.go();
    
    var p3 = new Pendulum(-20,20,40,"blue");
    p3.go();
    
    var p4 = new Pendulum(10,20,40,"purple");
    p4.go();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an array of integers which represent a RGB image and would like
I have a mainly transparent image which I would like to add as an
I have three text blocks and an image which I would like to to
I have a div which contains a number of images. I would like to
I have a greyscale image which was created from a RGB image using farmula:
I have a nested form in which I would like the form fields to
I have an image which is actually 393 x 21 px, which I would
I have an animated .GIF image that I created with http://ajaxload.info/ and some editing.
I have an ASP.Net application which as desired feature, users would like to be
I have some product photos, from which I would like to remove the white

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.