swipebox 1.2.9 → 1.3.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +5 -4
  3. data/lib/swipebox/version.rb +1 -1
  4. data/test/dummy/log/test.log +3 -30
  5. data/test/dummy/tmp/cache/assets/test/sass/af322a0e92ccadac09012d154ee28b4f413653a2/swipebox.css.scssc +0 -0
  6. data/test/dummy/tmp/cache/assets/test/sprockets/094fe312f84e24456e939e232419d161 +0 -0
  7. data/test/dummy/tmp/cache/assets/test/sprockets/3624f679b2faef3c8d4f0be8b412a7b4 +0 -0
  8. data/test/dummy/tmp/cache/assets/test/sprockets/5b111dd94287c0dc26ab3135104ff5e8 +0 -0
  9. data/test/dummy/tmp/cache/assets/test/sprockets/6158546426dd3b614cc331a893e3e32b +0 -0
  10. data/test/dummy/tmp/cache/assets/test/sprockets/{09898caf5a9a94ec51afecb80bca3cf2 → 641b32eca2fb6a11a629e366ef618910} +0 -0
  11. data/test/dummy/tmp/cache/assets/test/sprockets/71bf566457436ae26578623da8b68a62 +0 -0
  12. data/test/dummy/tmp/cache/assets/test/sprockets/{440dfe1de5fd9a862fed9bd0decb24b8 → 875634784ac6773adf05f3cbfbc354f1} +0 -0
  13. data/test/dummy/tmp/cache/assets/test/sprockets/b12c8eeb27dddf967e9497a27d787c6b +0 -0
  14. data/test/dummy/tmp/cache/assets/test/sprockets/b90c896ee4a772406357c7e80e9d4ff2 +0 -0
  15. data/test/dummy/tmp/cache/assets/test/sprockets/bf6921df542021c6a2e3c2de4594487a +0 -0
  16. data/test/dummy/tmp/cache/assets/test/sprockets/c0720704876b3cadc659513afef0fca6 +0 -0
  17. data/test/dummy/tmp/cache/assets/test/sprockets/c24cb53e4deb0627011b9e2fdaf539c6 +0 -0
  18. data/test/dummy/tmp/cache/assets/test/sprockets/ca7f363dbd860e3440d5000f99da447d +0 -0
  19. data/test/dummy/tmp/cache/assets/test/sprockets/d552baa52aa6c8c36743044c929e9c7a +0 -0
  20. data/test/dummy/tmp/cache/assets/test/sprockets/{7a6158d95c2641c1991a8ebd3fbe4213 → ecdcd5383451c2a6f726373f42341806} +0 -0
  21. data/vendor/assets/javascripts/swipebox.js +254 -179
  22. data/vendor/assets/stylesheets/swipebox.css.scss +137 -81
  23. metadata +35 -65
  24. data/test/dummy/db/development.sqlite3 +0 -0
  25. data/test/dummy/db/test.sqlite3 +0 -0
  26. data/test/dummy/tmp/cache/assets/test/sass/723883a196861294bbe8325180066fa58ee6de9e/swipebox.css.scssc +0 -0
  27. data/test/dummy/tmp/cache/assets/test/sass/771d9f27082f7556112a4648ca8fc905f2173465/swipebox.css.scssc +0 -0
  28. data/test/dummy/tmp/cache/assets/test/sprockets/0591d8c51084171b76a2c6f20926bb51 +0 -0
  29. data/test/dummy/tmp/cache/assets/test/sprockets/0bff44572e887b09daf68fed28839bb2 +0 -0
  30. data/test/dummy/tmp/cache/assets/test/sprockets/12326d2e44748b6b542dc270fba7390e +0 -0
  31. data/test/dummy/tmp/cache/assets/test/sprockets/1e17757dcb9ada88ed012e3675f1f95b +0 -0
  32. data/test/dummy/tmp/cache/assets/test/sprockets/1e47b6dbbf210735d6bfe9862e84f0cb +0 -0
  33. data/test/dummy/tmp/cache/assets/test/sprockets/1f74808b9e463d137a33f7ba77e3bbd4 +0 -0
  34. data/test/dummy/tmp/cache/assets/test/sprockets/2269a00fea39582a928db1d2c81983d8 +0 -0
  35. data/test/dummy/tmp/cache/assets/test/sprockets/25353c00952a3362331091a317a12bbc +0 -0
  36. data/test/dummy/tmp/cache/assets/test/sprockets/27915565888f61eae343f8223ece43a0 +0 -0
  37. data/test/dummy/tmp/cache/assets/test/sprockets/51010d13321d8992a932534ff1d41627 +0 -0
  38. data/test/dummy/tmp/cache/assets/test/sprockets/59bd4e64e2c90d2cbdca021507d81564 +0 -0
  39. data/test/dummy/tmp/cache/assets/test/sprockets/6450c3ebafe929a16bfea6cf4c35bf92 +0 -0
  40. data/test/dummy/tmp/cache/assets/test/sprockets/6fd4a72d818051674433e4a7a53ffd59 +0 -0
  41. data/test/dummy/tmp/cache/assets/test/sprockets/75c485a1ef3aafa76047132f5497eaba +0 -0
  42. data/test/dummy/tmp/cache/assets/test/sprockets/78fc9fc0f7b099f33eab93ec417fe39f +0 -0
  43. data/test/dummy/tmp/cache/assets/test/sprockets/79e92ecae5bf8e962811eb44d8ed5da6 +0 -0
  44. data/test/dummy/tmp/cache/assets/test/sprockets/86ffbc5132d97ef7634efb42901ca7e0 +0 -0
  45. data/test/dummy/tmp/cache/assets/test/sprockets/93057c6caa3e3b29af35e2323e5748c4 +0 -0
  46. data/test/dummy/tmp/cache/assets/test/sprockets/993de32fb37ad35f29a29a85c872f978 +0 -0
  47. data/test/dummy/tmp/cache/assets/test/sprockets/af78a815232b7bdf67f2f7d3b5535d5f +0 -0
  48. data/test/dummy/tmp/cache/assets/test/sprockets/b3a2d244fee52557c6bf0cc5acb01ff0 +0 -0
  49. data/test/dummy/tmp/cache/assets/test/sprockets/c53be797596ba6b9af102c9ac7423796 +0 -0
  50. data/test/dummy/tmp/cache/assets/test/sprockets/cde695242acc016b4f03a22a92cae318 +0 -0
  51. data/test/dummy/tmp/cache/assets/test/sprockets/ff9d1dac658ef3c703c5dfe984eb94d5 +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 51f0fa45917438717caa31372e3db87de179813e
