jQuery animate CSS transform
See also http://stackoverflow.com/a/21815901/490560
HTML
<div id="test">
<label id="in">
<input type="text" class="inp" placeholder="Введите текст">
<button class="button button-grey js-pick-value">Добавить</button>
</label>
<div class="speed">
<p>Скорость строки</p>
<button id="plus">+</button>
<input id="fixValue" type="number" value="10" align="center">
<button id="minus">-</button>
</div>
<label>
<input type="checkbox" value="1" id="check"> Циклично?
</label>
<div class="container-run">
<h1 class="marquee"><span></span></h1>
</div>
<button id="stop">Стоп</button>
</div>
CSS
@-webkit-keyframes scroll {
0% {
-webkit-transform: translate(0, 0);
transform: translate(0, 0);
}
100% {
-webkit-transform: translate(-100%, 0);
transform: translate(-100%, 0)
}
}
@-moz-keyframes scroll {
0% {
-moz-transform: translate(0, 0);
transform: translate(0, 0);
}
100% {
-moz-transform: translate(-100%, 0);
transform: translate(-100%, 0)
}
}
@keyframes scroll {
0% {
transform: translate(0, 0);
}
100% {
transform: translate(-100%, 0)
}
}
.marquee {
border: 1px solid hotpink;
display: block;
width: 500px;
white-space: nowrap;
overflow: hidden;
}
.marquee span {
display: inline-block;
padding-left: 100%;
-webkit-animation: scroll 1s infinite linear;
-moz-animation: scroll 1s infinite linear;
animation: scroll 5s infinite linear;
}
JavaScript
$(document).ready(function(){
$('.js-pick-value').on('click', function () {
var inText = $('.inp').val();
$('.marquee span').text(inText)
})
});