Permalink
Browse files

Fixes lightbox nav in IE10+, better error handling for swipe etc

  • Loading branch information...
1 parent bfbbf7c commit 0b39fe1fb3399c3ff27d86f5bef76330fc0f94db @davidhellsing davidhellsing committed Jan 9, 2014
Showing with 49 additions and 35 deletions.
  1. +49 −35 src/galleria.js
View
@@ -1,5 +1,5 @@
/**
- * Galleria v 1.3.3 2013-11-18
+ * Galleria v 1.3.4 2014-01-08
* http://galleria.io
*
* Licensed under the MIT license
@@ -1835,6 +1835,11 @@ Galleria = function() {
}
});
});
+
+ var n = self.getNext(index),
+ p = new Galleria.Picture(),
+ ndata = self.getData( n );
+ p.preload( self.isFullscreen() && ndata.big ? ndata.big : ndata.image );
}
// init the first rescale and attach callbacks
@@ -1975,7 +1980,7 @@ Galleria = function() {
active: false,
add: function(elem, to, from, hide) {
- if (!elem) {
+ if ( !elem || Galleria.TOUCH ) {
return;
}
if (!idle.bound) {
@@ -2178,12 +2183,17 @@ Galleria = function() {
},
appends = {};
- // IE8 fix for IE's transparent background event "feature"
- if ( IE && IE > 7 ) {
- cssMap.nextholder += 'background:#000;filter:alpha(opacity=0);';
- cssMap.prevholder += 'background:#000;filter:alpha(opacity=0);';
+ // fix for navigation hovers transparent background event "feature"
+ var exs = '';
+ if ( IE > 7 ) {
+ exs = IE < 9 ? 'background:#000;filter:alpha(opacity=0);' : 'background:rgba(0,0,0,0);';
+ } else {
+ exs = 'z-index:99999';
}
+ cssMap.nextholder += exs;
+ cssMap.prevholder += exs;
+
// create and insert CSS
$.each(cssMap, function( key, value ) {
css += '.galleria-'+prefix+key+'{'+value+'}';
@@ -2697,19 +2707,16 @@ Galleria.prototype = {
// check for canvas support
(function( can ) {
-
if ( !( 'getContext' in can ) ) {
can = null;
return;
}
-
_canvas = _canvas || {
elem: can,
context: can.getContext( '2d' ),
cache: {},
length: 0
};
-
}( doc.createElement( 'canvas' ) ) );
// bind the gallery to run when data is ready
@@ -2888,6 +2895,11 @@ Galleria.prototype = {
var index = M.max( 0, M.min( parseInt( page, 10 ), self.getDataLength() - 1 ) ),
data = self.getData(index);
+ $( self._thumbnails[ index ].container )
+ .addClass( 'active' )
+ .siblings( '.active' )
+ .removeClass( 'active' );
+
if ( !data ) {
return;
}
@@ -4727,6 +4739,22 @@ this.prependChild( 'info', 'myElement' );
return this;
},
+ _preload: function() {
+ if ( this._options.preload ) {
+ var p, i,
+ n = this.getNext(),
+ ndata;
+ try {
+ for ( i = this._options.preload; i > 0; i-- ) {
+ p = new Galleria.Picture();
+ ndata = this.getData( n );
+ p.preload( this.isFullscreen() && ndata.big ? ndata.big : ndata.image );
+ n = this.getNext( n );
+ }
+ } catch(e) {}
+ }
+ },
+
/**
Shows an image by index
@@ -4791,11 +4819,6 @@ this.prependChild( 'info', 'myElement' );
type: Galleria.LOADSTART
}));
- $( self._thumbnails[ index ].container )
- .addClass( 'active' )
- .siblings( '.active' )
- .removeClass( 'active' );
-
self.$('container').removeClass( 'videoplay' );
var complete = function() {
@@ -4808,10 +4831,12 @@ this.prependChild( 'info', 'myElement' );
self._playCheck();
};
+ self._preload();
+
window.setTimeout(function() {
// load if not ready
- if ( !image.ready ) {
+ if ( !image.ready || image.image.src != src ) {
if ( data.iframe && !data.image ) {
image.isIframe = true;
}
@@ -5008,21 +5033,7 @@ this.prependChild( 'info', 'myElement' );
}
// preload images
- if ( this._options.preload ) {
-
- var p, i,
- n = this.getNext(),
- ndata;
-
- try {
- for ( i = this._options.preload; i > 0; i-- ) {
- p = new Galleria.Picture();
- ndata = self.getData( n );
- p.preload( this.isFullscreen() && ndata.big ? ndata.big : ndata.image );
- n = self.getNext( n );
- }
- } catch(e) {}
- }
+ self._preload();
// show the next image, just in case
Utils.show( next.container );
@@ -6500,6 +6511,7 @@ $.extend( $.easing, {
});
+
// Forked version of Ainos Finger.js for native-style touch
Galleria.Finger = (function() {
@@ -6750,21 +6762,23 @@ Galleria.Finger = (function() {
// save animation parameters
this.anim = { start: this.pos, time: +new Date(), distance: distance, factor: factor, destination: this.to };
}
- // check if to has changed
- if ( this.anim.destination != this.to ) {
+ // check if to has changed or time has run out
+ var elapsed = +new Date() - this.anim.time;
+ var duration = this.config.duration*this.anim.factor;
+
+ if ( elapsed > duration || this.anim.destination != this.to ) {
this.anim = 0;
this.easing = this.easeout;
return;
}
// apply easing
this.pos = this.easing(
null,
- +new Date() - this.anim.time,
+ elapsed,
this.anim.start,
this.anim.distance,
- this.config.duration*this.anim.factor
+ duration
);
-
}
this.setX();
}

0 comments on commit 0b39fe1

Please sign in to comment.