title: HTML tabs drag-drop slider sample?
body: <p>What I need is a simple tab system such that if you <code>mouseDown</code> on its contents you do not select html text but start sliding tab. If you slide more than half it assumes you slid to next tab. How to do such thing with jQuery?</p>
  
  <p><em><strong>Update:</em></strong>
  Sample code:</p>
  
  <p><em>JS:</em></p>
  
  <pre><code>var $tabs = $('.tab');
  var $contents = $('.content');
  
  var contentWidth = $contents.eq(0).outerWidth(true);
  var $slider;
  
  var DURATION = 600;
  var EASING_METHOD = 'easeInOutCubic';
  
  
  $tabs.data('currentTabId', 1);
  
  
  $slider = $contents.wrapAll('&lt;div /&gt;').parent();
  $slider.css({ 'width' : contentWidth * $contents.length,
                'marginLeft' : 0 });
  
  
  
  function calcMargin(distance) {
    var margin = parseInt($slider.css('marginLeft').replace('px', ''), 10);
    return margin + contentWidth * distance * -1;
  }
  
  
  function changeTab(tabId) {
    var distance;
  
  
    if($tabs.data('currentTabId') !== tabId) {
  
      distance = tabId - $tabs.data('currentTabId');
  
  
      $slider.stop(true, true);  
      $slider.animate(
        { 'marginLeft' : calcMargin(distance) },
        { duration : DURATION, easing : EASING_METHOD }
      );
  
  
      $tabs.data('currentTabId', tabId);    
      $tabs.removeClass('current');
      $tabs.filter('#tab' + tabId).addClass('current');
    }
  }
  
  
  
  $tabs.click(function() {
    changeTab($(this).attr('id').slice(3));
  });
  </code></pre>
  
  <p><em>HTML:</em></p>
  
  <pre><code>&lt;div class='tabs'&gt;
    &lt;div class='tab current' id='tab1'&gt;tab1&lt;/div&gt;
    &lt;div class='tab' id='tab2'&gt;tab2&lt;/div&gt;
    &lt;div class='tab' id='tab3'&gt;tab3&lt;/div&gt;
  &lt;/div&gt;
  
  &lt;div class='contents'&gt;
  &lt;div class='content' id='content1'&gt;
    &lt;div class='inner'&gt;
      content1
    &lt;/div&gt;
  &lt;/div&gt;
  
  &lt;div class='content' id='content2'&gt;
    &lt;div class='inner'&gt;
      content2
    &lt;/div&gt;
  &lt;/div&gt;
  
  &lt;div class='content' id='content3'&gt;
    &lt;div class='inner'&gt;
      content3
    &lt;/div&gt;
  &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p><em>CSS:</em></p>
  
  <pre><code>body {
    margin: 0;
    padding: 20px;
    font-family: sans-serif;
  }
  
  .tabs {
  }
  
  .tab {
    display: inline-block;
    padding: 10px 30px;
    border: 1px solid #333;
    border-bottom: none;
    border-radius: 15px 10px 0 0;
    margin: 0 5px;
    cursor: pointer;
  }
  
  .tab.current {
    background: #90bfff;
  }
  
  .contents {
    overflow: hidden;
    width: 400px;
    height: 300px;
    border: 1px solid #333;
  }
  
  .content {
    float: left;
    margin-right: 10px;
    width: 400px;
    height: 300px;
  }
  
  .content .inner {
    padding: 20px;
    font-size: 35px;
  }
  </code></pre>
  
  <p>And live sample of how <a href="http://jsdo.it/oleg.jakushkin/oSPP" rel="nofollow">it works Here</a>. What I am looking for looks <a href="http://iphone.hohli.com/docs/gallery.html" rel="nofollow">like this (link provided by Trufa)</a> But works not just for images but also for html tabs... and can be simpler in physics...=) Is it possible to modify provided code to any thing near that thing I want?</p>