;(function ($){
  $.fn.carousel3d = function (options) {
    options = $.extend({
      interval: 4000,
      width: 400,
      zindex: 100,
      offset: {
        right: 20,
        bottom: 20
      },
    }, options)

    return this.each(function () {
      var $items = $('img', this)
        , scale = 1/$items.length
        , active = 0
        , interval = null

      function show(index) {
        for (var i = 0; i < $items.length; i++) {
          $items.eq((index + i) % $items.length).css({
            width: options.width * (1 - scale * i),
            left: (options.offset.right + options.width * scale) * i,
            bottom: options.offset.bottom * i,
            zIndex: options.zindex - i
          })
        }

        clearInterval(interval)
        interval = setInterval(next, options.interval)
      }

      function next() {
        show(++active)
      }

      function prev() {
        show(--active)
      }

      (new Hammer(this)).on('panleft panright', function(event) {
        if (event.isFinal && event.type == 'panleft') {
          next()
        }

        if (event.isFinal && event.type == 'panright') {
          prev()
        }
      })

      show(active)
    })
  }
})(jQuery)

@@ -15,14 +15,13 @@
 %7B%0A  
-$.fn.c
+var C
 arou
@@ -38,16 +38,25 @@
 nction (
+element, 
 options)
@@ -66,31 +66,208 @@
     
-options = $.extend(%7B%0A  
+this.$items = $('img', element)%0A    this.options = options%0A    this.scale = 1 / this.$items.length%0A    this.active = 0%0A    this.interval = null%0A    this.to(this.active)%0A  %7D%0A%0A  Carousel3d.DEFAULTS = %7B%0A
     
@@ -280,16 +280,14 @@
 al: 
-4
+5
 000,%0A
-  
     
@@ -302,18 +302,16 @@
 00,%0A    
-  
 zindex: 
@@ -319,18 +319,16 @@
 00,%0A    
- 
- 
 offset: 
@@ -329,18 +329,16 @@
 fset: %7B%0A
-  
       ri
@@ -348,26 +348,24 @@
 : 20,%0A      
- 
- 
 bottom: 20%0A 
@@ -367,190 +367,227 @@
  20%0A
-  
     %7D
-,%0A    %7D, options)%0A%0A    return this.each(function () %7B%0A      var $items = $('img', this)%0A        , sc
+%0A  %7D%0A%0A  Carousel3d.prototype.cycle = function () %7B%0A    this.interval && clearInterval(this.interval)%0A    this.interv
 al
-e
  = 
-1/$items.length%0A        , active = 0%0A        , interval = null%0A%0A     
+setInterval($.proxy(this.next, this), this.options.interval)%0A  %7D%0A%0A  Carousel3d.prototype.to =
  fun
@@ -592,20 +592,16 @@
 unction 
-show
 (index) 
@@ -598,28 +598,24 @@
 n (index) %7B%0A
-    
     for (var
@@ -626,16 +626,21 @@
  0; i %3C 
+this.
 $items.l
@@ -659,20 +659,21 @@
 %7B%0A      
-    
+this.
 $items.e
@@ -688,16 +688,21 @@
  + i) %25 
+this.
 $items.l
@@ -722,27 +722,28 @@
         
-   
- 
 width: 
+this.
 options.
@@ -755,16 +755,21 @@
  * (1 - 
+this.
 scale * 
@@ -784,19 +784,20 @@
     
-  
-  
 left: (
+this.
 opti
@@ -815,16 +815,21 @@
 right + 
+this.
 options.
@@ -836,16 +836,21 @@
 width * 
+this.
 scale) *
@@ -861,28 +861,24 @@
         
-    
 bottom: 
 options.
@@ -869,16 +869,21 @@
 bottom: 
+this.
 options.
@@ -913,20 +913,16 @@
     
-    
 zIndex: 
 opti
@@ -917,16 +917,21 @@
 zIndex: 
+this.
 options.
@@ -941,20 +941,16 @@
 dex - i%0A
-    
       %7D)
@@ -950,20 +950,16 @@
      %7D)%0A
-    
     %7D%0A%0A 
@@ -965,105 +965,131 @@
     
-    clearInterval(interval)%0A        interval = setInterval(next, options.interval)%0A      %7D%0A%0A     
+this.cycle()%0A  %7D%0A%0A  Carousel3d.prototype.next = function () %7B%0A    this.to(++this.active)%0A  %7D%0A%0A  Carousel3d.prototype.prev =
  fun
@@ -1094,20 +1094,16 @@
 unction 
-next
 () %7B%0A   
@@ -1107,27 +1107,31 @@
     
-    show(++
+this.to(--this.
 active)%0A
     
@@ -1130,79 +1130,180 @@
 ve)%0A
-    
   %7D%0A%0A  
-    function prev() %7B%0A        show(--active)%0A      %7D%0A
+$.fn.carousel3d = function (options) %7B%0A    return this.each(function () %7B%0A      var carousel3d = new Carousel3d(this, $.extend(Carousel3d.DEFAULTS, options))
 %0A      
+;
 (new
@@ -1424,16 +1424,27 @@
         
+carousel3d.
 next()%0A 
@@ -1520,16 +1520,27 @@
         
+carousel3d.
 prev()%0A 
@@ -1560,28 +1560,8 @@
   %7D)
-%0A%0A      show(active)
 %0A   

refactor carousel3d.js