【发布时间】:2019-04-05 01:30:19
【问题描述】:
所以,我有一个硬编码的轮播,因为它有自己的风格,并且类似于 netflix 轮播,但是当我通过左右指示器移动它到达最后一项时,它就坏了,因为没有更多的项目,我想知道是否有什么我可以做的,以便在到达最后一个项目时从第一个重新开始,在图像中是发生了什么的一个例子,如果我再点击一次右边就没有更多的项目了。正如我之前问过的,有没有办法循环这些项目? 我正在使用 rails 和 jquery
此处轮播
<div id="section-events">
<span id="controlL" class="left-controls" role="button" aria-label="See Previous Modules">
<b class="fa fa-chevron-left fa-chevron-left-extra" aria-hidden="true"></b>
</span>
<div class="module-section clearfix">
<!-- <button class="btn arrow-guides fa-chevron-left"></button> -->
<ul id="content">
<% @shows.each do |show| %>
<%= render partial: "event", locals: {show: show} %>
<% end %>
</ul>
</div>
<!--end of module-section-->
<span id="controlR" class="right-controls" role="button" aria-label="See Previous Modules">
<b class="fa fa-chevron-right fa-chevron-right-extra" aria-hidden="true"></b>
</span>
<!-- <button class="btn arrow-guides-right fa-chevron-right"></button> -->
<div class="view-more-button">
<%= link_to "Show more" ,events_landing_path, class: "btn btn-outline-info" %>
</div>
Jquery 在这里
$('#controlR').click(function() {
event.preventDefault();
$('#content').animate({
marginLeft: "-=95vw"
}, "fast");
});
$('#controlL').click(function() {
event.preventDefault();
$('#content').animate({
marginLeft: "+=95vw"
}, "fast");
});
【问题讨论】: