Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <div class="text-center"><h1>jQuery touchSwipe - Carousel</h1><br /></div>

<!-- [ Example #1 ] -->
<div class="bp-touchSwipe">
  <div class="bp-touchSwipe_inner">
    <div class="bp-inner_item"></div>
    <div class="bp-inner_item"></div>
    <div class="bp-inner_item"></div>
    <div class="bp-inner_item"></div>
    <div class="bp-inner_item"></div>
    <div class="bp-inner_item"></div>
    <div class="bp-inner_item"></div>
    <div class="bp-inner_item"></div>
  </div>
</div>

<hr />
<!-- [ Example #2 ] -->
<div class="container">
  <div class="col-md-6">
    <div class="bp-touchSwipe">
      <div class="bp-touchSwipe_inner">
        <div class="bp-inner_item"></div>
        <div class="bp-inner_item"></div>
        <div class="bp-inner_item"></div>
        <div class="bp-inner_item"></div>
        <div class="bp-inner_item"></div>
        <div class="bp-inner_item"></div>
        <div class="bp-inner_item"></div>
        <div class="bp-inner_item"></div>
      </div>
    </div>      
  </div>

  <div class="col-md-6">
    <div class="bp-touchSwipe">
      <div class="bp-touchSwipe_inner">
        <div class="bp-inner_item"></div>
        <div class="bp-inner_item"></div>
        <div class="bp-inner_item"></div>
        <div class="bp-inner_item"></div>
        <div class="bp-inner_item"></div>
        <div class="bp-inner_item"></div>
        <div class="bp-inner_item"></div>
        <div class="bp-inner_item"></div>
      </div>
    </div>      
  </div>
</div>

<hr />
<!-- [ Example #3 ] -->
<div class="container">
  <div class="bp-touchSwipe">
    <div class="bp-touchSwipe_inner">
      <div class="bp-inner_item"></div>
      <div class="bp-inner_item"></div>
      <div class="bp-inner_item"></div>
      <div class="bp-inner_item"></div>
      <div class="bp-inner_item"></div>
      <div class="bp-inner_item"></div>
      <div class="bp-inner_item"></div>
      <div class="bp-inner_item"></div>
    </div>
  </div>
</div>

<hr />
<!-- [ Example #4 ] -->
<div class="col-md-6">
  <div class="bp-touchSwipe">
    <div class="bp-touchSwipe_inner">
      <div class="bp-inner_item"></div>
      <div class="bp-inner_item"></div>
      <div class="bp-inner_item"></div>
      <div class="bp-inner_item"></div>
      <div class="bp-inner_item"></div>
      <div class="bp-inner_item"></div>
      <div class="bp-inner_item"></div>
      <div class="bp-inner_item"></div>
    </div>      
  </div>
</div>
<div class="col-md-6">
  <div class="bp-touchSwipe">
    <div class="bp-touchSwipe_inner">
      <div class="bp-inner_item"></div>
      <div class="bp-inner_item"></div>
      <div class="bp-inner_item"></div>
      <div class="bp-inner_item"></div>
      <div class="bp-inner_item"></div>
      <div class="bp-inner_item"></div>
      <div class="bp-inner_item"></div>
      <div class="bp-inner_item"></div>
    </div>      
  </div>
</div>

<hr />
<!-- [ Usage ] -->
<div class="container">
<h2>Markup:</h2>
<pre class="prettyprint bp-prettyprint">&lt;div class="bp-touchSwipe"&gt;
  &lt;div class="bp-touchSwipe_inner"&gt;
    &lt;div class="bp-inner_item"&gt;&lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;</pre>
<h2>Style Customization:</h2>
<pre class="prettyprint bp-prettyprint">/* [ Customize Height ] */
/* CSS */
.bp-touchSwipe,
.bp-touchSwipe_inner,
.bp-inner_item {
   height: 220px; /* default */
}

/* SCSS */
$bpSwipecHeight   : 220px !default;

/* [ Customize Width ] */
/* CSS */
.bp-touchSwipe .bp-inner_item {
   width: 320px; /* default */
}

/* SCSS */
$bpInnerItemWidth : 320px !default;</pre>
<h2>Fork on Github:</h2>
<pre class="prettyprint bp-prettyprint">$ git clone https://github.com/boompx/jQuery-touchSwipe-Carousel.git</pre>
Or <a class="btn btn-default btn-sm" href="https://github.com/boompx/jQuery-touchSwipe-Carousel/archive/master.zip"><i class="fa fa-cloud-download"></i> Download ZIP</a>
</div>

<footer class="footer text-center text-muted">
  <p>Follow for more:</p> 
  <div class="btn-group" role="group">
  <a class="btn btn-default" href="https://twitter.com/boom_px"><i class="fa fa-twitter"></i></a>
  <a class="btn btn-default" href="https://plus.google.com/u/0/112381755879226452363/posts"><i class="fa fa-google-plus"></i></a>
  <a class="btn btn-default" href="https://www.facebook.com/pages/Boompx/380876822068214"><i class="fa fa-facebook"></i></a>
  <a class="btn btn-default" href="https://codepen.io/boompx/"><i class="fa fa-codepen"></i></a>
  </div>
  <div class="container"><hr /></div>
  <p><a href="http://boompx.com/">boompx.com</a></p>
</footer>
              
            
!

CSS

              
                @import "compass/css3";

// $size
$bpSwipecHeight   : 220px !default;
$bpInnerItemWidth : 320px !default;
$col-gutter       : 15px !default;

// $colors
$colors: #9ca0a1, #76cbce, #c1dbdc, #e0676e, #b4d030, #61585d;

// Base
.bp-touchSwipe {
  overflow: hidden;
  position: relative;
  cursor: move;
  cursor: grab;
  cursor: -moz-grab;
  cursor: -webkit-grab;
  &:active {
    cursor: grabbing;
    cursor: -moz-grabbing;
    cursor: -webkit-grabbing;
  }  
}

// Default size
.bp-touchSwipe {
  &,
  .bp-touchSwipe_inner, 
  .bp-inner_item {
    height: $bpSwipecHeight;
  }  
}


// Inner holder setup
.bp-touchSwipe {
  .bp-touchSwipe_inner {
    position: absolute;
    top: 0;
    left: 0;
    margin: 0;
    padding: 0;
    @include transition(all, .1s, ease);
  }  
}

// Item setup
.bp-touchSwipe {
  .bp-inner_item {
    width: $bpInnerItemWidth;
    float: left;
    @for $i from 1 through length($colors) {
      &:nth-child(#{length($colors)}n+#{$i}) {
        background-color: nth($colors, $i);
      }
    }
  } 
}


/* The following code is used only for demo purpose: */
body {
  background-color: #f7f7f7;
  margin-top: $col-gutter * 2; //~30px
}
.footer {
  background-color: #fff;
  padding: $col-gutter * 2;
  margin-top: $col-gutter * 2;
}
#{headings()} { font-family: 'Bad Script', cursive; }
pre.prettyprint {
  &.bp-prettyprint {
  padding: $col-gutter !important;
  border: 0 !important;
  font-family: consolas;
  font-size: 14px;
  background-color: white !important;

  .callout-demo & {
    max-height: 415px;
  }

  span {
    &.com { color: #919d9f; }
    &.pln { color: #395063; }
    &.tag { color: #6a93d0; }
    &.atv { color: #05ad97; }
    &.pun, &.opn, &.clo {
      color: #B9947B;
    }
    &.atn { color: #a95ebb; }
  } 
  }
}

              
            
!

JS

              
                /*
 * jQuery touchSwipe - Carousel
 * Author  : http://boompx.com/
 * Follow  : @boom_px
 * Github  : https://github.com/boompx/jQuery-touchSwipe-Carousel
 * Vendors : https://github.com/mattbryson/TouchSwipe-Jquery-Plugin
 * Licensed under the MIT license
 */
$(function () {
    $(".bp-touchSwipe").each(function () {
        function e() {
            a.find(".bp-touchSwipe_inner").css({
                width: a.find(".bp-inner_item").length * a.find(".bp-inner_item").width()
            })
        }
        var a = $(this);
        e();
        window.onresize = e;
        a.find(".bp-touchSwipe_inner").width() > a.width() && a.swipe({
            swipeStatus: function (f, c, b, d, e, g) {
                f = parseInt(a.find(".bp-touchSwipe_inner").css("left"));
                d = a.find(".bp-inner_item");
                d.last().position();
                d.last().width();
                a.width();
                b = "left" == b ? -1 : 1;
                "end" == c && (-1 == b ? (c = f + b * d.width(), b = -a.find(".bp-touchSwipe_inner").width() + a.innerWidth(), a.find(".bp-touchSwipe_inner").css("left", Math.max(c, b))) : 1 == b && (c = f + b * d.width(), a.find(".bp-touchSwipe_inner").css("left", Math.min(0, c))))
            },
            threshold: 0,
            maxTimeThreshold: 5E3,
            fingers: "all"
        })
    })
});
              
            
!
999px

Console