JSFiddle - React, Tailwind, and code Playground

by shanabus

HTML

<!DOCTYPE html>  
<html>      
    <head>      
        <title>Sample Page</title>           
        <link rel="stylesheet" href="http://code.jquery.com/mobile/1.0/jquery.mobile-1.0.min.css" />    
        <script type="text/javascript" src="http://code.jquery.com/jquery-1.6.4.min.js"></script>        
        <script type="text/javascript" src="http://code.jquery.com/mobile/1.0/jquery.mobile-1.0.min.js"></script> 
    </head>   
    <body>              
        <div data-role="page" id="page1">      
            <div data-role="header">         
                <h1>
                    Page 1
                </h1>     
            </div><!-- /header -->      
            
            <div data-role="content">                
                <br />
                <ul data-role="listview" id="resultListView">
                    <li>Item 1</li>
                    <li>Thing 2</li>
                    <li>What next 3</li>
                    <li>Another item 4</li>
                    <li>Item 5</li>
                    <li>Thing 6</li>
                    <li>What next 7</li>
                    <li>Another item 8</li>
                </ul>
            </div><!-- /content -->      
            
            <div data-role="footer">              
            </div> 
        </div><!-- /page -->      
        
        <div data-role="page" id="page2">         
            <div data-role="header">    
               <h1>
                  Page 2
                </h1>     
            </div><!-- /header -->         
            
            <div data-role="content">         
            </div><!-- /content -->         
            
            <div data-role="footer">         
            </div><!-- /fotoer -->     
            
        </div><!-- /page --> 

    </body>
</html>

JavaScript

$(document).ready(function(){

    var eventsElement = $('#resultListView');
    $(window).bind('scrollstart', function () {        
        $('.ui-body-c').css('background', 'green');
        if (isAtBottom()){
         console.log("at bottom");   
         eventsElement.append('<li><a href="">Start</a></li>');
         eventsElement.listview('refresh');
        }
    });

    $(window).bind('scrollstop', function () {        
       $('.ui-body-c').css('background', 'red');
       //eventsElement.append('<li><a href="">Stop</a></li>');
       //eventsElement.listview('refresh');
    });
    
});

function isAtBottom(){
  
  var totalHeight, currentScroll, visibleHeight;
  
  if (document.documentElement.scrollTop)
    { currentScroll = document.documentElement.scrollTop; }
  else
    { currentScroll = document.body.scrollTop; }
  
  totalHeight = document.body.offsetHeight;
  visibleHeight = document.documentElement.clientHeight;
  
 console.log(
    'total height: ' + totalHeight + ' ' +
    'visibleHeight : ' + visibleHeight + ' ' +
    'currentScroll:' + currentScroll);
  return (totalHeight <= currentScroll + visibleHeight )
}