jquery - Dyamic line animation -


i'm having bit of trouble making animated line appear drawn 1 element another.

here's i'm trying achieve:

proof of concept

when user clicks on button, line appear "drawn" out, starting div , ending on button has been pressed.

i attempted achieve using svg's, positioned absolutely within elements, using stroke-dashoffset hack make them being drawn in, couldn't dynamically alter middle svg line using jquery.

so, think? using svg's lines bad idea? or not on right path this?

the lines have connect multiple different buttons same starting point (the div), , whole thing has work responsively well... make little more difficult.

any suggestions?

this question intrigued me. in regular day job, tend approach problems in 3 step process:

1) make work 2) clean 3) make perform

the result of step 1 @ fiddle: http://jsfiddle.net/gl96uklx/2/

it uses css , jquery perform lines , animation requested.

highlights are:

  • css transition used handle animation
  • heavy reliance on jquery offset position of elements
  • timing tricky because user can click madly make things misbehave
  • perhaps better disable buttons prevent further clicks until animation complete
  • an additional class of "showing" used alert css animate transitions
  • thin divs used vertical lines, short div used horizontal line

here meat of result:

vert1     .addclass('showing')     .css(     {   height: vertheight,         top: vertline1top,         left: vertline1left     });     horz         .addclass('showing')         .css(         {   width: horzwidth,             left: vertline1left,             top: (vertline1top + vertheight)         });     vert2         .addclass('showing')         .css(         {   height: vertheight,             left: vertline2left,             top: (vertline1top + vertheight)         }); 

i set position , length/width of each of 3 divs: vert1, vert2, , horz. css transition animate change of size in second. present first vertical line no delay, horizontal line 1 second delay (the time takes first vertical line draw), , second vertical line 2 second delay (the time takes both first vertical line , horizontal line draw).

please note! quick , dirty proof of concept show result can achieved jquery , css. may or may not suitable personal need. haven't thought step 2 in process. :p

good luck!


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -