Skip to content
Browse files

Small fix

  • Loading branch information...
1 parent f7b61ff commit 190948f2411f6a888216e6231772de3fd9ba9778 @antonj committed Dec 8, 2013
Showing with 27 additions and 31 deletions.
  1. +5 −7 Gruntfile.js
  2. +8 −9 dist/viewpager.js
  3. +6 −6 examples/simpleslider/main.js
  4. +8 −9 src/viewpager.js
View
12 Gruntfile.js
@@ -6,13 +6,11 @@ module.exports = function (grunt) {
pkg: grunt.file.readJSON('package.json'),
jshint: {
- ignore_warning: {
- options: {
- '-W015' : true,
- 'globalstrict' : true
- },
- src: ['src/**/*.js']
- }
+ options: {
+ globalstrict : true,
+ trailing: true
+ },
+ src: ['src/**/*.js']
},
uglify: {
View
17 dist/viewpager.js
@@ -84,7 +84,7 @@ module.exports = {
'use strict';
var utils = require('./utils');
-var rAF = require('./raf').requestAnimationFrame;
+var raf = require('./raf').requestAnimationFrame;
var Events = require('./events');
function ViewPager(elem, options) {
@@ -119,16 +119,15 @@ function ViewPager(elem, options) {
onPageChange = options.onPageChange || noop,
onSizeChanged = options.onSizeChanged || noop;
-
function isMovingOutOfBounds() {
return PAGES &&
((move_diff_px < 0) && (active_page === 0)) ||
((move_diff_px > 0) && ((active_page + 1) === PAGES));
}
-
+
function getPoint (event) {
return has_touch ? event.touches[0] : event;
- }
+ }
var events = {
handleEvent : function (event) {
@@ -192,13 +191,14 @@ function ViewPager(elem, options) {
}
if (!is_active) {
+ is_dragging = false;
Events.add(elem, ev_start_name, this);
Events.remove(container, ev_move_name, this);
Events.remove(container, ev_end_name, this);
return false;
}
-
e.preventDefault(); // prevent default scrolling
+
is_animating = false; // Stop animations
move_diff_px = DIRECTION_HORIZONTAL ? m_down_x - p.pageX : m_down_y - p.pageY;
@@ -286,27 +286,26 @@ function ViewPager(elem, options) {
(!should_change_page && ((anim_from_offset >= 0 && move_offset > 0) ||
(anim_from_offset <= 0 && move_offset < 0))))) {
onPageScroll(move_offset, active_page);
- rAF(update);
+ raf(update);
} else {
handleAnimEnd();
}
}
- rAF(update);
+ raf(update);
}
Events.add(elem, ev_start_name, events);
Events.add(window, 'resize', events);
-
/** move_diff_pxe API */
return {
next : function () {
animate(true, 500);
},
previous : function() {
animate(true, 500, true);
- }
+ }
};
}
View
12 examples/simpleslider/main.js
@@ -23,9 +23,9 @@ var vp = new ViewPager(view_pager_elem, {
}
});
-document.getElementById('prev').addEventListener('click', function () {
- vp.previous();
-});
-document.getElementById('next').addEventListener('click', function () {
- vp.next();
-});
+// document.getElementById('prev').addEventListener('click', function () {
+// vp.previous();
+// });
+// document.getElementById('next').addEventListener('click', function () {
+// vp.next();
+// });
View
17 src/viewpager.js
@@ -2,7 +2,7 @@
'use strict';
var utils = require('./utils');
-var rAF = require('./raf').requestAnimationFrame;
+var raf = require('./raf').requestAnimationFrame;
var Events = require('./events');
function ViewPager(elem, options) {
@@ -37,16 +37,15 @@ function ViewPager(elem, options) {
onPageChange = options.onPageChange || noop,
onSizeChanged = options.onSizeChanged || noop;
-
function isMovingOutOfBounds() {
return PAGES &&
((move_diff_px < 0) && (active_page === 0)) ||
((move_diff_px > 0) && ((active_page + 1) === PAGES));
}
-
+
function getPoint (event) {
return has_touch ? event.touches[0] : event;
- }
+ }
var events = {
handleEvent : function (event) {
@@ -110,13 +109,14 @@ function ViewPager(elem, options) {
}
if (!is_active) {
+ is_dragging = false;
Events.add(elem, ev_start_name, this);
Events.remove(container, ev_move_name, this);
Events.remove(container, ev_end_name, this);
return false;
}
-
e.preventDefault(); // prevent default scrolling
+
is_animating = false; // Stop animations
move_diff_px = DIRECTION_HORIZONTAL ? m_down_x - p.pageX : m_down_y - p.pageY;
@@ -204,27 +204,26 @@ function ViewPager(elem, options) {
(!should_change_page && ((anim_from_offset >= 0 && move_offset > 0) ||
(anim_from_offset <= 0 && move_offset < 0))))) {
onPageScroll(move_offset, active_page);
- rAF(update);
+ raf(update);
} else {
handleAnimEnd();
}
}
- rAF(update);
+ raf(update);
}
Events.add(elem, ev_start_name, events);
Events.add(window, 'resize', events);
-
/** move_diff_pxe API */
return {
next : function () {
animate(true, 500);
},
previous : function() {
animate(true, 500, true);
- }
+ }
};
}

0 comments on commit 190948f

Please sign in to comment.
Something went wrong with that request. Please try again.