Created
November 28, 2016 14:22
-
-
Save sanex3339/7917c094a0175787dba1152ae5db3738 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function setTimelinePointsPosition () { | |
$('.timeline-item:odd').each((id, element) => { | |
var $element = $(element); | |
var $prevOdd = $element.prev(); | |
var $point = $element.find('.timeline-point'); | |
var $arrow = $element.find('.timeline-arrow'); | |
var $prevPoint = $prevOdd.find('.timeline-point'); | |
var offsetDiff = $point.offset().top - $prevPoint.offset().top; | |
if (offsetDiff < 24) { | |
var additionalSpace = 6; | |
var pointMarginTop = parseInt($point.css('margin-top')); | |
var arrowTop = parseInt($arrow.css('top')); | |
$point.css({ | |
'margin-top': (pointMarginTop + additionalSpace + (24 - offsetDiff)) + 'px' | |
}); | |
$arrow.css({ | |
'top': (arrowTop + additionalSpace + (24 - offsetDiff)) + 'px' | |
}); | |
} | |
}); | |
} | |
$(window).on('load resize orientationchange', () => { | |
setTimelinePointsPosition(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment