|
|
@@ -1,4 +1,4 @@
|
|
|
-/*! PhotoSwipe - v4.1.0 - 2015-07-11
|
|
|
+/*! PhotoSwipe - v4.1.1 - 2015-12-24
|
|
|
* http://photoswipe.com
|
|
|
* Copyright (c) 2015 Dmitry Semenov; */
|
|
|
(function (root, factory) {
|
|
|
@@ -341,8 +341,7 @@ var _options = {
|
|
|
modal: true,
|
|
|
|
|
|
// not fully implemented yet
|
|
|
- scaleMode: 'fit', // TODO
|
|
|
- alwaysFadeIn: false // TODO
|
|
|
+ scaleMode: 'fit' // TODO
|
|
|
};
|
|
|
framework.extend(_options, options);
|
|
|
|
|
|
@@ -488,12 +487,11 @@ var _isOpen,
|
|
|
_moveMainScroll = function(x, dragging) {
|
|
|
|
|
|
if(!_options.loop && dragging) {
|
|
|
- // if of current item during scroll (float)
|
|
|
- var newSlideIndexOffset = _currentItemIndex + (_slideSize.x * _currPositionIndex - x)/_slideSize.x;
|
|
|
- var delta = Math.round(x - _mainScrollPos.x);
|
|
|
+ var newSlideIndexOffset = _currentItemIndex + (_slideSize.x * _currPositionIndex - x) / _slideSize.x,
|
|
|
+ delta = Math.round(x - _mainScrollPos.x);
|
|
|
|
|
|
if( (newSlideIndexOffset < 0 && delta > 0) ||
|
|
|
- (newSlideIndexOffset >= _getNumItems()-1 && delta < 0) ) {
|
|
|
+ (newSlideIndexOffset >= _getNumItems() - 1 && delta < 0) ) {
|
|
|
x = _mainScrollPos.x + delta * _options.mainScrollEndFriction;
|
|
|
}
|
|
|
}
|
|
|
@@ -810,7 +808,7 @@ var publicMethods = {
|
|
|
|
|
|
var i;
|
|
|
|
|
|
- self.framework = framework; // basic function
|
|
|
+ self.framework = framework; // basic functionality
|
|
|
self.template = template; // root DOM element of PhotoSwipe
|
|
|
self.bg = framework.getChildByClass(template, 'pswp__bg');
|
|
|
|
|
|
@@ -965,7 +963,7 @@ var publicMethods = {
|
|
|
framework.addClass(template, 'pswp--visible');
|
|
|
},
|
|
|
|
|
|
- // Closes the gallery, then destroy it
|
|
|
+ // Close the gallery, then destroy it
|
|
|
close: function() {
|
|
|
if(!_isOpen) {
|
|
|
return;
|
|
|
@@ -976,10 +974,10 @@ var publicMethods = {
|
|
|
_shout('close');
|
|
|
_unbindEvents();
|
|
|
|
|
|
- _showOrHide( self.currItem, null, true, self.destroy);
|
|
|
+ _showOrHide(self.currItem, null, true, self.destroy);
|
|
|
},
|
|
|
|
|
|
- // destroys gallery (unbinds events, cleans up intervals and timeouts to avoid memory leaks)
|
|
|
+ // destroys the gallery (unbinds events, cleans up intervals and timeouts to avoid memory leaks)
|
|
|
destroy: function() {
|
|
|
_shout('destroy');
|
|
|
|
|
|
@@ -996,7 +994,7 @@ var publicMethods = {
|
|
|
|
|
|
framework.unbind(self.scrollWrap, _downEvents, self);
|
|
|
|
|
|
- // we unbind lost event at the end, as closing animation may depend on it
|
|
|
+ // we unbind scroll event at the end, as closing animation may depend on it
|
|
|
framework.unbind(window, 'scroll', self);
|
|
|
|
|
|
_stopDragUpdateLoop();
|
|
|
@@ -1298,7 +1296,6 @@ var publicMethods = {
|
|
|
|
|
|
_roundPoint(destPanOffset);
|
|
|
|
|
|
- // _startZoomLevel = destZoomLevel;
|
|
|
var onUpdate = function(now) {
|
|
|
if(now === 1) {
|
|
|
_currZoomLevel = destZoomLevel;
|
|
|
@@ -1412,12 +1409,12 @@ var _gestureStartTime,
|
|
|
|
|
|
// find the closest parent DOM element
|
|
|
_closestElement = function(el, fn) {
|
|
|
- if(!el) {
|
|
|
+ if(!el || el === document) {
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
// don't search elements above pswp__scroll-wrap
|
|
|
- if(el.className && el.className.indexOf('pswp__scroll-wrap') > -1 ) {
|
|
|
+ if(el.getAttribute('class') && el.getAttribute('class').indexOf('pswp__scroll-wrap') > -1 ) {
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
@@ -2548,21 +2545,23 @@ var _showOrHideTimeout,
|
|
|
// if bounds aren't provided, just open gallery without animation
|
|
|
if(!duration || !thumbBounds || thumbBounds.x === undefined) {
|
|
|
|
|
|
- var finishWithoutAnimation = function() {
|
|
|
- _shout('initialZoom' + (out ? 'Out' : 'In') );
|
|
|
+ _shout('initialZoom' + (out ? 'Out' : 'In') );
|
|
|
|
|
|
- _currZoomLevel = item.initialZoomLevel;
|
|
|
- _equalizePoints(_panOffset, item.initialPosition );
|
|
|
- _applyCurrentZoomPan();
|
|
|
+ _currZoomLevel = item.initialZoomLevel;
|
|
|
+ _equalizePoints(_panOffset, item.initialPosition );
|
|
|
+ _applyCurrentZoomPan();
|
|
|
|
|
|
- // no transition
|
|
|
- template.style.opacity = out ? 0 : 1;
|
|
|
- _applyBgOpacity(1);
|
|
|
+ template.style.opacity = out ? 0 : 1;
|
|
|
+ _applyBgOpacity(1);
|
|
|
|
|
|
+ if(duration) {
|
|
|
+ setTimeout(function() {
|
|
|
+ onComplete();
|
|
|
+ }, duration);
|
|
|
+ } else {
|
|
|
onComplete();
|
|
|
- };
|
|
|
- finishWithoutAnimation();
|
|
|
-
|
|
|
+ }
|
|
|
+
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
@@ -2790,7 +2789,7 @@ var _getItemAt,
|
|
|
// if it's not image, we return zero bounds (content is not zoomable)
|
|
|
return item.bounds;
|
|
|
}
|
|
|
- return false;
|
|
|
+
|
|
|
},
|
|
|
|
|
|
|
|
|
@@ -2806,7 +2805,7 @@ var _getItemAt,
|
|
|
if(img) {
|
|
|
|
|
|
item.imageAppended = true;
|
|
|
- _setImageSize(item, img);
|
|
|
+ _setImageSize(item, img, (item === self.currItem && _renderMaxResolution) );
|
|
|
|
|
|
baseDiv.appendChild(img);
|
|
|
|
|
|
@@ -2906,7 +2905,7 @@ _registerModule('Controller', {
|
|
|
index = _getLoopedId(index);
|
|
|
var item = _getItemAt(index);
|
|
|
|
|
|
- if(!item || item.loaded || item.loading) {
|
|
|
+ if(!item || ((item.loaded || item.loading) && !_itemsNeedUpdate)) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
@@ -2934,7 +2933,7 @@ _registerModule('Controller', {
|
|
|
_listen('beforeChange', function(diff) {
|
|
|
|
|
|
var p = _options.preload,
|
|
|
- isNext = diff === null ? true : (diff > 0),
|
|
|
+ isNext = diff === null ? true : (diff >= 0),
|
|
|
preloadBefore = Math.min(p[0], _getNumItems() ),
|
|
|
preloadAfter = Math.min(p[1], _getNumItems() ),
|
|
|
i;
|