just-carousel
Advanced tools
Comparing version 1.0.1 to 1.1.0
16
index.js
@@ -22,3 +22,3 @@ /* global module, window, document */ | ||
this.neededSlideIdx = null; | ||
this.animationDuration = 250; | ||
this.animationDuration = options.duration || 250; | ||
this.width = this.root.getBoundingClientRect().width; | ||
@@ -28,2 +28,8 @@ this.currentOffset = 100 / this.slides.length * this.currentSlideIdx * -1; | ||
this.timing = | ||
options.timingFunction || | ||
(function (t) { | ||
return t * (2 - t); | ||
}); | ||
this._onTouchStart = onTouchStart.bind(this); | ||
@@ -350,3 +356,3 @@ this._onTouchEnd = onTouchEnd.bind(this); | ||
var progress = timing(timeFraction); | ||
var progress = self.timing(timeFraction); | ||
var value = (endPoint - currentOffset) * progress + currentOffset; | ||
@@ -377,3 +383,3 @@ | ||
var progress = timing(timeFraction); | ||
var progress = self.timing(timeFraction); | ||
var range = pos - self.currentOffset; | ||
@@ -396,6 +402,2 @@ | ||
function timing(t) { | ||
return t * (2 - t); | ||
} | ||
function transformTo(endPoint) { | ||
@@ -402,0 +404,0 @@ this.inner.style.webkitTransform = 'translate3d(' + endPoint + '%, 0, 0)'; |
{ | ||
"name": "just-carousel", | ||
"version": "1.0.1", | ||
"version": "1.1.0", | ||
"description": "Just an 1-item-on-screen carousel that works naturally like an iOS/android desktops and nothing else.", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -10,3 +10,3 @@ # just-carousel | ||
* No dependencies. | ||
* 1.6kb min + gzip, 8kb full. | ||
* 2.6kb gzip, 9.1kb full. | ||
* Android 4+, WP8+, iOS 7+. | ||
@@ -78,2 +78,20 @@ * Written on es3 so must work on most desktop browsers (only requires support for `transform3d`). | ||
### duration | ||
Type: `number` | ||
Animation duration (milliseconds, default is 250) | ||
### timingFunction | ||
Type: `function` | ||
Animation timing function | ||
```javascript | ||
/** | ||
* Default function is ease-out | ||
* @param {number} t — timing fraction (from 0 to 1) | ||
* @returns {number} — animation fraction | ||
*/ | ||
function (t) { | ||
return t * (2 - t); | ||
} | ||
``` | ||
### onChangePos | ||
@@ -80,0 +98,0 @@ |
18689
395
128