Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: antonj/viewpager.js
base: 190948f241
...
head fork: antonj/viewpager.js
compare: c142100c9c
Checking mergeability… Don't worry, you can still create the pull request.
  • 2 commits
  • 7 files changed
  • 0 commit comments
  • 1 contributor
View
4 Gruntfile.js
@@ -49,5 +49,7 @@ module.exports = function (grunt) {
});
grunt.registerTask('default', ['watch']);
- grunt.registerTask('dist', ['browserify', 'uglify']);
+ grunt.registerTask('dist', ['browserify', 'jshint', 'uglify']);
+ grunt.registerTask('all', ['dist']);
+
};
View
7 dist/viewpager.js
@@ -282,9 +282,10 @@ function ViewPager(elem, options) {
}
if (is_animating &&
- ((should_change_page && (move_offset > Math.min(anim_from_offset, anim_to_offset) && move_offset < Math.max(anim_from_offset, anim_to_offset))) ||
- (!should_change_page && ((anim_from_offset >= 0 && move_offset > 0) ||
- (anim_from_offset <= 0 && move_offset < 0))))) {
+ ((should_change_page &&
+ (move_offset >= Math.min(anim_from_offset, anim_to_offset) &&
+ move_offset <= Math.max(anim_from_offset, anim_to_offset))) ||
+ (!should_change_page && move_offset !== 0))) {
onPageScroll(move_offset, active_page);
raf(update);
} else {
View
2  dist/viewpager.min.js
@@ -1 +1 @@
-!function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);throw new Error("Cannot find module '"+g+"'")}var j=c[g]={exports:{}};b[g][0].call(j.exports,function(a){var c=b[g][1][a];return e(c?c:a)},j,j.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g<d.length;g++)e(d[g]);return e}({1:[function(a,b){"use strict";b.exports={add:function(a,b,c,d){var e,f;for(b instanceof Array||(b=[b]),e=0,f=b.length;f>e;e+=1)a.addEventListener(b[e],c,!!d)},remove:function(a,b,c,d){var e,f;for(b instanceof Array||(b=[b]),e=0,f=b.length;f>e;e+=1)a.removeEventListener(b[e],c,!!d)}}},{}],2:[function(a,b){"use strict";var c,d=0,e=["webkit","moz"];for(c=0;c<e.length&&!window.requestAnimationFrame;++c)window.requestAnimationFrame=window[e[c]+"RequestAnimationFrame"],window.cancelAnimationFrame=window[e[c]+"CancelAnimationFrame"]||window[e[c]+"CancelRequestAnimationFrame"];window.requestAnimationFrame||(window.requestAnimationFrame=function(a){var b=(new Date).getTime(),c=Math.max(0,16-(b-d)),e=window.setTimeout(function(){a(b+c)},c);return d=b+c,e}),window.cancelAnimationFrame||(window.cancelAnimationFrame=function(a){clearTimeout(a)}),b.exports.requestAnimationFrame=window.requestAnimationFrame,b.exports.cancelAnimationFrame=window.cancelAnimationFrame},{}],3:[function(a,b){"use strict";b.exports={clamp:function(a,b,c){return b>a?b:a>c?c:a},map:function(a,b,c,d,e){return d+(e-d)*((a-b)/(c-b))},mapClamp:function(a,b,c,d,e){return this.clamp(this.map(a,b,c,d,e),e>d?d:e,e>d?e:d)},random:function(a,b){return Math.random()*(b-a)+a},randomInt:function(a,b){return Math.floor(Math.random()*(b-a+1))+a},Ease:{CubicInOut:function(a){return(a*=2)<1?.5*a*a*a:.5*((a-=2)*a*a+2)},CubicIn:function(a){return a*a*a},CubicOut:function(a){return--a*a*a+1}}}},{}],4:[function(a,b){"use strict";function c(a,b){function c(){return j&&0>x&&0===z||x>0&&z+1===j}function g(a){return A?a.touches[0]:a}function h(a,b,c){function f(){var b=!1;return y=d.mapClamp(Date.now(),g,h,j,k),t?(s=!1,!1):(s&&(a&&y>-1&&1>y||!a&&j>=0&&y>0||!a&&0>=j&&0>y)?(F(y,z),e(f)):(s&&(y=0),F(k,z),s&&a&&(b=!0,z+=k),s=!1,u=!1),b&&G(z),void 0)}var g=Date.now(),h=g+b,j=y,k=x>=0&&!c?1:-1;b=b||i,s=!0,u=a,a||(k=0),e(f)}b=b||{};var i=void 0!==b.anim_duration?b.anim_duration:200,j=(void 0!==b.wait_for_anim?b.wait_for_anim:!0,void 0!==b.pages?b.pages:!1),k=window,l=a.offsetWidth,m=0,n=0,o=0,p=0,q=0,r=0,s=!1,t=!1,u=!1,v=!1,w=!1,x=0,y=0,z=0,A="ontouchstart"in window,B=A?"touchstart":"mousedown",C=A?"touchmove":"mousemove",D=A?["touchend","touchcancel"]:["mouseup","mousecancel"],E=function(){},F=b.onPageScroll||E,G=b.onPageChange||E,H=b.onSizeChanged||E,I={handleEvent:function(b){switch(b.type){case"mousedown":case"touchstart":this.onDown(b);break;case"mousemove":case"touchmove":this.onMove(b);break;case"mouseup":case"touchend":this.onUp(b);break;case"resize":l=a.offsetWidth,H(a.offsetWidth,a.offsetHeight)}},onDown:function(b){t=!0,s&&(F(u?x>0?1:-1:0,z),z+=u?x>0?1:-1:0,u&&G(z),u=!1);var c=g(b);return m=c.pageX,n=c.pageY,o=c.pageX,p=c.pageY,q=Date.now(),r=0,f.remove(a,B,this),f.add(k,C,this),f.add(k,D,this),v=void 0,!1},onMove:function(b){var d=g(b);if(void 0===v&&(v=Math.abs(m-d.pageX)>Math.abs(n-d.pageY)),!v)return f.add(a,B,this),f.remove(k,C,this),f.remove(k,D,this),!1;b.preventDefault(),s&&(w=!0),s=!1,x=m-d.pageX,y=x/l+r;return c()&&(y/=3),F(y,z,!0),!1},onUp:function(){var b=Date.now()-q,d=Number(b)<250&&Math.abs(x)>20||Math.abs(x)>.5*l;return d&=!c()&&!w,h(d),w=!1,x=0,f.add(a,B,this),f.remove(k,C,this),f.remove(k,D,this),t=!1,!1}};return f.add(a,B,I),f.add(window,"resize",I),{next:function(){h(!0,500)},previous:function(){h(!0,500,!0)}}}var d=a("./utils"),e=a("./raf").requestAnimationFrame,f=a("./events");b.exports=c,window.ViewPager=c},{"./events":1,"./raf":2,"./utils":3}]},{},[4]);
+!function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);throw new Error("Cannot find module '"+g+"'")}var j=c[g]={exports:{}};b[g][0].call(j.exports,function(a){var c=b[g][1][a];return e(c?c:a)},j,j.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g<d.length;g++)e(d[g]);return e}({1:[function(a,b){"use strict";b.exports={add:function(a,b,c,d){var e,f;for(b instanceof Array||(b=[b]),e=0,f=b.length;f>e;e+=1)a.addEventListener(b[e],c,!!d)},remove:function(a,b,c,d){var e,f;for(b instanceof Array||(b=[b]),e=0,f=b.length;f>e;e+=1)a.removeEventListener(b[e],c,!!d)}}},{}],2:[function(a,b){"use strict";var c,d=0,e=["webkit","moz"];for(c=0;c<e.length&&!window.requestAnimationFrame;++c)window.requestAnimationFrame=window[e[c]+"RequestAnimationFrame"],window.cancelAnimationFrame=window[e[c]+"CancelAnimationFrame"]||window[e[c]+"CancelRequestAnimationFrame"];window.requestAnimationFrame||(window.requestAnimationFrame=function(a){var b=(new Date).getTime(),c=Math.max(0,16-(b-d)),e=window.setTimeout(function(){a(b+c)},c);return d=b+c,e}),window.cancelAnimationFrame||(window.cancelAnimationFrame=function(a){clearTimeout(a)}),b.exports.requestAnimationFrame=window.requestAnimationFrame,b.exports.cancelAnimationFrame=window.cancelAnimationFrame},{}],3:[function(a,b){"use strict";b.exports={clamp:function(a,b,c){return Math.min(Math.max(a,b),c)},map:function(a,b,c,d,e){return d+(e-d)*((a-b)/(c-b))},mapClamp:function(a,b,c,d,e){return this.clamp(this.map(a,b,c,d,e),e>d?d:e,e>d?e:d)}}},{}],4:[function(a,b){"use strict";function c(a,b){function c(){return p&&0>B&&0===D||B>0&&D+1===p}function g(a){return E?a.touches[0]:a}function h(){y&&(C=0),J(l,D),y&&A&&(D+=l,K(D)),y=!1,A=!1}function i(a,b,c){function f(){return C=d.mapClamp(Date.now(),j,k,m,l),z?(y=!1,void 0):(y&&(a&&C>=Math.min(m,l)&&C<=Math.max(m,l)||!a&&0!==C)?(J(C,D),e(f)):h(),void 0)}b=b||o,j=Date.now(),k=j+b,m=C,l=C>=0&&!c?1:-1,y=!0,A=a,(-1>m||m>1)&&(l=Math.round(m)),A||(l=0),e(f)}b=b||{};var j,k,l,m,n,o=void 0!==b.anim_duration?b.anim_duration:200,p=void 0!==b.pages?b.pages:!1,q=!b.vertical,r=window,s=q?a.offsetWidth:a.offsetHeight,t=0,u=0,v=0,w=0,x=0,y=!1,z=!1,A=!1,B=0,C=0,D=0,E="ontouchstart"in window,F=E?"touchstart":"mousedown",G=E?"touchmove":"mousemove",H=E?["touchend","touchcancel"]:["mouseup","mousecancel"],I=function(){},J=b.onPageScroll||I,K=b.onPageChange||I,L=b.onSizeChanged||I,M={handleEvent:function(b){switch(b.type){case"mousedown":case"touchstart":this.onDown(b);break;case"mousemove":case"touchmove":this.onMove(b);break;case"mouseup":case"touchend":this.onUp(b);break;case"resize":s=a.offsetWidth,L(a.offsetWidth,a.offsetHeight)}},onDown:function(b){z=!0,y&&h();var c=g(b);return t=c.pageX,u=c.pageY,v=c.pageX,w=c.pageY,x=Date.now(),f.remove(a,F,this),f.add(r,G,this),f.add(r,H,this),n=void 0,!1},onMove:function(b){var d=g(b);return void 0===n&&(n=Math.abs(t-d.pageX)>Math.abs(u-d.pageY),q||(n=!n)),n?(b.preventDefault(),y=!1,B=q?t-d.pageX:u-d.pageY,C=B/s,c()&&(C/=3),J(C,D,!0),!1):(z=!1,f.add(a,F,this),f.remove(r,G,this),f.remove(r,H,this),!1)},onUp:function(){var b=Date.now()-x,d=Number(b)<250&&Math.abs(B)>20||Math.abs(B)>.5*s;return d&=!c(),i(d),B=0,f.add(a,F,this),f.remove(r,G,this),f.remove(r,H,this),z=!1,!1}};return f.add(a,F,M),f.add(window,"resize",M),{next:function(){i(!0,500)},previous:function(){i(!0,500,!0)}}}var d=a("./utils"),e=a("./raf").requestAnimationFrame,f=a("./events");b.exports=c,window.ViewPager=c},{"./events":1,"./raf":2,"./utils":3}]},{},[4]);
View
22 examples/simplevertical/index.html
@@ -0,0 +1,22 @@
+<!DOCTYPE html>
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <meta charset="UTF-8" />
+ <meta name="viewport" content="width=device-width, user-scalable=yes, initial-scale=1.0" />
+ <link rel="stylesheet" href="style.css" type="text/css" media="screen" />
+ <title></title>
+ </head>
+ <body>
+ <div class="pager">
+ <!-- <button id="prev">prev</button> -->
+ <!-- <button id="next">next</button> -->
+ <div class="pager_items">
+ <img draggable="false" style="background: url(http://nicenicejpg.com/1024); background-size: cover; background-position: center;" />
+ <img draggable="false" style="background: url(http://placekitten.com/1024); background-size: cover; background-position: center;" />
+ <img draggable="false" style="background: url(http://placebear.com/1024/1024); background-size: cover; background-position: center;" />
+ </div>
+ </div>
+ <script type="text/javascript" src="../../dist/viewpager.js"></script>
+ <script type="text/javascript" src="main.js"></script>
+ </body>
+</html>
View
31 examples/simplevertical/main.js
@@ -0,0 +1,31 @@
+/*global ViewPager*/
+
+var item_container = document.querySelector('.pager_items');
+var view_pager_elem = document.querySelector('.pager');
+var w = view_pager_elem.offsetWidth;
+var h = view_pager_elem.offsetHeight;
+
+var vp = new ViewPager(view_pager_elem, {
+ pages: item_container.children.length,
+ vertical: true,
+ onPageScroll : function (offset, page) {
+ console.log(offset, page);
+ item_container.style['-webkit-transform'] = 'translate3d(0px, ' + ((-offset * h) - (page * h)) + 'px, 0px)';
+
+ },
+
+ onPageChange : function (page) {
+ console.log('page', page);
+ },
+
+ onSizeChanged : function(width, height) {
+ w = width;
+ }
+});
+
+// document.getElementById('prev').addEventListener('click', function () {
+// vp.previous();
+// });
+// document.getElementById('next').addEventListener('click', function () {
+// vp.next();
+// });
View
26 examples/simplevertical/style.css
@@ -0,0 +1,26 @@
+html, body {
+ margin: 0;
+ padding: 0;
+}
+
+.pager {
+ position: absolute;
+ width: 100%;
+ height: 100%;
+ overflow: hidden;
+}
+
+.pager_items {
+ width: 100%;
+ height: 300%;
+ overflow: hidden;
+ outline: 1px solid blue;
+}
+
+img {
+ position: relative;
+ display: block;
+ width: 100%;
+ height: 33.3333333333%;
+ outline: 1px solid red;
+}
View
7 src/viewpager.js
@@ -200,9 +200,10 @@ function ViewPager(elem, options) {
}
if (is_animating &&
- ((should_change_page && (move_offset > Math.min(anim_from_offset, anim_to_offset) && move_offset < Math.max(anim_from_offset, anim_to_offset))) ||
- (!should_change_page && ((anim_from_offset >= 0 && move_offset > 0) ||
- (anim_from_offset <= 0 && move_offset < 0))))) {
+ ((should_change_page &&
+ (move_offset >= Math.min(anim_from_offset, anim_to_offset) &&
+ move_offset <= Math.max(anim_from_offset, anim_to_offset))) ||
+ (!should_change_page && move_offset !== 0))) {
onPageScroll(move_offset, active_page);
raf(update);
} else {

No commit comments for this range

Something went wrong with that request. Please try again.