$(document).on('click', '.tabs li a', function(e) {
e.preventDefault();
// select clicked tab
$(this).parents('li').addClass('current')
.siblings('li').removeClass('current');
// draw the line
var $start = $('#paas_tabs li.current');
var $stop = $('#paas_tabs2 li.current');
var pos = $start.offset();
var height = $start.height();
var width = $start.width();
var left = $('#paas_tabs').position().left;
var start = {
'left': pos.left + width / 2,
'top': pos.top + height
};
var $path = $('#path-line');
var ml = start.left;
var v = ($stop.position().top - start.top) / 2;
var h = $stop.position().left - pos.left;
var newD = 'm ' + ml + ',0 v ' + v + ' h ' + h + ' v ' + v;
//console.log(pos.left);
//console.log(start);
//console.log(v);
//console.log(h);
//console.log(left);
//console.log(start.top);
//console.log(newD);
$('#svg-line').css({
'left': left,
'top': start.top
});
//$path.attr('d', newD);
// animate the awesome!
// http://jakearchibald.com/2013/animated-line-drawing-svg/
animate({'rewind': true});
$path.attr('d', newD);
//animate({'rewind': false});
function animate() {
var path = $path.get(0);
var length = path.getTotalLength();
console.log(length);
// Clear any previous transition
path.style.transition = path.style.WebkitTransition = 'none';
// Set up the starting positions
var animateLength = length - v;
path.style.strokeDasharray = animateLength + ' ' + animateLength;
console.log(path.style.strokeDasharray);
path.style.strokeDashoffset = length;
// Trigger a layout so styles are calculated & the browser
// picks up the starting position before animating
path.getBoundingClientRect();
// Define our transition
...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.