Jump to content


Draw an oblique line with TweenMaxJS

Recommended Posts

Hi everybody,


for a personal project I would like to build an oblique progress bar.


So, my first question is: Is there a way to create dynamically and easily a Line object with Tweenmax.js?


For the moment I just resize the width of a rectangle shape like this : http://jsfiddle.net/FracArt/6GJ67/2/

Which actually works! But seems a bit "hacky".


Second question, as you can notice on the jsfiddle file I tried to build an oblique progress bar on the same principle. However, when I rotate the rectangle a gap appears between the initial and final position of the bar.

So do you have an idea of how I can correct that without doing some geometry calculations?

(maybe a transform-origin property on the css?)

Link to comment
Share on other sites

Hi and welcome to the forums,


One way would be to rotate the element and scale it down with a TweenMax.set and then scale it back to 1, like this:

var obliqBar = document.getElementById("progBar"),
    tl1 = new TimelineMax();

TweenMax.set(obliqBar, {rotation:25, scaleX:.001, transformOrigin:'0% 50%'});

tl1.to(obliqBar, 0.5, {scaleX:1});

I've updated your fiddle so you can see it working:



Hope this helps,



  • Like 2
Link to comment
Share on other sites

That did the trick! Thanks a lot for you answer and update rhernando.


So I assume there is no current solution for drawing a line easily with this library ?

Link to comment
Share on other sites

Hi Carl, first of all thank you for this great javascript library  :)


In the past I used the flash version of this tool and its method LineTo(). However, in view of your last comment, I now understand why I can't find an equivalence with the JS version.



Problem solved.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.