I have a ticketing plugin that I am working with that provides an html table of events. I want that table to appear scrollable through the events by clicking up and down arrows. Therefore, I have put the table behind a div that has the overflow hidden only showing 3 events in the div.
I then created some code that allows the top arrow and bottom arrow to add or subtract to the div element style's "top" in order to move the table up and down behind the restricted div.
The issue is the user can keep hitting the top and down arrow beyond the table's visibility. Meaning if the user hits the top arrow too many times the table essentially disappears to the user. I am hoping to achieve some JavaScript that says if the div element reaches top:0px then to disallow the top arrows click function. If the div element reaches top: -434px then it disallows the bottom arrow function.
These functions would then have to become active again once they are no longer those specific max and min values. I have created a rough codepen demonstration here: https://codepen.io/TheBrandsmen/pen/JjdEQgj
It does not have quite all the CSS and such but the general idea is there. If there is another better idea on how to make an html table scrollable please feel free to comment with that as well.
<body>
<div class="up-arrow" onclick="MoveDiv()"><img src="https://thebrandsmen.com/staging/thegrizzlyrose/wp-content/uploads/2020/02/up-arrow.png"></div>
<div class="carousel-frame">
<script>twSendEvent({'twView':'list','event':'twView'});</script><style>
</style>
<div class="tw-plugin-upcoming-event-list" id="id_1" style="top: 0px;">
<table>
<tbody><tr>
<td>
<div class="tw-event-venue-name tw-remove-when-empty">
</div>
<div class="tw-event-venue-address tw-remove-when-empty">
</div>
<div class="tw-event-prefix-text tw-remove-when-empty">
</div>
<div class="tw-event-name tw-remove-when-empty">
<a href="/?event_id=10214595">
Runaway June </a>
</div>
<ul class="tw-attraction-list tw-remove-when-empty">
</ul>
<div class="tw-event-date-time tw-remove-when-empty">
<span class="tw-event-date-complete"> <span class="tw-event-date">Feb 29</span></span>
</div>
<div class="tw-event-description tw-remove-when-empty">
</div>
<div class="tw-event-additional-text tw-remove-when-empty">
</div>
<div class="tw-event-price tw-remove-when-empty">
</div>
<div class="tw-event-links tw-remove-when-empty">
<span class="tw-event-more-info-link tw-remove-when-empty">
</span>
<span class="tw-event-ticketing-link tw-remove-when-empty">
</span>
</div>
</td>
</tr>
<tr>
<td>
<div class="tw-event-venue-name tw-remove-when-empty">
</div>
<div class="tw-event-venue-address tw-remove-when-empty">
</div>
<div class="tw-event-prefix-text tw-remove-when-empty">
</div>
<div class="tw-event-name tw-remove-when-empty">
<a href="/?event_id=9929345">
Clay Walker </a>
</div>
<ul class="tw-attraction-list tw-remove-when-empty">
</ul>
<div class="tw-event-date-time tw-remove-when-empty">
<span class="tw-event-date-complete"> <span class="tw-event-date">Mar 06</span></span>
</div>
<div class="tw-event-description tw-remove-when-empty">
</div>
<div class="tw-event-additional-text tw-remove-when-empty">
</div>
<div class="tw-event-price tw-remove-when-empty">
</div>
<div class="tw-event-links tw-remove-when-empty">
<span class="tw-event-more-info-link tw-remove-when-empty">
</span>
<span class="tw-event-ticketing-link tw-remove-when-empty">
</span>
</div>
</td>
</tr>
<tr>
<td>
<div class="tw-event-venue-name tw-remove-when-empty">
</div>
<div class="tw-event-venue-address tw-remove-when-empty">
</div>
<div class="tw-event-prefix-text tw-remove-when-empty">
</div>
<div class="tw-event-name tw-remove-when-empty">
<a href="/?event_id=9929365">
Clay Walker </a>
</div>
<ul class="tw-attraction-list tw-remove-when-empty">
</ul>
<div class="tw-event-date-time tw-remove-when-empty">
<span class="tw-event-date-complete"> <span class="tw-event-date">Mar 07</span></span>
</div>
<div class="tw-event-description tw-remove-when-empty">
</div>
<div class="tw-event-additional-text tw-remove-when-empty">
</div>
<div class="tw-event-price tw-remove-when-empty">
</div>
<div class="tw-event-links tw-remove-when-empty">
<span class="tw-event-more-info-link tw-remove-when-empty">
</span>
<span class="tw-event-ticketing-link tw-remove-when-empty">
</span>
</div>
</td>
</tr>
<tr>
<td>
<div class="tw-event-venue-name tw-remove-when-empty">
</div>
<div class="tw-event-venue-address tw-remove-when-empty">
</div>
<div class="tw-event-prefix-text tw-remove-when-empty">
</div>
<div class="tw-event-name tw-remove-when-empty">
<a href="/?event_id=10117425">
JASON BOLAND & THE STRAGGLERS </a>
</div>
<ul class="tw-attraction-list tw-remove-when-empty">
</ul>
<div class="tw-event-date-time tw-remove-when-empty">
<span class="tw-event-date-complete"> <span class="tw-event-date">Mar 13</span></span>
</div>
<div class="tw-event-description tw-remove-when-empty">
</div>
<div class="tw-event-additional-text tw-remove-when-empty">
</div>
<div class="tw-event-price tw-remove-when-empty">
</div>
<div class="tw-event-links tw-remove-when-empty">
<span class="tw-event-more-info-link tw-remove-when-empty">
</span>
<span class="tw-event-ticketing-link tw-remove-when-empty">
</span>
</div>
</td>
</tr>
<tr>
<td>
<div class="tw-event-venue-name tw-remove-when-empty">
</div>
<div class="tw-event-venue-address tw-remove-when-empty">
</div>
<div class="tw-event-prefix-text tw-remove-when-empty">
</div>
<div class="tw-event-name tw-remove-when-empty">
<a href="/?event_id=10356305">
Jerrod Niemann </a>
</div>
<ul class="tw-attraction-list tw-remove-when-empty">
</ul>
<div class="tw-event-date-time tw-remove-when-empty">
<span class="tw-event-date-complete"> <span class="tw-event-date">Mar 20</span></span>
</div>
<div class="tw-event-description tw-remove-when-empty">
</div>
<div class="tw-event-additional-text tw-remove-when-empty">
</div>
<div class="tw-event-price tw-remove-when-empty">
</div>
<div class="tw-event-links tw-remove-when-empty">
<span class="tw-event-more-info-link tw-remove-when-empty">
</span>
<span class="tw-event-ticketing-link tw-remove-when-empty">
</span>
</div>
</td>
</tr>
<tr>
<td>
<div class="tw-event-venue-name tw-remove-when-empty">
</div>
<div class="tw-event-venue-address tw-remove-when-empty">
</div>
<div class="tw-event-prefix-text tw-remove-when-empty">
</div>
<div class="tw-event-name tw-remove-when-empty">
<a href="/?event_id=10367135">
Josh Gracin </a>
</div>
<ul class="tw-attraction-list tw-remove-when-empty">
</ul>
<div class="tw-event-date-time tw-remove-when-empty">
<span class="tw-event-date-complete"> <span class="tw-event-date">Mar 27</span></span>
</div>
<div class="tw-event-description tw-remove-when-empty">
</div>
<div class="tw-event-additional-text tw-remove-when-empty">
</div>
<div class="tw-event-price tw-remove-when-empty">
</div>
<div class="tw-event-links tw-remove-when-empty">
<span class="tw-event-more-info-link tw-remove-when-empty">
</span>
<span class="tw-event-ticketing-link tw-remove-when-empty">
</span>
</div>
</td>
</tr>
<tr>
<td>
<div class="tw-event-venue-name tw-remove-when-empty">
</div>
<div class="tw-event-venue-address tw-remove-when-empty">
</div>
<div class="tw-event-prefix-text tw-remove-when-empty">
</div>
<div class="tw-event-name tw-remove-when-empty">
<a href="/?event_id=10188845">
Aaron Lewis </a>
</div>
<ul class="tw-attraction-list tw-remove-when-empty">
</ul>
<div class="tw-event-date-time tw-remove-when-empty">
<span class="tw-event-date-complete"> <span class="tw-event-date">Mar 28</span></span>
</div>
<div class="tw-event-description tw-remove-when-empty">
</div>
<div class="tw-event-additional-text tw-remove-when-empty">
</div>
<div class="tw-event-price tw-remove-when-empty">
</div>
<div class="tw-event-links tw-remove-when-empty">
<span class="tw-event-more-info-link tw-remove-when-empty">
</span>
<span class="tw-event-ticketing-link tw-remove-when-empty">
</span>
</div>
</td>
</tr>
<tr>
<td>
<div class="tw-event-venue-name tw-remove-when-empty">
</div>
<div class="tw-event-venue-address tw-remove-when-empty">
</div>
<div class="tw-event-prefix-text tw-remove-when-empty">
</div>
<div class="tw-event-name tw-remove-when-empty">
<a href="/?event_id=10218455">
COPPER CHIEF </a>
</div>
<ul class="tw-attraction-list tw-remove-when-empty">
</ul>
<div class="tw-event-date-time tw-remove-when-empty">
<span class="tw-event-date-complete"> <span class="tw-event-date">Apr 03</span></span>
</div>
<div class="tw-event-description tw-remove-when-empty">
</div>
<div class="tw-event-additional-text tw-remove-when-empty">
</div>
<div class="tw-event-price tw-remove-when-empty">
</div>
<div class="tw-event-links tw-remove-when-empty">
<span class="tw-event-more-info-link tw-remove-when-empty">
</span>
<span class="tw-event-ticketing-link tw-remove-when-empty">
</span>
</div>
</td>
</tr>
<tr>
<td>
<div class="tw-event-venue-name tw-remove-when-empty">
</div>
<div class="tw-event-venue-address tw-remove-when-empty">
</div>
<div class="tw-event-prefix-text tw-remove-when-empty">
</div>
<div class="tw-event-name tw-remove-when-empty">
<a href="/?event_id=9993135">
106.7 The Bull Birthday Bash with Michael Ray and Carly Pearce </a>
</div>
<ul class="tw-attraction-list tw-remove-when-empty">
</ul>
<div class="tw-event-date-time tw-remove-when-empty">
<span class="tw-event-date-complete"> <span class="tw-event-date">Apr 08</span></span>
</div>
<div class="tw-event-description tw-remove-when-empty">
</div>
<div class="tw-event-additional-text tw-remove-when-empty">
</div>
<div class="tw-event-price tw-remove-when-empty">
</div>
<div class="tw-event-links tw-remove-when-empty">
<span class="tw-event-more-info-link tw-remove-when-empty">
</span>
<span class="tw-event-ticketing-link tw-remove-when-empty">
</span>
</div>
</td>
</tr>
<tr>
<td>
<div class="tw-event-venue-name tw-remove-when-empty">
</div>
<div class="tw-event-venue-address tw-remove-when-empty">
</div>
<div class="tw-event-prefix-text tw-remove-when-empty">
</div>
<div class="tw-event-name tw-remove-when-empty">
<a href="/?event_id=10376005">
RAYNE JOHNSON </a>
</div>
<ul class="tw-attraction-list tw-remove-when-empty">
</ul>
<div class="tw-event-date-time tw-remove-when-empty">
<span class="tw-event-date-complete"> <span class="tw-event-date">Apr 17</span></span>
</div>
<div class="tw-event-description tw-remove-when-empty">
</div>
<div class="tw-event-additional-text tw-remove-when-empty">
</div>
<div class="tw-event-price tw-remove-when-empty">
</div>
<div class="tw-event-links tw-remove-when-empty">
<span class="tw-event-more-info-link tw-remove-when-empty">
</span>
<span class="tw-event-ticketing-link tw-remove-when-empty">
</span>
</div>
</td>
</tr>
</tbody></table>
</div>
<style>
.tw-paginate {
text-align: center;
position: relative;
width: 100%;
}
</style>
<div class="tw-paginate">
<span class="tw-paginate-text">
<span class="previous">« Previous</span>
<span class="seperator">|</span>
<span class="lead">Page:</span>
<span class="current">1</span>
<span class="link"><a href="?twpage=1">2</a></span>
<span class="seperator">|</span>
<span class="next"><a href="?twpage=1">Next »</a></span>
</span>
</div>
</div>
<div class="down-arrow" onclick="DownDiv()"><img src="https://thebrandsmen.com/staging/thegrizzlyrose/wp-content/uploads/2020/02/Down-Arrow.png"></div>
</body>
body {
background: gray;
}
.slider-flex-2 tr:nth-child(odd), .slider-flex-2 .pricing-table>li:nth-child(odd), .slider-flex-2 .pricing-extra {
background: transparent !important;
}
.main_color tr:nth-child(even) {
background: transparent !important;
}
.slider-flex-2 table {
background: transparent !important;
}
.slider-flex-2 tr th:first-child, .slider-flex-2 tr td:first-child {
border: none;
}
.slider-flex-2 td {
display: flex;
justify-content: center;
}
td {
display: flex;
}
.slider-flex-2 .tw-paginate {
display: none;
}
.slider-flex-2 .tw-plugin-upcoming-event-list a {
color: #ffffff;
}
span.tw-event-date {
font-size: 24px;
font-family: Roboto;
font-weight: bold;
}
span.tw-event-date:before {
content: "-";
padding-right: 10px;
}
.tw-event-name.tw-remove-when-empty {
max-width: 20vw;
overflow: hidden;
display: inline-block;
text-overflow: ellipsis;
white-space: nowrap;
font-size: 24px;
font-family: Roboto;
font-weight: bold;
color: #ffffff;
text-transform: uppercase;
}
.move-up {
margin-top: -47px;
transition: 1s;
font-size: 40px;
}
.move-down {
margin-top: 47px;
transition: 1s;
font-size: 40px;
}
.carousel-frame {
height: 185px;
overflow: hidden;
}
.tw-plugin-upcoming-event-list {
position: relative;
top:0px;
}
.tw-plugin-upcoming-event-list td {
padding: 16px 12px;
}
.tw-plugin-upcoming-event-list span.tw-event-date {
white-space: nowrap;
}
.tw-plugin-upcoming-event-list td {
border-bottom: 1px solid #ffffff !important;
}
#tw-plugin-upcoming-event-list {
position: relative;
top:0px;
}
.up-arrow {
margin-bottom: 20px;
max-width: 20vw;
}
.up-arrow img {
margin: auto;
display: block;
}
.down-arrow {
margin-top: 20px;
max-width: 20vw;
}
.down-arrow img {
margin: auto;
display: block;
}
$( document ).ready(function() {
$(".tw-plugin-upcoming-event-list").css("top","0");
});
$(function(){
$('.tw-plugin-upcoming-event-list').attr('id',function(i){
return 'id_'+(i+1);
});
});
function DownDiv()
{
div = document.getElementById("id_1");
div.style.top = parseInt(div.style.top) - 62 + "px";
}
function MoveDiv()
{
div = document.getElementById("id_1");
div.style.top = parseInt(div.style.top) + 62 + "px";
}