4
- data.tar.gz: 87c4357aabff614f0654676b5951af77cb46d9ab
3
+ metadata.gz: c148e4099fd61700f76dadbc97e3790db951f3b4
4
+ data.tar.gz: 6d1858503319c815d4baaef13038ef85b42a90bd
5
5
  SHA512:
6
- metadata.gz: 977f93f0bd6cb60647f65145bd5ba22910f441a8164ac908f48041a6f1b4c66590bba7970609da4d431e2f26d090a8b37cc5fd04e72edab708f1644917513962
7
- data.tar.gz: ce7906b22290bb0d18c70ba5f62f8c1597f5940a5cbfbe9acf2ab8631f65d5b9cb122c0f775ce9e4b27ae814b5c9bb4d14bde929e0a8aab02f19d3555d460c7d
6
+ metadata.gz: 78094600ffac02fd7d46a7ccb3e6a1ac6f408e2a63fa4794b58ec081722c8d07e468f44d1809635a037b25946bc03c7fbb8002112c5cae9e9c892e3e551c6144
7
+ data.tar.gz: 57c9b9c5aaf85b8f002413e14adbe91f0625a544c7161a7154ac6dc6164e5f2184038f0836e0a596806375763bb6cb45f7ef48f1259f5e5c1121f3897430a2b0
data/README.md CHANGED
@@ -25,7 +25,7 @@ In your CSS manifest file:
25
25
 
26
26
  In your JavaScript manifest file:
27
27
 
28
- ```js
28
+ ```javascript
29
29
  //= require swipebox
30
30
  ```
31
31
 
@@ -46,17 +46,18 @@ $('.swipebox').swipebox();
46
46
  ```javascript
47
47
  useCSS : true, // false will force the use of jQuery for animations
48
48
  initialIndexOnArray: 0, // which image index to init when a array is passed
49
- hideBarsOnMobile : true, // false will show the caption and navbar on mobile devices
50
- hideBarsDelay : 3000, // 0 to always show caption and action bar
49
+ hideCloseButtonOnMobile : false, // true will hide the close button on mobile devices
50
+ hideBarsDelay : 3000, // delay before hiding bars on desktop
51
51
  videoMaxWidth : 1140, // videos max width
52
52
  beforeOpen: function(){} , // called before opening
53
+ afterOpen: null, // called after opening
53
54
  afterClose: function(){}, // called after closing
54
55
  loopAtEnd: false // true will return to the first image after the last image is reached
55
56
  ```
56
57
 
57
58
  Look at the original [Swipebox repo](https://github.com/brutaldesign/swipebox#usage) for more.
58
59
 
59
- I have modified source a bit from the 1.2.9 version:
60
+ I have modified source a bit from the 1.3.0.1 version:
60
61
  - SCSS instead of CSS because we need the `asset-url` helpers
61
62
  - .png -> .svg via class not hardcoded image path
62
63
 
@@ -1,3 +1,3 @@
1
1
  module Swipebox
2
- VERSION = '1.2.9'
2
+ VERSION = '1.3.0.1'
3
3
  end
@@ -1,30 +1,3 @@
1
-
2
-
3
- Started GET "/assets/swipebox.js" for 127.0.0.1 at 2013-12-04 17:13:52 +0100
4
-
5
-
6
- Started GET "/assets/swipebox.css" for 127.0.0.1 at 2013-12-04 17:13:52 +0100
7
-
8
-
9
- Started GET "/assets/swipebox.css" for 127.0.0.1 at 2013-12-04 17:13:52 +0100
10
-
11
-
12
- Started GET "/assets/swipebox.js" for 127.0.0.1 at 2013-12-04 17:14:12 +0100
13
-
14
-
15
- Started GET "/assets/swipebox.css" for 127.0.0.1 at 2013-12-04 17:14:12 +0100
16
-
17
-
18
- Started GET "/assets/swipebox.css" for 127.0.0.1 at 2013-12-04 17:14:12 +0100
19
- Started GET "/assets/swipebox.js" for 127.0.0.1 at 2013-12-04 17:16:28 +0100
20
- Started GET "/assets/swipebox.css" for 127.0.0.1 at 2013-12-04 17:16:28 +0100
21
- Started GET "/assets/swipebox.css" for 127.0.0.1 at 2013-12-04 17:16:28 +0100
22
- Started GET "/assets/swipebox.js" for 127.0.0.1 at 2013-12-04 17:16:37 +0100
23
- Started GET "/assets/swipebox.css" for 127.0.0.1 at 2013-12-04 17:16:37 +0100
24
- Started GET "/assets/swipebox.css" for 127.0.0.1 at 2013-12-04 17:16:37 +0100
25
- Started GET "/assets/swipebox.js" for 127.0.0.1 at 2014-09-03 16:45:29 +0200
26
- Started GET "/assets/swipebox.css" for 127.0.0.1 at 2014-09-03 16:45:29 +0200
27
- Started GET "/assets/swipebox.css" for 127.0.0.1 at 2014-09-03 16:45:29 +0200
28
- Started GET "/assets/swipebox.css" for 127.0.0.1 at 2014-09-03 16:47:35 +0200
29
- Started GET "/assets/swipebox.css" for 127.0.0.1 at 2014-09-03 16:47:35 +0200
30
- Started GET "/assets/swipebox.js" for 127.0.0.1 at 2014-09-03 16:47:35 +0200
1
+ Started GET "/assets/swipebox.css" for 127.0.0.1 at 2014-10-07 16:00:18 +0200
2
+ Started GET "/assets/swipebox.css" for 127.0.0.1 at 2014-10-07 16:00:19 +0200
3
+ Started GET "/assets/swipebox.js" for 127.0.0.1 at 2014-10-07 16:00:19 +0200
@@ -1,4 +1,4 @@
1
- /*! Swipebox v1.2.9 | Constantin Saguin csag.co | MIT License | github.com/brutaldesign/swipebox */
1
+ /*! Swipebox v1.3.0.1 | Constantin Saguin csag.co | MIT License | github.com/brutaldesign/swipebox */
2
2
 
3
3
  ;( function ( window, document, $, undefined ) {
4
4
 
@@ -10,15 +10,14 @@
10
10
  useCSS : true,
11
11
  useSVG : true,
12
12
  initialIndexOnArray : 0,
13
- closeBySwipe: true,
14
- hideBarsOnMobile : true,
13
+ hideCloseButtonOnMobile : false,
15
14
  hideBarsDelay : 3000,
16
15
  videoMaxWidth : 1140,
17
- vimeoColor : 'CCCCCC',
16
+ vimeoColor : 'cccccc',
18
17
  beforeOpen: null,
19
18
  afterOpen: null,
20
19
  afterClose: null,
21
- loopAtEnd: false
20
+ loopAtEnd: false
22
21
  },
23
22
 
24
23
  plugin = this,
@@ -31,26 +30,33 @@
31
30
  supportSVG = !! document.createElementNS && !! document.createElementNS( 'http://www.w3.org/2000/svg', 'svg').createSVGRect,
32
31
  winWidth = window.innerWidth ? window.innerWidth : $( window ).width(),
33
32
  winHeight = window.innerHeight ? window.innerHeight : $( window ).height(),
33
+ currentX = 0,
34
34
  /* jshint multistr: true */
35
35
  html = '<div id="swipebox-overlay">\
36
- <div id="swipebox-slider"></div>\
37
- <div id="swipebox-caption"></div>\
38
- <div id="swipebox-action">\
36
+ <div id="swipebox-container">\
37
+ <div id="swipebox-slider"></div>\
38
+ <div id="swipebox-top-bar">\
39
+ <div id="swipebox-title"></div>\
40
+ </div>\
41
+ <div id="swipebox-bottom-bar">\
42
+ <div id="swipebox-arrows">\
43
+ <a id="swipebox-prev"></a>\
44
+ <a id="swipebox-next"></a>\
45
+ </div>\
46
+ </div>\
39
47
  <a id="swipebox-close"></a>\
40
- <a id="swipebox-prev"></a>\
41
- <a id="swipebox-next"></a>\
42
48
  </div>\
43
49
  </div>';
44
50
 
45
51
  plugin.settings = {};
46
52
 
47
- $.swipebox.close = function (){
48
- ui.closeSlide();
49
- };
53
+ $.swipebox.close = function () {
54
+ ui.closeSlide();
55
+ };
50
56
 
51
- $.swipebox.extend = function (){
52
- return ui;
53
- }
57
+ $.swipebox.extend = function () {
58
+ return ui;
59
+ };
54
60
 
55
61
  plugin.init = function() {
56
62
 
@@ -71,7 +77,6 @@
71
77
  if ( event.target.parentNode.className === 'slide current' ) {
72
78
 
73
79
  return false;
74
-
75
80
  }
76
81
 
77
82
  if ( ! $.isArray( elem ) ) {
@@ -132,8 +137,8 @@
132
137
  ui = {
133
138
 
134
139
  /**
135
- * Initiate Swipebox
136
- */
140
+ * Initiate Swipebox
141
+ */
137
142
  init : function( index ) {
138
143
  if ( plugin.settings.beforeOpen ) {
139
144
  plugin.settings.beforeOpen();
@@ -151,43 +156,19 @@
151
156
  },
152
157
 
153
158
  /**
154
- * Built HTML containers and fire main functions
155
- */
159
+ * Built HTML containers and fire main functions
160
+ */
156
161
  build : function () {
157
162
  var $this = this, bg;
158
163
 
159
164
  $( 'body' ).append( html );
160
165
 
161
- if ( $this.doCssTrans() ) {
162
- $( '#swipebox-slider' ).css( {
163
- '-webkit-transition' : 'left 0.4s ease',
164
- '-moz-transition' : 'left 0.4s ease',
165
- '-o-transition' : 'left 0.4s ease',
166
- '-khtml-transition' : 'left 0.4s ease',
167
- 'transition' : 'left 0.4s ease'
168
- } );
169
- $( '#swipebox-overlay' ).css( {
170
- '-webkit-transition' : 'opacity 1s ease',
171
- '-moz-transition' : 'opacity 1s ease',
172
- '-o-transition' : 'opacity 1s ease',
173
- '-khtml-transition' : 'opacity 1s ease',
174
- 'transition' : 'opacity 1s ease'
175
- } );
176
- $( '#swipebox-action, #swipebox-caption' ).css( {
177
- '-webkit-transition' : '0.5s',
178
- '-moz-transition' : '0.5s',
179
- '-o-transition' : '0.5s',
180
- '-khtml-transition' : '0.5s',
181
- 'transition' : '0.5s'
182
- } );
183
- }
184
-
185
166
  if ( supportSVG && plugin.settings.useSVG === true ) {
186
167
  $('#swipebox-prev, #swipebox-next, #swipebox-close').addClass('svg');
187
168
  }
188
169
 
189
- if ( isMobile && plugin.settings.hideBarsOnMobile === true ) {
190
- $( '#swipebox-action, #swipebox-caption' ).hide();
170
+ if ( isMobile ) {
171
+ $( '#swipebox-bottom-bar, #swipebox-top-bar' ).remove();
191
172
  }
192
173
 
193
174
  $.each( elements, function() {
@@ -210,8 +191,8 @@
210
191
  },
211
192
 
212
193
  /**
213
- * Set dimensions depending on windows width and height
214
- */
194
+ * Set dimensions depending on windows width and height
195
+ */
215
196
  setDim : function () {
216
197
 
217
198
  var width, height, sliderCss = {};
@@ -246,8 +227,8 @@
246
227
  },
247
228
 
248
229
  /**
249
- * Reset dimensions on window resize envent
250
- */
230
+ * Reset dimensions on window resize envent
231
+ */
251
232
  resize : function () {
252
233
  var $this = this;
253
234
 
@@ -257,8 +238,8 @@
257
238
  },
258
239
 
259
240
  /**
260
- * Check if device supports CSS transitions
261
- */
241
+ * Check if device supports CSS transitions
242
+ */
262
243
  supportTransition : function () {
263
244
 
264
245
  var prefixes = 'transition WebkitTransition MozTransition OTransition msTransition KhtmlTransition'.split( ' ' ),
@@ -273,8 +254,8 @@
273
254
  },
274
255
 
275
256
  /**
276
- * Check if CSS transitions are allowed (options + devicesupport)
277
- */
257
+ * Check if CSS transitions are allowed (options + devicesupport)
258
+ */
278
259
  doCssTrans : function () {
279
260
  if ( plugin.settings.useCSS && this.supportTransition() ) {
280
261
  return true;
@@ -282,20 +263,24 @@
282
263
  },
283
264
 
284
265
  /**
285
- * Touch navigation
286
- */
266
+ * Touch navigation
267
+ */
287
268
  gesture : function () {
288
269
 
289
270
  var $this = this,
290
- distance = null,
291
- vDistance = null,
271
+ index,
272
+ hDistance,
273
+ vDistance,
274
+ hDistanceLast,
275
+ vDistanceLast,
276
+ hDistancePercent,
292
277
  vSwipe = false,
293
- swipMinDistance = 10,
278
+ hSwipe = false,
279
+ hSwipMinDistance = 10,
294
280
  vSwipMinDistance = 50,
295
281
  startCoords = {},
296
282
  endCoords = {},
297
-
298
- bars = $( '#swipebox-caption, #swipebox-action' ),
283
+ bars = $( '#swipebox-top-bar, #swipebox-bottom-bar' ),
299
284
  slider = $( '#swipebox-slider' );
300
285
 
301
286
  bars.addClass( 'visible-bars' );
@@ -304,17 +289,23 @@
304
289
  $( 'body' ).bind( 'touchstart', function( event ) {
305
290
 
306
291
  $( this ).addClass( 'touching' );
307
-
292
+ index = $( '#swipebox-slider .slide' ).index( $( '#swipebox-slider .slide.current' ) );
308
293
  endCoords = event.originalEvent.targetTouches[0];
309
294
  startCoords.pageX = event.originalEvent.targetTouches[0].pageX;
310
295
  startCoords.pageY = event.originalEvent.targetTouches[0].pageY;
311
296
 
297
+ $( '#swipebox-slider' ).css( {
298
+ '-webkit-transform' : 'translate3d(' + currentX +'%, 0, 0)',
299
+ 'transform' : 'translate3d(' + currentX + '%, 0, 0)'
300
+ } );
301
+
312
302
  $( '.touching' ).bind( 'touchmove',function( event ) {
313
303
  event.preventDefault();
314
304
  event.stopPropagation();
315
305
  endCoords = event.originalEvent.targetTouches[0];
316
306
 
317
- if ( plugin.settings.closeBySwipe ) {
307
+ if ( ! hSwipe ) {
308
+ vDistanceLast = vDistance;
318
309
  vDistance = endCoords.pageY - startCoords.pageY;
319
310
  if ( Math.abs( vDistance ) >= vSwipMinDistance || vSwipe ) {
320
311
  var opacity = 0.75 - Math.abs(vDistance) / slider.height();
@@ -326,6 +317,53 @@
326
317
  }
327
318
  }
328
319
 
320
+ hDistanceLast = hDistance;
321
+ hDistance = endCoords.pageX - startCoords.pageX;
322
+ hDistancePercent = hDistance * 100 / winWidth;
323
+
324
+ if ( ! hSwipe && ! vSwipe && Math.abs( hDistance ) >= hSwipMinDistance ) {
325
+ $( '#swipebox-slider' ).css( {
326
+ '-webkit-transition' : '',
327
+ 'transition' : ''
328
+ } );
329
+ hSwipe = true;
330
+ }
331
+
332
+ if ( hSwipe ) {
333
+
334
+ // swipe left
335
+ if ( 0 < hDistance ) {
336
+
337
+ // first slide
338
+ if ( 0 === index ) {
339
+ // console.log( 'first' );
340
+ $( '#swipebox-overlay' ).addClass( 'leftSpringTouch' );
341
+ } else {
342
+ // Follow gesture
343
+ $( '#swipebox-overlay' ).removeClass( 'leftSpringTouch' ).removeClass( 'rightSpringTouch' );
344
+ $( '#swipebox-slider' ).css( {
345
+ '-webkit-transform' : 'translate3d(' + ( currentX + hDistancePercent ) +'%, 0, 0)',
346
+ 'transform' : 'translate3d(' + ( currentX + hDistancePercent ) + '%, 0, 0)'
347
+ } );
348
+ }
349
+
350
+ // swipe rught
351
+ } else if ( 0 > hDistance ) {
352
+
353
+ // last Slide
354
+ if ( elements.length === index +1 ) {
355
+ // console.log( 'last' );
356
+ $( '#swipebox-overlay' ).addClass( 'rightSpringTouch' );
357
+ } else {
358
+ $( '#swipebox-overlay' ).removeClass( 'leftSpringTouch' ).removeClass( 'rightSpringTouch' );
359
+ $( '#swipebox-slider' ).css( {
360
+ '-webkit-transform' : 'translate3d(' + ( currentX + hDistancePercent ) +'%, 0, 0)',
361
+ 'transform' : 'translate3d(' + ( currentX + hDistancePercent ) + '%, 0, 0)'
362
+ } );
363
+ }
364
+
365
+ }
366
+ }
329
367
  } );
330
368
 
331
369
  return false;
@@ -334,8 +372,19 @@
334
372
  event.preventDefault();
335
373
  event.stopPropagation();
336
374
 
337
- if ( plugin.settings.closeBySwipe ) {
338
- if ( slider.css( 'opacity' ) <= 0.5) {
375
+ $( '#swipebox-slider' ).css( {
376
+ '-webkit-transition' : '-webkit-transform 0.4s ease',
377
+ 'transition' : 'transform 0.4s ease'
378
+ } );
379
+
380
+ vDistance = endCoords.pageY - startCoords.pageY;
381
+ hDistance = endCoords.pageX - startCoords.pageX;
382
+ hDistancePercent = hDistance*100/winWidth;
383
+
384
+ // Swipe to bottom to close
385
+ if ( vSwipe ) {
386
+ vSwipe = false;
387
+ if ( Math.abs( vDistance ) >= 2 * vSwipMinDistance && Math.abs( vDistance ) > Math.abs( vDistanceLast ) ) {
339
388
  var vOffset = vDistance > 0 ? slider.height() : - slider.height();
340
389
  slider.animate( { top: vOffset + 'px', 'opacity': 0 },
341
390
  300,
@@ -346,25 +395,22 @@
346
395
  slider.animate( { top: 0, 'opacity': 1 }, 300 );
347
396
  }
348
397
 
349
- if ( vSwipe ) {
350
- vSwipe = false;
351
- return;
352
- }
353
- }
354
-
355
- distance = endCoords.pageX - startCoords.pageX;
398
+ } else if ( hSwipe ) {
356
399
 
357
- if ( distance >= swipMinDistance ) {
400
+ hSwipe = false;
358
401
 
359
402
  // swipeLeft
360
- $this.getPrev();
403
+ if( hDistance >= hSwipMinDistance && hDistance >= hDistanceLast) {
361
404
 
362
- } else if ( distance <= - swipMinDistance ) {
405
+ $this.getPrev();
363
406
 
364
407
  // swipeRight
365
- $this.getNext();
408
+ } else if ( hDistance <= -hSwipMinDistance && hDistance <= hDistanceLast) {
366
409
 
367
- } else {
410
+ $this.getNext();
411
+ }
412
+
413
+ } else { // Top and bottom bars have been removed on touchable devices
368
414
  // tap
369
415
  if ( ! bars.hasClass( 'visible-bars' ) ) {
370
416
  $this.showBars();
@@ -375,15 +421,20 @@
375
421
  }
376
422
  }
377
423
 
424
+ $( '#swipebox-slider' ).css( {
425
+ '-webkit-transform' : 'translate3d(' + currentX + '%, 0, 0)',
426
+ 'transform' : 'translate3d(' + currentX + '%, 0, 0)'
427
+ } );
428
+
429
+ $( '#swipebox-overlay' ).removeClass( 'leftSpringTouch' ).removeClass( 'rightSpringTouch' );
378
430
  $( '.touching' ).off( 'touchmove' ).removeClass( 'touching' );
379
431
 
380
432
  } );
381
-
382
433
  },
383
434
 
384
435
  /**
385
- * Set timer to hide the action bars
386
- */
436
+ * Set timer to hide the action bars
437
+ */
387
438
  setTimeout: function () {
388
439
  if ( plugin.settings.hideBarsDelay > 0 ) {
389
440
  var $this = this;
@@ -398,23 +449,23 @@
398
449
  },
399
450
 
400
451
  /**
401
- * Clear timer
402
- */
452
+ * Clear timer
453
+ */
403
454
  clearTimeout: function () {
404
455
  window.clearTimeout( this.timeout );
405
456
  this.timeout = null;
406
457
  },
407
458
 
408
459
  /**
409
- * Show navigation and title bars
410
- */
460
+ * Show navigation and title bars
461
+ */
411
462
  showBars : function () {
412
- var bars = $( '#swipebox-caption, #swipebox-action' );
463
+ var bars = $( '#swipebox-top-bar, #swipebox-bottom-bar' );
413
464
  if ( this.doCssTrans() ) {
414
465
  bars.addClass( 'visible-bars' );
415
466
  } else {
416
- $( '#swipebox-caption' ).animate( { top : 0 }, 500 );
417
- $( '#swipebox-action' ).animate( { bottom : 0 }, 500 );
467
+ $( '#swipebox-top-bar' ).animate( { top : 0 }, 500 );
468
+ $( '#swipebox-bottom-bar' ).animate( { bottom : 0 }, 500 );
418
469
  setTimeout( function() {
419
470
  bars.addClass( 'visible-bars' );
420
471
  }, 1000 );
@@ -422,15 +473,15 @@
422
473
  },
423
474
 
424
475
  /**
425
- * Hide navigation and title bars
426
- */
476
+ * Hide navigation and title bars
477
+ */
427
478
  hideBars : function () {
428
- var bars = $( '#swipebox-caption, #swipebox-action' );
479
+ var bars = $( '#swipebox-top-bar, #swipebox-bottom-bar' );
429
480
  if ( this.doCssTrans() ) {
430
481
  bars.removeClass( 'visible-bars' );
431
482
  } else {
432
- $( '#swipebox-caption' ).animate( { top : '-50px' }, 500 );
433
- $( '#swipebox-action' ).animate( { bottom : '-50px' }, 500 );
483
+ $( '#swipebox-top-bar' ).animate( { top : '-50px' }, 500 );
484
+ $( '#swipebox-bottom-bar' ).animate( { bottom : '-50px' }, 500 );
434
485
  setTimeout( function() {
435
486
  bars.removeClass( 'visible-bars' );
436
487
  }, 1000 );
@@ -438,11 +489,11 @@
438
489
  },
439
490
 
440
491
  /**
441
- * Animate navigation and top bars
442
- */
492
+ * Animate navigation and top bars
493
+ */
443
494
  animBars : function () {
444
495
  var $this = this,
445
- bars = $( '#swipebox-caption, #swipebox-action' );
496
+ bars = $( '#swipebox-top-bar, #swipebox-bottom-bar' );
446
497
 
447
498
  bars.addClass( 'visible-bars' );
448
499
  $this.setTimeout();
@@ -454,24 +505,23 @@
454
505
  }
455
506
  } );
456
507
 
457
- $( '#swipebox-action' ).hover( function() {
508
+ $( '#swipebox-bottom-bar' ).hover( function() {
458
509
  $this.showBars();
459
510
  bars.addClass( 'visible-bars' );
460
511
  $this.clearTimeout();
461
512
 
462
- }, function() {
463
- if (plugin.settings.hideBarsDelay > 0){
513
+ }, function() {
514
+ if ( plugin.settings.hideBarsDelay > 0 ) {
464
515
  bars.removeClass( 'visible-bars' );
465
516
  $this.setTimeout();
466
- }
467
-
468
- } );
517
+ }
469
518
 
519
+ } );
470
520
  },
471
521
 
472
522
  /**
473
- * Keyboard navigation
474
- */
523
+ * Keyboard navigation
524
+ */
475
525
  keyboard : function () {
476
526
  var $this = this;
477
527
  $( window ).bind( 'keyup', function( event ) {
@@ -489,21 +539,24 @@
489
539
  } else if ( event.keyCode === 27 ) {
490
540
 
491
541
  $this.closeSlide();
492
-
493
542
  }
494
543
  } );
495
544
  },
496
545
 
497
546
  /**
498
- * Navigation events : go to next slide, go to prevous slide and close
499
- */
547
+ * Navigation events : go to next slide, go to prevous slide and close
548
+ */
500
549
  actions : function () {
501
550
  var $this = this,
502
551
  action = 'touchend click'; // Just detect for both event types to allow for multi-input
503
552
 
504
553
  if ( elements.length < 2 ) {
505
554
 
506
- $( '#swipebox-prev, #swipebox-next' ).hide();
555
+ $( '#swipebox-bottom-bar' ).hide();
556
+
557
+ if ( undefined === elements[ 1 ] ) {
558
+ $( '#swipebox-top-bar' ).hide();
559
+ }
507
560
 
508
561
  } else {
509
562
  $( '#swipebox-prev' ).bind( action, function( event ) {
@@ -527,15 +580,21 @@
527
580
  },
528
581
 
529
582
  /**
530
- * Set current slide
531
- */
583
+ * Set current slide
584
+ */
532
585
  setSlide : function ( index, isFirst ) {
586
+
533
587
  isFirst = isFirst || false;
534
588
 
535
589
  var slider = $( '#swipebox-slider' );
536
590
 
591
+ currentX = -index*100;
592
+
537
593
  if ( this.doCssTrans() ) {
538
- slider.css( { left : ( -index*100 )+'%' } );
594
+ slider.css( {
595
+ '-webkit-transform' : 'translate3d(' + (-index*100)+'%, 0, 0)',
596
+ 'transform' : 'translate3d(' + (-index*100)+'%, 0, 0)'
597
+ } );
539
598
  } else {
540
599
  slider.animate( { left : ( -index*100 )+'%' } );
541
600
  }
@@ -552,32 +611,38 @@
552
611
 
553
612
  if ( index === 0 ) {
554
613
  $( '#swipebox-prev' ).addClass( 'disabled' );
555
- } else if ( index === elements.length - 1 && plugin.settings.loopAtEnd != true) {
614
+ } else if ( index === elements.length - 1 && plugin.settings.loopAtEnd !== true ) {
556
615
  $( '#swipebox-next' ).addClass( 'disabled' );
557
616
  }
558
617
  },
559
618
 
560
619
  /**
561
- * Open slide
562
- */
620
+ * Open slide
621
+ */
563
622
  openSlide : function ( index ) {
564
623
  $( 'html' ).addClass( 'swipebox-html' );
565
624
  if ( isTouch ) {
566
625
  $( 'html' ).addClass( 'swipebox-touch' );
626
+
627
+ if ( plugin.settings.hideCloseButtonOnMobile ) {
628
+ $( 'html' ).addClass( 'swipebox-no-close-button' );
629
+ }
630
+ } else {
631
+ $( 'html' ).addClass( 'swipebox-no-touch' );
567
632
  }
568
633
  $( window ).trigger( 'resize' ); // fix scroll bar visibility on desktop
569
634
  this.setSlide( index, true );
570
635
  },
571
636
 
572
637
  /**
573
- * Set a time out if the media is a video
574
- */
638
+ * Set a time out if the media is a video
639
+ */
575
640
  preloadMedia : function ( index ) {
576
641
  var $this = this,
577
642
  src = null;
578
643
 
579
- if ( elements[index] !== undefined ) {
580
- src = elements[index].href;
644
+ if ( elements[ index ] !== undefined ) {
645
+ src = elements[ index ].href;
581
646
  }
582
647
 
583
648
  if ( ! $this.isVideo( src ) ) {
@@ -590,50 +655,58 @@
590
655
  },
591
656
 
592
657
  /**
593
- * Open
594
- */
658
+ * Open
659
+ */
595
660
  openMedia : function ( index ) {
596
661
  var $this = this,
597
- src = null;
662
+ src,
663
+ slide;
598
664
 
599
- if ( elements[index] !== undefined ) {
600
- src = elements[index].href;
665
+ if ( elements[ index ] !== undefined ) {
666
+ src = elements[ index ].href;
601
667
  }
602
668
 
603
- if (index < 0 || index >= elements.length) {
669
+ if ( index < 0 || index >= elements.length ) {
604
670
  return false;
605
671
  }
606
672
 
673
+ slide = $( '#swipebox-slider .slide' ).eq( index );
674
+
607
675
  if ( ! $this.isVideo( src ) ) {
676
+ slide.addClass( 'slide-loading' );
608
677
  $this.loadMedia( src, function() {
609
- $( '#swipebox-slider .slide' ).eq( index ).html( this );
678
+ slide.removeClass( 'slide-loading' );
679
+ slide.html( this );
610
680
  } );
611
681
  } else {
612
- $( '#swipebox-slider .slide' ).eq( index ).html( $this.getVideo( src ) );
682
+ slide.html( $this.getVideo( src ) );
613
683
  }
614
684
 
615
685
  },
616
686
 
617
687
  /**
618
- * Set link title attribute as caption
619
- */
688
+ * Set link title attribute as caption
689
+ */
620
690
  setTitle : function ( index ) {
621
691
  var title = null;
622
692
 
623
- $( '#swipebox-caption' ).empty();
693
+ $( '#swipebox-title' ).empty();
624
694
 
625
- if ( elements[index] !== undefined ) {
626
- title = elements[index].title;
695
+ if ( elements[ index ] !== undefined ) {
696
+ title = elements[ index ].title;
627
697
  }
628
698
 
629
699
  if ( title ) {
630
- $( '#swipebox-caption' ).append( title );
700
+ $( '#swipebox-top-bar' ).show();
701
+ $( '#swipebox-title' ).append( title );
702
+ } else {
703
+ $( '#swipebox-top-bar' ).hide();
631
704
  }
632
705
  },
633
706
 
634
707
  /**
635
- * Check if the URL is a video
636
- */
708
+ * Check if the URL is a video
709
+ */
637
710
  isVideo : function ( src ) {
638
711
 
639
712
  if ( src ) {
@@ -641,17 +714,17 @@
641
714
  return true;
642
715
  }
643
716
 
644
- if (src.toLowerCase().indexOf( "swipeboxvideo=1" ) >= 0){
717
+ if ( src.toLowerCase().indexOf( 'swipeboxvideo=1' ) >= 0 ) {
645
718
 
646
- return true;
647
- }
719
+ return true;
720
+ }
648
721
  }
649
722
 
650
723
  },
651
724
 
652
725
  /**
653
- * Get video iframe code from URL
654
- */
726
+ * Get video iframe code from URL
727
+ */
655
728
  getVideo : function( url ) {
656
729
  var iframe = '',
657
730
  youtubeUrl = url.match( /watch\?v=([a-zA-Z0-9\-_]+)/ ),
@@ -669,18 +742,18 @@
669
742
 
670
743
  }
671
744
 
672
- if (youtubeShortUrl || youtubeShortUrl || vimeoUrl){
745
+ if ( youtubeUrl || youtubeShortUrl || vimeoUrl ) {
673
746
 
674
- } else {
675
- iframe = '<iframe width="560" height="315" src="' + url + '" frameborder="0" allowfullscreen></iframe>';
676
- }
747
+ } else {
748
+ iframe = '<iframe width="560" height="315" src="' + url + '" frameborder="0" allowfullscreen></iframe>';
749
+ }
677
750
 
678
751
  return '<div class="swipebox-video-container" style="max-width:' + plugin.settings.videomaxWidth + 'px"><div class="swipebox-video">'+iframe+'</div></div>';
679
752
  },
680
753
 
681
754
  /**
682
- * Load image
683
- */
755
+ * Load image
756
+ */
684
757
  loadMedia : function ( src, callback ) {
685
758
  if ( ! this.isVideo( src ) ) {
686
759
  var img = $( '<img>' ).on( 'load', function() {
@@ -692,57 +765,60 @@
692
765
  },
693
766
 
694
767
  /**
695
- * Get next slide
696
- */
768
+ * Get next slide
769
+ */
697
770
  getNext : function () {
698
771
  var $this = this,
772
+ src,
699
773
  index = $( '#swipebox-slider .slide' ).index( $( '#swipebox-slider .slide.current' ) );
700
- if ( index+1 < elements.length ) {
701
- var src = $( '#swipebox-slider .slide' ).eq(index).contents().find("iframe").attr("src");
702
- $( '#swipebox-slider .slide' ).eq(index).contents().find("iframe").attr("src",src);
774
+ if ( index + 1 < elements.length ) {
775
+
776
+ src = $( '#swipebox-slider .slide' ).eq( index ).contents().find( 'iframe' ).attr( 'src' );
777
+ $( '#swipebox-slider .slide' ).eq( index ).contents().find( 'iframe' ).attr( 'src', src );
703
778
  index++;
704
779
  $this.setSlide( index );
705
780
  $this.preloadMedia( index+1 );
706
781
  } else {
707
782
 
708
- if (plugin.settings.loopAtEnd === true){
709
- var src = $( '#swipebox-slider .slide' ).eq(index).contents().find("iframe").attr("src");
710
- $( '#swipebox-slider .slide' ).eq(index).contents().find("iframe").attr("src",src);
711
- index = 0;
712
- $this.preloadMedia( index );
713
- $this.setSlide( index );
714
- $this.preloadMedia( index + 1 );
715
- } else {
716
- $( '#swipebox-slider' ).addClass( 'rightSpring' );
717
- setTimeout( function() {
718
- $( '#swipebox-slider' ).removeClass( 'rightSpring' );
719
- }, 500 );
720
- }
783
+ if ( plugin.settings.loopAtEnd === true ) {
784
+ src = $( '#swipebox-slider .slide' ).eq( index ).contents().find( 'iframe' ).attr( 'src' );
785
+ $( '#swipebox-slider .slide' ).eq( index ).contents().find( 'iframe' ).attr( 'src', src );
786
+ index = 0;
787
+ $this.preloadMedia( index );
788
+ $this.setSlide( index );
789
+ $this.preloadMedia( index + 1 );
790
+ } else {
791
+ $( '#swipebox-overlay' ).addClass( 'rightSpring' );
792
+ setTimeout( function() {
793
+ $( '#swipebox-overlay' ).removeClass( 'rightSpring' );
794
+ }, 500 );
795
+ }
721
796
  }
722
797
  },
723
798
 
724
799
  /**
725
- * Get previous slide
726
- */
800
+ * Get previous slide
801
+ */
727
802
  getPrev : function () {
728
- var index = $( '#swipebox-slider .slide' ).index( $( '#swipebox-slider .slide.current' ) );
803
+ var index = $( '#swipebox-slider .slide' ).index( $( '#swipebox-slider .slide.current' ) ),
804
+ src;
729
805
  if ( index > 0 ) {
730
- var src = $( '#swipebox-slider .slide' ).eq(index).contents().find("iframe").attr("src");
731
- $( '#swipebox-slider .slide' ).eq(index).contents().find("iframe").attr("src",src);
806
+ src = $( '#swipebox-slider .slide' ).eq( index ).contents().find( 'iframe').attr( 'src' );
807
+ $( '#swipebox-slider .slide' ).eq( index ).contents().find( 'iframe' ).attr( 'src', src );
732
808
  index--;
733
809
  this.setSlide( index );
734
810
  this.preloadMedia( index-1 );
735
811
  } else {
736
- $( '#swipebox-slider' ).addClass( 'leftSpring' );
737
- setTimeout( function() {
738
- $( '#swipebox-slider' ).removeClass( 'leftSpring' );
739
- }, 500 );
740
- }
812
+ $( '#swipebox-overlay' ).addClass( 'leftSpring' );
813
+ setTimeout( function() {
814
+ $( '#swipebox-overlay' ).removeClass( 'leftSpring' );
815
+ }, 500 );
816
+ }
741
817
  },
742
818
 
743
819
  /**
744
- * Close
745
- */
820
+ * Close
821
+ */
746
822
  closeSlide : function () {
747
823
  $( 'html' ).removeClass( 'swipebox-html' );
748
824
  $( 'html' ).removeClass( 'swipebox-touch' );
@@ -751,8 +827,8 @@
751
827
  },
752
828
 
753
829
  /**
754
- * Destroy the whole thing
755
- */
830
+ * Destroy the whole thing
831
+ */
756
832
  destroy : function () {
757
833
  $( window ).unbind( 'keyup' );
758
834
  $( 'body' ).unbind( 'touchstart' );
@@ -771,14 +847,13 @@
771
847
 
772
848
  $.swipebox.isOpen = false;
773
849
 
774
- if ( plugin.settings.afterClose ){
850
+ if ( plugin.settings.afterClose ) {
775
851
  plugin.settings.afterClose();
776
852
  }
777
853
  }
778
854
  };
779
855
 
780
856
  plugin.init();
781
-
782
857
  };
783
858
 
784
859
  $.fn.swipebox = function( options ) {