Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow multiple swipeviews in the same document #52

Open
wants to merge 72 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
1d37c64
Allow multiple swipviews in the same document (multitouch support)
Jun 20, 2013
0731a35
oops, forgot to test without touch events
Jun 20, 2013
4fd3af8
rm div id
Jun 20, 2013
a6c49eb
add a new demo with 5 swipe views
Jun 20, 2013
f922ae7
fix demo
Jun 20, 2013
000c80f
update readme
Jun 20, 2013
e42f36a
rm onMouveOut cb in demo/gallery2
Jun 21, 2013
2d764b9
add mouseout listener on the swipe view wrapper
Jun 21, 2013
9913092
demo gallery2, keep global references for testing
Jun 21, 2013
16e7dd2
demo: gallery2 refacto, getting data from a ƒ
Jun 21, 2013
027e2b6
fix on __end()
Jun 21, 2013
c44bc3f
handle touch cancel properly!
Jun 21, 2013
3081d49
wip VerticalSwipeView
Jun 25, 2013
39aff26
wip VerticalSwipeView
Jun 25, 2013
e2db487
progress on VerticalSwipeView
Jun 25, 2013
200dd6a
wip gallery4 demo
Jun 25, 2013
0239dcf
add demo3
Jun 25, 2013
4a01397
oops
Jun 25, 2013
ee01079
re oops
Jun 25, 2013
6064ced
prefixing custom events
Jun 25, 2013
c7cec24
wip bidirectional infinite swipe view demo
Jun 25, 2013
caeea22
wip demo5
Jun 25, 2013
b5e606f
Merge branch 'master' into gh-pages
Jun 25, 2013
2ede772
style+ add a set of graph
Jun 26, 2013
c91e827
style+ add a set of graph
Jun 26, 2013
639b874
add reset method to allow reuse of a SwipeView
Jun 26, 2013
6ea5bd3
wip vertical/horizontal infinite scroll with reusing swipeviews
Jun 26, 2013
6113ffc
Merge branch 'master' into gh-pages
Jun 26, 2013
6e290f5
fix mouse out issues
Jun 27, 2013
6343c9b
fix mouse out issues
Jun 27, 2013
d699772
wip adding a vertical option in SwipeView
Jul 1, 2013
048b34d
Merge branch 'master' into gh-pages
Jul 1, 2013
97ec3a2
%s/\t/ /g
Jul 1, 2013
b965bc1
allow to specify clientHeight and clientWidth in the option
Jul 1, 2013
e5d766f
tiny refactoring
Jul 1, 2013
f5a6532
Merge branch 'master' into gh-pages
Jul 1, 2013
a2e444d
improve README
Jul 1, 2013
9b9d502
improve README
Jul 1, 2013
8a73010
refactoring demo gallery7
Jul 2, 2013
cca87ec
Merge branch 'master' into gh-pages
Jul 2, 2013
6398e74
add package.json + Gruntfile.js + pass jshint
Jul 4, 2013
435e2a3
update read me
Jul 4, 2013
d6a314f
add version in dist filename
Jul 4, 2013
11ce536
Merge branch 'master' into gh-pages
Jul 4, 2013
dbf6d89
oops
Jul 4, 2013
e3ee935
add grunt-contrib-connect
Jul 9, 2013
b00696b
new demos...
Jul 9, 2013
a5ad40f
fix desktop mouse stuff
Jul 9, 2013
9eb73ce
bump version to 1.0.6
Jul 9, 2013
7a7b42e
fix when swipeview < viewport
Jul 9, 2013
9d91b06
fix inner swipeview events
Jul 10, 2013
016c937
1.1.1
Jul 10, 2013
f938534
Add .abort() method
Jul 16, 2013
7309f95
Increment version 1.1.2
Jul 17, 2013
47ccd70
Merge pull request #1 from gre/master
gre Jul 17, 2013
30eff4d
Making it work on IE8 !
Jul 17, 2013
a8c1354
Making the destroy function working on IE
Jul 18, 2013
bd5df63
compile
Jul 18, 2013
fee8eb0
Merge pull request #2 from gre/master
bobylito Aug 7, 2013
6af4c13
Provide a way to unbind the external events without destroying
bobylito Aug 7, 2013
dc961d5
Merge pull request #3 from peutetre/features/unbind
gre Aug 7, 2013
eed82a5
Bump to v1.2.1
bobylito Aug 7, 2013
5afdbd0
Add origin information in onFlip callback
bobylito Aug 12, 2013
c278ab6
GoToPage fix
bobylito Aug 13, 2013
714b56b
Fix no loop when swipe
bobylito Aug 13, 2013
9e57469
Merge pull request #4 from peutetre/features/flipOrigin
peutetre Aug 19, 2013
2885e21
Merge pull request #5 from peutetre/features/noLoop
peutetre Aug 19, 2013
84ef88f
Correctly bump version 1.2.2
bobylito Aug 19, 2013
23844de
Using loop:false fix the initial state of pages (sometimes was hidden)
Sep 18, 2013
7ee7426
Really fix the loop:false visibility:hidden bug - goToPage now reset …
Sep 19, 2013
43c85e8
Add bind() and unbind() for DOM events
Nov 28, 2013
76a8c9b
throw error if bind / unbind is called when already bound/unbound
Nov 28, 2013
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.DS_Store
*-min.js
*-min.js
/node_modules/
42 changes: 42 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
module.exports = function(grunt) {

grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
connect: {
server: {
options: {
base: "",
port: 9999
}
}
},
uglify: {
options: {
banner: '/*! <%= pkg.name %> <%= pkg.version %> - <%= pkg.description %> */\n'
},
build: {
src: 'src/<%= pkg.name %>.js',
dest: 'dist/<%= pkg.name %>-<%= pkg.version %>.min.js'
}
},
jshint: {
all: {
src: ['src/<%= pkg.name %>.js']
}
},
watch: {
all: {
files: ['src/*.js', 'demo/*/*.js'],
tasks: ['default', 'dev']
}
}
});

grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-jshint');

grunt.registerTask('default', ['jshint', 'uglify']);
grunt.registerTask("dev", ["connect", "watch"]);
};
17 changes: 14 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
SwipeView v1.0 - 2012-08-25
============================
SwipeView v1.3.0 - 2013-09-28
=============================

- the SwipeView instanciation does not auto-bind anymore
- Add bind() and unbind()
- the old unbind() has been renamed to offAll()

SwipeView v1.0.5 - 2013-07-04
=============================

Modified version of Matteo's SwipeView which allows vertical swipe (with the `vertical` option) and also allows multiple SwipeViews in the same document:

example: Multiple SwipeViews in the same document + vertical swipe: [http://peutetre.github.io/SwipeView/demo/gallery7/](http://peutetre.github.io/SwipeView/demo/gallery7/)

Virtually infinite loop-able horizontal carousel for desktop and mobile browsers.

Expand All @@ -11,4 +22,4 @@ eReader Demo: [http://cubiq.org/dropbox/SwipeView/demo/ereader](http://cubiq.org

Inline Demo: [http://cubiq.org/dropbox/SwipeView/demo/inline](http://cubiq.org/dropbox/SwipeView/demo/inline)

Screencast: [http://www.youtube.com/watch?v=Hhes5JHs8jQ](http://www.youtube.com/watch?v=Hhes5JHs8jQ)
Screencast: [http://www.youtube.com/watch?v=Hhes5JHs8jQ](http://www.youtube.com/watch?v=Hhes5JHs8jQ)
3 changes: 2 additions & 1 deletion demo/ereader/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
req = new XMLHttpRequest();

ereader = new SwipeView('#wrapper', { hastyPageFlip:true });
ereader.bind();

// Ajax request
req.open('GET', 'flowers.txt', true);
Expand Down Expand Up @@ -154,4 +155,4 @@
</div>
<div id="wrapper"></div>
</body>
</html>
</html>
7 changes: 6 additions & 1 deletion demo/gallery/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
];

gallery = new SwipeView('#wrapper', { numberOfPages: slides.length });
gallery.bind();

// Load initial data
for (i=0; i<3; i++) {
Expand All @@ -81,6 +82,10 @@
el.width = slides[page].width;
el.height = slides[page].height;
el.onload = function () { this.className = ''; }
// fixes for IE
el.setAttribute("unselectable", "on");
el.ondragstart = function() { return false; };

gallery.masterPages[i].appendChild(el);

el = document.createElement('span');
Expand Down Expand Up @@ -123,4 +128,4 @@

</script>
</body>
</html>
</html>
12 changes: 6 additions & 6 deletions demo/gallery/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ body {
background:rgba(255,255,255,0.4);
}

#swipeview-slider > div {
.swipeview-slider > div {
position:relative;
display:-webkit-box;
display:-moz-box;
Expand All @@ -97,7 +97,7 @@ body {
overflow:hidden;
}

#swipeview-slider img {
.swipeview-slider img {
display:block;
border:5px solid #eee;
-webkit-box-shadow:0 2px 6px #000;
Expand All @@ -124,7 +124,7 @@ body {
pointer-events:none;
}

#swipeview-slider span {
.swipeview-slider span {
position:absolute;
bottom:0;
left:0;
Expand Down Expand Up @@ -165,7 +165,7 @@ body {
transform:translate(0,100%) translateZ(0);
}

#swipeview-slider .swipeview-active span {
.swipeview-slider .swipeview-active span {
-webkit-transform:translate(0,0) translateZ(0);
-moz-transform:translate(0,0) translateZ(0);
-ms-transform:translate(0,0);
Expand All @@ -184,7 +184,7 @@ body {
}

#wrapper > div > .swipeview-loading img,
#swipeview-slider img.loading {
.swipeview-slider img.loading {
-webkit-transition-duration:0s;
opacity:0;
}
Expand All @@ -202,4 +202,4 @@ body {
-o-transform:translate(0,100%);
-o-transform:translate(0,100%) translateZ(0);
transform:translate(0,100%) translateZ(0);
}
}
117 changes: 117 additions & 0 deletions demo/gallery2/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<title>SwipeView</title>
<link href="style.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="../../src/swipeview.js"></script>
</head>

<body>
<div id="wrapper1" class='wrapper'></div>
<div id="wrapper2" class="wrapper"></div>
<div id="wrapper3" class="wrapper"></div>
<div id="wrapper4" class="wrapper"></div>
<div id="wrapper5" class="wrapper"></div>

<script type="text/javascript">

function getImgURL() {
return "http://lorempixel.com/186/125/?t=" + Math.ceil(Math.random()*100000);
}

function genData(size) {
var data = [], tmp = [], i=0, j=3;

for(var k=0; k<size; k++) {
tmp.push(getImgURL());
if (i<j) { i++; }
else {
tmp.push(getImgURL());
data.push({ imgs:tmp, height:125, width:186 });
i = 0; tmp = [];
}
}
return {
get: function (i) {
return data[i];
},
length : data.length
};
}

function generateSwipeView(id, dataO) {
var gallery = new SwipeView(id, {
hastyPageFlip:true,
numberOfPages: dataO.length
}), i, page;
gallery.bind();

function genImgs(container, page, d) {
var img, div;
for(var i=0; i< 5; i++) {
div = document.createElement('div');
div.className = 'container';
img = document.createElement('img');
img.className = 'loading';
img.src = d.get(page).imgs[i];
img.width = d.get(page).width;
img.height = d.get(page).height;
// fixes for IE
img.setAttribute("unselectable", "on");
img.ondragstart = function() { return false; };
div.style.width = d.get(page).width + "px";
div.style.height = d.get(page).height + "px";
img.onload = function () { this.className = ''; }
div.appendChild(img);
container.appendChild(div);
}
}

for(i=0; i<3; i++) {
page = i==0 ? dataO.length-1 : i-1;
div = document.createElement('div');
div.className = 'set-container';
genImgs(div, page, dataO);
gallery.masterPages[i].appendChild(div);
}

function setImg(el, src) {
el.className = 'loading';
el.src = src;
el.onload = function () { this.className = ''; }
}

gallery.onFlip(function () {
var el,
upcoming,
i;

for (i=0; i<3; i++) {
upcoming = gallery.masterPages[i].dataset.upcomingPageIndex;

if (upcoming != gallery.masterPages[i].dataset.pageIndex) {
els = gallery.masterPages[i].querySelectorAll('img');
setImg(els[0], dataO.get(upcoming).imgs[0]);
setImg(els[1], dataO.get(upcoming).imgs[1]);
setImg(els[2], dataO.get(upcoming).imgs[2]);
setImg(els[3], dataO.get(upcoming).imgs[3]);
setImg(els[4], dataO.get(upcoming).imgs[4]);
}
}
});
return gallery;
}

var g1 = generateSwipeView("#wrapper1", genData(100));
var g2 = generateSwipeView("#wrapper2", genData(100));
var g3 = generateSwipeView("#wrapper3", genData(100));
var g4 = generateSwipeView("#wrapper4", genData(100));
var g5 = generateSwipeView("#wrapper5", genData(100));

</script>
</body>
</html>
83 changes: 83 additions & 0 deletions demo/gallery2/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
html, body { height:100%; }
body {
padding:0;
margin:0;
background:#333;
-webkit-user-select:none;
-moz-user-select:none;
-ms-user-select:none;
-o-user-select:none;
user-select:none;
-webkit-text-size-adjust:none;
-moz-text-size-adjust:none;
-ms-text-size-adjust:none;
-o-text-size-adjust:none;
text-size-adjust:none;
color:#eee;
font-family:helvetica;
font-size:12px;
}

.wrapper {
width:1024px;
min-width:320px;
height:145px;
margin:10px auto;
border: 5px solid rgb(43, 38, 38);
}

.swipeview-slider > div {
position:relative;
display:-webkit-box;
display:-moz-box;
display:-ms-box;
display:-o-box;
display:box;
-webkit-box-orient:vertical;
-moz-box-orient:vertical;
-ms-box-orient:vertical;
-o-box-orient:vertical;
box-orient:vertical;
-webkit-box-pack:center;
-moz-box-pack:center;
-ms-box-pack:center;
-o-box-pack:center;
box-pack:center;
-webkit-box-align:center;
-mox-box-align:center;
-ms-box-align:center;
-o-box-align:center;
box-align:center;
overflow:hidden;
}

.swipeview-slider img {
display:block;
-webkit-transition-duration:.4s;
-moz-transition-duration:.4s;
-ms-transition-duration:.4s;
-o-transition-duration:.4s;
transition-duration:.4s;
-webkit-transition-property:opacity;
-moz-transition-property:opacity;
-ms-transition-property:opacity;
-o-transition-property:opacity;
transition-property:opacity;
opacity:1;
pointer-events:none;
visibility:visible;
}

.swipeview-slider .set-container {
margin:auto;
}

.swipeview-slider .container {
background: rgb(197, 197, 197);
float: left;
margin: 0 5px;
}

.swipeview-slider img.loading {
visibility:hidden;
}
Loading