Created
May 28, 2018 03:40
-
-
Save temberature/e1d8ad642e3d82b58ae2f0ffc7a7bdfe to your computer and use it in GitHub Desktop.
This file contains 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
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