Skip to content

Commit

Permalink
fix for issue #443
Browse files Browse the repository at this point in the history
  • Loading branch information
lyfeyaj committed Mar 2, 2015
1 parent 6bb0bb3 commit 91b3100
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 13 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ Swipe can take an optional second parameter– an object of key/value settings:
``` js

window.mySwipe = new Swipe(document.getElementById('slider'), {
startSlide: 2,
startSlide: 0,
speed: 400,
auto: 3000,
continuous: true,
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "swipe-js",
"version": "2.0.1",
"version": "2.0.2",
"main": [
"./swipe.js"
],
Expand Down
4 changes: 2 additions & 2 deletions build/swipe.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ <h1>Swipe 2</h1>
<header>Pure Javascript</header>
<pre>
var element = document.getElementById('mySwipe');
window.mySwipe = Swipe(element, {
window.mySwipe = new Swipe(element, {
startSlide: 0,
auto: 3000,
autoRestart: true,
Expand All @@ -96,7 +96,7 @@ <h1>Swipe 2</h1>

// pure JS
var element = document.getElementById('mySwipe');
window.mySwipe = Swipe(element, {
window.mySwipe = new Swipe(element, {
startSlide: 0,
auto: 3000,
autoRestart: true,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "swipe-js",
"version": "2.0.1",
"version": "2.0.2",
"dependencies": {},
"devDependencies": {
"grunt": "~0.4.5",
Expand Down
23 changes: 17 additions & 6 deletions swipe.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Swipe 2.0.1
* Swipe 2.0.2
*
* Brad Birdsall & Felix Liu
* Copyright 2015, MIT License
Expand Down Expand Up @@ -129,6 +129,17 @@ function Swipe(container, options) {

}

function getPos() {
// Fix for the clone issue in the event of 2 slides
var currentIndex = index;

if (currentIndex >= length) {
currentIndex = currentIndex - length;
}

return currentIndex;
}

function slide(to, slideSpeed) {

// do nothing if already on requested slide
Expand Down Expand Up @@ -177,7 +188,7 @@ function Swipe(container, options) {
}

index = to;
offloadFn(options.callback && options.callback(index, slides[index]));
offloadFn(options.callback && options.callback(getPos(), slides[index]));
}

function move(index, dist, speed) {
Expand Down Expand Up @@ -234,7 +245,7 @@ function Swipe(container, options) {
}

if (options.transitionEnd) {
options.transitionEnd.call(event, index, slides[index]);
options.transitionEnd.call(event, getPos(), slides[index]);
}

clearInterval(timer);
Expand Down Expand Up @@ -446,7 +457,7 @@ function Swipe(container, options) {
}

if (options.callback) {
options.callback(index, slides[index]);
options.callback(getPos(), slides[index]);
}

} else {
Expand Down Expand Up @@ -482,7 +493,7 @@ function Swipe(container, options) {
}

if (options.transitionEnd) {
options.transitionEnd.call(event, index, slides[index]);
options.transitionEnd.call(event, getPos(), slides[index]);
}

}
Expand Down Expand Up @@ -572,7 +583,7 @@ function Swipe(container, options) {
getPos: function() {

// return current index position
return index;
return getPos();

},
getNumSlides: function() {
Expand Down

0 comments on commit 91b3100

Please sign in to comment.