Я бы хотел прокрутить несколько div в одно и то же время.Прокрутка нескольких элементов/DIVs
У меня есть то, что работает, но это не производительное на медленных машины (мобильные особенно)
<!-- HTML -->
<div class="container">
<div class="row">
<div class="scroller">
<div>some really long content that just keeps going on and on and on and on and on and on and on and on and on and on and on and on and on</div>
</div>
</div>
<div class="row">
<div class="scroller">
<div>some really long content that just keeps going on and on and on and on and on and on and on and on and on and on and on and on and on</div>
</div>
</div>
<div class="row">
<div class="scroller">
<div>some really long content that just keeps going on and on and on and on and on and on and on and on and on and on and on and on and on</div>
</div>
</div>
<div class="row">
<div class="scroller">
<div>some really long content that just keeps going on and on and on and on and on and on and on and on and on and on and on and on and on</div>
</div>
</div>
<div class="row">
<div class="scroller">
<div>some really long content that just keeps going on and on and on and on and on and on and on and on and on and on and on and on and on</div>
</div>
</div>
</div>
<style>
/* CSS */
.container { width:300px; }
.scroller { width:100%; height:40px; padding:0 0 16px; line-height:40px; overflow-x:auto; overflow-y:hidden; white-space:nowrap; }
</style>
<script>
// jQuery
$(".scroller").scroll(function(){
$(".scroller").scrollLeft($(this).scrollLeft());
});
</script>
Я могу видеть, что whevever прокручивает элемент, что она прокручивается другой элементы того же класса, но поскольку я установил «слушатель» прокрутки в этом классе, функция снова срабатывает для каждого из других элементов, поскольку они прокручиваются с помощью метода scrollLeft.
Есть ли у кого-нибудь идеи, как я могу это улучшить?
Таким образом, только для уточнения: поведение прокрутки, все прокрутки в то же время предназначено, и это всего лишь производительность? – Markai
Правильно @ Маркай. – RussAtkins
И должны ли они быть обновлены в реальном времени, то есть когда перемещается полоса прокрутки или она достаточно, чтобы переместить их в конце прокрутки? – Markai