Skip to content

Instantly share code, notes, and snippets.

@temberature
Created May 28, 2018 03:40
Show Gist options
  • Save temberature/e1d8ad642e3d82b58ae2f0ffc7a7bdfe to your computer and use it in GitHub Desktop.
Save temberature/e1d8ad642e3d82b58ae2f0ffc7a7bdfe to your computer and use it in GitHub Desktop.
initMarquee: function (speed) {
var me = this;
var $marquee = $('.m-marquee');
$marquee.show();
var $container = $marquee.find('.container');
var $firstMsg = $marquee.find('.message').eq(0);
if (!$container.length) {
return;
}
var startPos = parseFloat($marquee.css('width')) - parseFloat($firstMsg.css('padding-left'));
var width = $container.css('width');
var duration = (parseFloat(width)) / speed;
$container
.css({
transform: 'translate(' + startPos + 'px)'
});
setTimeout(function () {
$container
.css({
transition: duration + 's linear',
transform: 'translate(-' + width + ')'
});
}, 10);
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment