css - Jquery Hide Vertical scroll button when no more list items -
i need hide next button once items have been displayed.
here full example in http://jsfiddle.net/afnguyen/dpfvq/
and here script trying use:
<script type="text/javascript"> $(document).ready(function () { $('.prev').css('visibility', 'hidden'); $(document).on("click", ".next", function () { $('.prev').css('visibility', 'visible'); //.onebysix li .w6392597 or height - whatever want scroll height of var scrollval = $('.onebysix li').height(); var currentscrollval = $('.onebysixmiddle').scrolltop(); $('.onebysixmiddle').scrolltop(scrollval + currentscrollval); var maxheight = $('.onebysixmiddle .items').height(); if (currentscrollval >= maxheight) { //hide next button $('.next').css('visibility', 'hidden'); } }); $(document).on("click", ".prev", function () { $('.next').css('visibility', 'visible'); var scrollval = $('.onebysix li').height(); var currentscrollval = parseint($('.onebysixmiddle').scrolltop()); $('.onebysixmiddle').scrolltop(currentscrollval - scrollval); if (currentscrollval == 0) { //hide next button $('.prev').css('visibility', 'hidden'); } }); }); </script>
the hide previous works fine:
if (currentscrollval == 0) { //hide next button $('.prev').css('visibility', 'hidden'); }
but m struggling know should put hide next. responsive design making bit harder.
at moment when items have been displayed won t scroll further need hide button aswel.
any appreciated!
change max_height
var maxheight = $('.onebysixmiddle .items').height();
to
var maxheight = $('.onebysixmiddle .items').height() - $('.onebysixmiddle').height();
like fiddle example
also change
if (currentscrollval == 0) { //hide next button $('.prev').css('visibility', 'hidden'); }
to
if (currentscrollval - scrollval == 0) { //hide next button $('.prev').css('visibility', 'hidden'); }
and
if (currentscrollval >= maxheight) { //hide next button $('.next').css('visibility', 'hidden'); }
to
if ((currentscrollval + scrollval) >= maxheight) { //hide next button $('.next').css('visibility', 'hidden'); }
if want arrows disappear when last page rather having click them again when on last page
Comments
Post a Comment