Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>arrived demo</title>
  <link rel="stylesheet" href="//code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css">
  <script src="//code.jquery.com/jquery-1.10.2.min.js"></script>
  <script src="//code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
  <style>
    
    td {        
        vertical-align: middle;
    }
    tr td:first-child {
        width: 500px; 
        padding: 20px;
    }    
    .box {
      width: 200px;
      height: 100%;    
    }
    .arrivalIndicator{
      position:relative;
      background: #e1e1e1;
      display:inline-block;
      overflow:hidden;
      cursor:pointer;
    }
    .arrivalIndicator:before{
      content:'';
      position:absolute;
      top:0;left:50%;
      width:0;
      height:100%;
      background:green;
      z-index:-1;
      -webkit-transition: left 1.05s, width 1.05s, .6s -webkit-transform .2s; 
      -ms-transition: left 1.05s, width 1.05s, .6s -ms-transform .2s; 
      transition: left 1.05s, width 1.05s, .6s transform .2s;
    }
    .fillGreen:before{
      width:100%;
      left: 0%;
      background:green;
      z-index:10;
    }
    .fillGray:before{
      width:100%;
      left: 0%;
      background:#e1e1e1;
      z-index:10;
    }
    .arrived {
        background: green;
    }
  </style>
</head>
<body>
  <div data-role="page" id="page1">
     <div data-role="header">
        <h1>My page</h1> 
    </div>  
    <div role="main" class="ui-content">
      <table>
          <tr>
              <td>Person's name</td>
            <td id="t1" class="box arrivalIndicator"></div></td>
          </tr>
          <tr>
              <td>Someone elses name</td>
              <td class="box arrivalIndicator"></td>
          </tr>
      </table>
    </div> 
</div>  
<script>
    var tapTime = 0;
  
  $(document).on("pagecreate","#page1", function(){ 
  
      $('.arrivalIndicator').on('vmousedown vmouseup', function (event) {
        if (event.type == 'vmousedown') {
            tapTime = new Date().getTime();
            if($(this).hasClass('arrived')){
                $(this).addClass('fillGray');
            } else {
                //if not arrived
                $(this).addClass('fillGreen');
            }
        } else {
            //event.type == 'vmouseup'
            //here you can check how long the `tap` was to determine what do do
            var duration = (new Date().getTime() - tapTime);
            if (duration > 1000) {
                //this is a tap-hold
                if($(this).hasClass('arrived')){
                    //if already marked as arrived
                    $(this).removeClass('arrived');
                } else {
                    $(this).addClass('arrived');
                }   
                localStorage.setItem('t1','Y');
            } 
          //this is a tap
          $(this).removeClass('fillGray');
          $(this).removeClass('fillGreen');
        }        
        
      });
  
  });
  
</script>
</body>
</html>
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
ezankerpro
0viewers