From cc99a07aff428e38686630a343e89487567bc7e0 Mon Sep 17 00:00:00 2001 From: Andreas Blaesius Date: Wed, 12 Aug 2020 18:57:49 +0200 Subject: [PATCH] build (js, css) --- dist/default-skin/default-skin.css | 28 +- dist/default-skin/default-skin.css.map | 2 +- dist/photoswipe-ui-default.js | 1460 ++++++++--------- dist/photoswipe.css | 4 +- dist/photoswipe.css.map | 2 +- dist/photoswipe.js | 2095 +++++++++++------------- 6 files changed, 1640 insertions(+), 1951 deletions(-) diff --git a/dist/default-skin/default-skin.css b/dist/default-skin/default-skin.css index d3e440332..49ea60ccd 100644 --- a/dist/default-skin/default-skin.css +++ b/dist/default-skin/default-skin.css @@ -165,7 +165,7 @@ .pswp__share-tooltip { z-index: 1620; position: absolute; - background: #FFF; + background: #fff; top: 56px; border-radius: 2px; display: block; @@ -216,27 +216,27 @@ a.pswp__share--facebook:before { top: -12px; right: 15px; border: 6px solid rgba(0, 0, 0, 0); - border-bottom-color: #FFF; + border-bottom-color: #fff; -webkit-pointer-events: none; -moz-pointer-events: none; pointer-events: none; } a.pswp__share--facebook:hover { - background: #3E5C9A; - color: #FFF; } + background: #3e5c9a; + color: #fff; } a.pswp__share--facebook:hover:before { - border-bottom-color: #3E5C9A; } + border-bottom-color: #3e5c9a; } a.pswp__share--twitter:hover { - background: #55ACEE; - color: #FFF; } + background: #55acee; + color: #fff; } a.pswp__share--pinterest:hover { - background: #CCC; - color: #CE272D; } + background: #ccc; + color: #ce272d; } a.pswp__share--download:hover { - background: #DDD; } + background: #ddd; } /* @@ -250,7 +250,7 @@ a.pswp__share--download:hover { height: 44px; font-size: 13px; line-height: 44px; - color: #FFF; + color: #fff; opacity: 0.75; padding: 0 10px; } @@ -267,7 +267,7 @@ a.pswp__share--download:hover { min-height: 44px; } .pswp__caption small { font-size: 11px; - color: #BBB; } + color: #bbb; } .pswp__caption__center { text-align: center; @@ -276,7 +276,7 @@ a.pswp__share--download:hover { font-size: 13px; padding: 10px; line-height: 20px; - color: #CCC; } + color: #ccc; } .pswp__caption--empty { display: none; } @@ -350,7 +350,7 @@ a.pswp__share--download:hover { box-sizing: border-box; width: 14px; height: 14px; - border: 2px solid #FFF; + border: 2px solid #fff; border-radius: 50%; border-left-color: transparent; border-bottom-color: transparent; diff --git a/dist/default-skin/default-skin.css.map b/dist/default-skin/default-skin.css.map index 01a02240c..a063adcff 100644 --- a/dist/default-skin/default-skin.css.map +++ b/dist/default-skin/default-skin.css.map @@ -6,5 +6,5 @@ "../../src/css/_main-settings.scss" ], "names": [], - "mappings": "AAAA,iFAAiF;AAEjF;;;;;;;;;;;EAWE;AASF;;;;GAIG;AAEH,wBAAwB;AACxB,AAAA,aAAa,CAAC;EACb,KAAK,EAAE,IAAI;EACX,MAAM,EAAE,IAAI;EACZ,QAAQ,EAAE,QAAQ;EAClB,UAAU,EAAE,IAAI;EAChB,MAAM,EAAE,OAAO;EACf,QAAQ,EAAE,OAAO;EACjB,kBAAkB,EAAE,IAAI;EACxB,OAAO,EAAE,KAAK;EACd,MAAM,EAAE,CAAC;EACT,OAAO,EAAE,CAAC;EACV,MAAM,EAAE,CAAC;EACT,KAAK,EAAE,KAAK;EACZ,OAAO,EAAE,IAAI;EACb,UAAU,EAAE,YAAY;EACxB,UAAU,EAAE,IAAI,GAgBhB;EA/BD,AAiBC,aAjBY,AAiBX,MAAM,EAjBR,aAAa,AAkBX,MAAM,CAAC;IACP,OAAO,EAAE,CAAC,GACV;EApBF,AAsBC,aAtBY,AAsBX,OAAO,CAAC;IACR,OAAO,EAAE,IAAI;IACb,OAAO,EAAE,GAAG,GACZ;EAzBF,AA2BC,aA3BY,AA2BX,kBAAkB,CAAC;IACnB,OAAO,EAAE,CAAC;IACV,MAAM,EAAE,CACT,GAAC;;AAGF,8FAA8F;AAC9F,AAAA,qBAAqB,CAAC,oBAAoB,CAAC;EAC1C,OAAO,EAAE,CAAC,GACV;;AAED,AAAA,aAAa;AACb,0BAA0B,AAAA,OAAO;AACjC,2BAA2B,AAAA,OAAO,CAA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;EAC5C,2BAA2B,EAAE,MAAM;EACnC,WAAW,EAAE,OAAO;EACpB,UAAU,EAAE,OAAO,CCvfiB,KAAK,CDufe,6BAA6B,GACrF;;AAED,oFAAoF;AACpF,AACC,gBADe,CACf,0BAA0B;AAD3B,gBAAgB,CAEf,2BAA2B,CAAC;EAC3B,UAAU,EAAE,OAAO,GACnB;;AAGF,AAAA,cAAc;AACd,cAAc,CAAC;EACd,gBAAgB,EAAE,kBAAkB,GACpC;;AAED,kGAAkG;AAClG,AACC,cADa,CACb,cAAc;AADf,cAAc,CAEb,cAAc,CAAC;EACd,gBAAgB,EAAE,kBAAkB,GACpC;;AAGF,sGAAsG;AAEtG,AACC,eADc,CACd,cAAc,CAAC;EACd,OAAO,EAAE,CAAC,GACV;;AAHF,AAKC,eALc,CAKd,0BAA0B;AAL3B,eAAe,CAMd,2BAA2B,CAAC;EAC3B,OAAO,EAAE,CAAC,GACV;;AAGF;;;EAGE;AACF,AACC,iBADgB,CAChB,cAAc;AADf,iBAAiB,CAEhB,cAAc;AAFf,iBAAiB,CAGhB,0BAA0B;AAH3B,iBAAiB,CAIhB,2BAA2B,CAAC;EAC3B,0DAA0D;EAC1D,OAAO,EAAE,KAAK,GACd;;AAGF,+EAA+E;AAC/E,AACC,oBADmB,CACnB,0BAA0B;AAD3B,oBAAoB,CAEnB,2BAA2B;AAF5B,oBAAoB,CAGnB,cAAc,CAAC;EACd,OAAO,EAAE,IAAI,GACb;;AAGF,AAAA,wBAAwB,CAAC;EACxB,OAAO,EAAE,eAAe,GACxB;;AAGA,AACC,oBADmB,CACnB,cAAc,CAAC;EACd,UAAU,EAAE,IAAI,GAChB" } \ No newline at end of file diff --git a/dist/photoswipe-ui-default.js b/dist/photoswipe-ui-default.js index c5bdaef51..44671189b 100644 --- a/dist/photoswipe-ui-default.js +++ b/dist/photoswipe-ui-default.js @@ -1,13 +1,13 @@ -/*! PhotoSwipe Default UI - 4.1.4 - 2020-08-09 +/*! PhotoSwipe Default UI - 4.1.4 - 2020-08-12 * http://photoswipe.com * Copyright (c) 2020 Dmitry Semenov; */ /** -* -* UI on top of main sliding area (caption, arrows, close button, etc.). -* Built just using public methods/properties of PhotoSwipe. -* -*/ -(function (root, factory) { + * + * UI on top of main sliding area (caption, arrows, close button, etc.). + * Built just using public methods/properties of PhotoSwipe. + * + */ +(function (root, factory) { if (typeof define === 'function' && define.amd) { define(factory); } else if (typeof exports === 'object') { @@ -16,854 +16,808 @@ root.PhotoSwipeUI_Default = factory(); } })(this, function () { - 'use strict'; - - -var PhotoSwipeUI_Default = - function(pswp, framework) { - - var ui = this; - var _overlayUIUpdated = false, - _controlsVisible = true, - _fullscrenAPI, - _controls, - _captionContainer, - _fakeCaptionContainer, - _indexIndicator, - _shareButton, - _shareModal, - _shareModalHidden = true, - _initalCloseOnScrollValue, - _isIdle, - _listen, - - _loadingIndicator, - _loadingIndicatorHidden, - _loadingIndicatorTimeout, - - _galleryHasOneSlide, - - _options, - _defaultUIOptions = { - barsSize: {top:44, bottom:'auto'}, - closeElClasses: ['item', 'caption', 'zoom-wrap', 'ui', 'top-bar'], - timeToIdle: 4000, - timeToIdleOutside: 1000, - loadingIndicatorDelay: 1000, // 2s - - addCaptionHTMLFn: function(item, captionEl /*, isFake */) { - if(!item.title) { - captionEl.children[0].innerHTML = ''; - return false; - } - captionEl.children[0].innerHTML = item.title; - return true; - }, - - closeEl:true, - captionEl: true, - fullscreenEl: true, - zoomEl: true, - shareEl: true, - counterEl: true, - arrowEl: true, - preloaderEl: true, - closeOnOutsideClick: true, - - tapToClose: false, - tapToToggleControls: true, - - clickToCloseNonZoomable: true, - - shareButtons: [ - {id:'facebook', label:'Share on Facebook', url:'https://www.facebook.com/sharer/sharer.php?u={{url}}'}, - {id:'twitter', label:'Tweet', url:'https://twitter.com/intent/tweet?text={{text}}&url={{url}}'}, - {id:'pinterest', label:'Pin it', url:'http://www.pinterest.com/pin/create/button/'+ - '?url={{url}}&media={{image_url}}&description={{text}}'}, - {id:'download', label:'Download image', url:'{{raw_image_url}}', download:true} - ], - getImageURLForShare: function( /* shareButtonData */ ) { - return pswp.currItem.src || ''; - }, - getPageURLForShare: function( /* shareButtonData */ ) { - return window.location.href; - }, - getTextForShare: function( /* shareButtonData */ ) { - return pswp.currItem.title || ''; + var PhotoSwipeUI_Default = function (pswp, framework) { + var ui = this; + var _overlayUIUpdated = false, + _controlsVisible = true, + _fullscrenAPI, + _controls, + _captionContainer, + _fakeCaptionContainer, + _indexIndicator, + _shareButton, + _shareModal, + _shareModalHidden = true, + _initalCloseOnScrollValue, + _isIdle, + _listen, + _loadingIndicator, + _loadingIndicatorHidden, + _loadingIndicatorTimeout, + _galleryHasOneSlide, + _options, + _defaultUIOptions = { + barsSize: {top: 44, bottom: 'auto'}, + closeElClasses: ['item', 'caption', 'zoom-wrap', 'ui', 'top-bar'], + timeToIdle: 4000, + timeToIdleOutside: 1000, + loadingIndicatorDelay: 1000, // 2s + + addCaptionHTMLFn: function (item, captionEl /*, isFake */) { + if (!item.title) { + captionEl.children[0].innerHTML = ''; + return false; + } + captionEl.children[0].innerHTML = item.title; + return true; + }, + + closeEl: true, + captionEl: true, + fullscreenEl: true, + zoomEl: true, + shareEl: true, + counterEl: true, + arrowEl: true, + preloaderEl: true, + closeOnOutsideClick: true, + + tapToClose: false, + tapToToggleControls: true, + + clickToCloseNonZoomable: true, + + shareButtons: [ + {id: 'facebook', label: 'Share on Facebook', url: 'https://www.facebook.com/sharer/sharer.php?u={{url}}'}, + {id: 'twitter', label: 'Tweet', url: 'https://twitter.com/intent/tweet?text={{text}}&url={{url}}'}, + { + id: 'pinterest', + label: 'Pin it', + url: 'http://www.pinterest.com/pin/create/button/' + '?url={{url}}&media={{image_url}}&description={{text}}' + }, + {id: 'download', label: 'Download image', url: '{{raw_image_url}}', download: true} + ], + getImageURLForShare: function (/* shareButtonData */) { + return pswp.currItem.src || ''; + }, + getPageURLForShare: function (/* shareButtonData */) { + return window.location.href; + }, + getTextForShare: function (/* shareButtonData */) { + return pswp.currItem.title || ''; + }, + + indexIndicatorSep: ' / ', + fitControlsWidth: 1200 }, - - indexIndicatorSep: ' / ', - fitControlsWidth: 1200 - - }, - _blockControlsTap, - _blockControlsTapTimeout; - - - - var _onControlsTap = function(e) { - if(_blockControlsTap) { - return true; - } + _blockControlsTap, + _blockControlsTapTimeout; + var _onControlsTap = function (e) { + if (_blockControlsTap) { + return true; + } - e = e || window.event; - - if(_options.timeToIdle && _options.mouseUsed && !_isIdle) { - // reset idle timer - _onIdleMouseMove(); - } - - - var target = e.target || e.srcElement, - uiElement, - clickedClass = target.getAttribute('class') || '', - found; - - for(var i = 0; i < _uiElements.length; i++) { - uiElement = _uiElements[i]; - if(uiElement.onTap && clickedClass.indexOf('pswp__' + uiElement.name ) > -1 ) { - uiElement.onTap(); - found = true; + e = e || window.event; + if (_options.timeToIdle && _options.mouseUsed && !_isIdle) { + // reset idle timer + _onIdleMouseMove(); } - } - if(found) { - if(e.stopPropagation) { - e.stopPropagation(); - } - _blockControlsTap = true; - - // Some versions of Android don't prevent ghost click event - // when preventDefault() was called on touchstart and/or touchend. - // - // This happens on v4.3, 4.2, 4.1, - // older versions strangely work correctly, - // but just in case we add delay on all of them) - var tapDelay = framework.features.isOldAndroid ? 600 : 30; - _blockControlsTapTimeout = setTimeout(function() { - _blockControlsTap = false; - }, tapDelay); - } + var target = e.target || e.srcElement, + uiElement, + clickedClass = target.getAttribute('class') || '', + found; - }, - _fitControlsInViewport = function() { - return !pswp.likelyTouchDevice || _options.mouseUsed || screen.width > _options.fitControlsWidth; - }, - _togglePswpClass = function(el, cName, add) { - framework[ (add ? 'add' : 'remove') + 'Class' ](el, 'pswp__' + cName); - }, - - // add class when there is just one item in the gallery - // (by default it hides left/right arrows and 1ofX counter) - _countNumItems = function() { - var hasOneSlide = (_options.getNumItemsFn() === 1); - - if(hasOneSlide !== _galleryHasOneSlide) { - _togglePswpClass(_controls, 'ui--one-slide', hasOneSlide); - _galleryHasOneSlide = hasOneSlide; - } - }, - _toggleShareModalClass = function() { - _togglePswpClass(_shareModal, 'share-modal--hidden', _shareModalHidden); - }, - _toggleShareModal = function() { - - _shareModalHidden = !_shareModalHidden; - - - if(!_shareModalHidden) { - _toggleShareModalClass(); - setTimeout(function() { - if(!_shareModalHidden) { - framework.addClass(_shareModal, 'pswp__share-modal--fade-in'); - } - }, 30); - } else { - framework.removeClass(_shareModal, 'pswp__share-modal--fade-in'); - setTimeout(function() { - if(_shareModalHidden) { - _toggleShareModalClass(); + for (var i = 0; i < _uiElements.length; i++) { + uiElement = _uiElements[i]; + if (uiElement.onTap && clickedClass.indexOf('pswp__' + uiElement.name) > -1) { + uiElement.onTap(); + found = true; } - }, 300); - } - - if(!_shareModalHidden) { - _updateShareURLs(); - } - return false; - }, - - _openWindowPopup = function(e) { - e = e || window.event; - var target = e.target || e.srcElement; + } - pswp.shout('shareLinkClick', e, target); + if (found) { + if (e.stopPropagation) { + e.stopPropagation(); + } + _blockControlsTap = true; + + // Some versions of Android don't prevent ghost click event + // when preventDefault() was called on touchstart and/or touchend. + // + // This happens on v4.3, 4.2, 4.1, + // older versions strangely work correctly, + // but just in case we add delay on all of them) + var tapDelay = framework.features.isOldAndroid ? 600 : 30; + _blockControlsTapTimeout = setTimeout(function () { + _blockControlsTap = false; + }, tapDelay); + } + }, + _fitControlsInViewport = function () { + return !pswp.likelyTouchDevice || _options.mouseUsed || screen.width > _options.fitControlsWidth; + }, + _togglePswpClass = function (el, cName, add) { + framework[(add ? 'add' : 'remove') + 'Class'](el, 'pswp__' + cName); + }, + // add class when there is just one item in the gallery + // (by default it hides left/right arrows and 1ofX counter) + _countNumItems = function () { + var hasOneSlide = _options.getNumItemsFn() === 1; + + if (hasOneSlide !== _galleryHasOneSlide) { + _togglePswpClass(_controls, 'ui--one-slide', hasOneSlide); + _galleryHasOneSlide = hasOneSlide; + } + }, + _toggleShareModalClass = function () { + _togglePswpClass(_shareModal, 'share-modal--hidden', _shareModalHidden); + }, + _toggleShareModal = function () { + _shareModalHidden = !_shareModalHidden; + + if (!_shareModalHidden) { + _toggleShareModalClass(); + setTimeout(function () { + if (!_shareModalHidden) { + framework.addClass(_shareModal, 'pswp__share-modal--fade-in'); + } + }, 30); + } else { + framework.removeClass(_shareModal, 'pswp__share-modal--fade-in'); + setTimeout(function () { + if (_shareModalHidden) { + _toggleShareModalClass(); + } + }, 300); + } - if(!target.href) { + if (!_shareModalHidden) { + _updateShareURLs(); + } return false; - } - - if( target.hasAttribute('download') ) { - return true; - } + }, + _openWindowPopup = function (e) { + e = e || window.event; + var target = e.target || e.srcElement; - window.open(target.href, 'pswp_share', 'scrollbars=yes,resizable=yes,toolbar=no,'+ - 'location=yes,width=550,height=420,top=100,left=' + - (window.screen ? Math.round(screen.width / 2 - 275) : 100) ); + pswp.shout('shareLinkClick', e, target); - if(!_shareModalHidden) { - _toggleShareModal(); - } - - return false; - }, - _updateShareURLs = function() { - var shareButtonOut = '', - shareButtonData, - shareURL, - image_url, - page_url, - share_text; - - for(var i = 0; i < _options.shareButtons.length; i++) { - shareButtonData = _options.shareButtons[i]; - - image_url = _options.getImageURLForShare(shareButtonData); - page_url = _options.getPageURLForShare(shareButtonData); - share_text = _options.getTextForShare(shareButtonData); - - shareURL = shareButtonData.url.replace('{{url}}', encodeURIComponent(page_url) ) - .replace('{{image_url}}', encodeURIComponent(image_url) ) - .replace('{{raw_image_url}}', image_url ) - .replace('{{text}}', encodeURIComponent(share_text) ); - - shareButtonOut += '' + - shareButtonData.label + ''; - - if(_options.parseShareButtonOut) { - shareButtonOut = _options.parseShareButtonOut(shareButtonData, shareButtonOut); + if (!target.href) { + return false; } - } - _shareModal.children[0].innerHTML = shareButtonOut; - _shareModal.children[0].onclick = _openWindowPopup; - }, - _hasCloseClass = function(target) { - for(var i = 0; i < _options.closeElClasses.length; i++) { - if( framework.hasClass(target, 'pswp__' + _options.closeElClasses[i]) ) { + if (target.hasAttribute('download')) { return true; } - } - }, - _idleInterval, - _idleTimer, - _idleIncrement = 0, - _onIdleMouseMove = function() { - clearTimeout(_idleTimer); - _idleIncrement = 0; - if(_isIdle) { - ui.setIdle(false); - } - }, - _onMouseLeaveWindow = function(e) { - e = e ? e : window.event; - var from = e.relatedTarget || e.toElement; - if (!from || from.nodeName === 'HTML') { - clearTimeout(_idleTimer); - _idleTimer = setTimeout(function() { - ui.setIdle(true); - }, _options.timeToIdleOutside); - } - }, - _setupFullscreenAPI = function() { - if(_options.fullscreenEl && !framework.features.isOldAndroid) { - if(!_fullscrenAPI) { - _fullscrenAPI = ui.getFullscreenAPI(); - } - if(_fullscrenAPI) { - framework.bind(document, _fullscrenAPI.eventK, ui.updateFullscreen); - ui.updateFullscreen(); - framework.addClass(pswp.template, 'pswp--supports-fs'); - } else { - framework.removeClass(pswp.template, 'pswp--supports-fs'); - } - } - }, - _setupLoadingIndicator = function() { - // Setup loading indicator - if(_options.preloaderEl) { - - _toggleLoadingIndicator(true); - _listen('beforeChange', function() { + window.open( + target.href, + 'pswp_share', + 'scrollbars=yes,resizable=yes,toolbar=no,' + + 'location=yes,width=550,height=420,top=100,left=' + + (window.screen ? Math.round(screen.width / 2 - 275) : 100) + ); - clearTimeout(_loadingIndicatorTimeout); - - // display loading indicator with delay - _loadingIndicatorTimeout = setTimeout(function() { - - if(pswp.currItem && pswp.currItem.loading) { + if (!_shareModalHidden) { + _toggleShareModal(); + } - if( !pswp.allowProgressiveImg() || (pswp.currItem.img && !pswp.currItem.img.naturalWidth) ) { - // show preloader if progressive loading is not enabled, - // or image width is not defined yet (because of slow connection) - _toggleLoadingIndicator(false); - // items-controller.js function allowProgressiveImg + return false; + }, + _updateShareURLs = function () { + var shareButtonOut = '', + shareButtonData, + shareURL, + image_url, + page_url, + share_text; + + for (var i = 0; i < _options.shareButtons.length; i++) { + shareButtonData = _options.shareButtons[i]; + + image_url = _options.getImageURLForShare(shareButtonData); + page_url = _options.getPageURLForShare(shareButtonData); + share_text = _options.getTextForShare(shareButtonData); + + shareURL = shareButtonData.url + .replace('{{url}}', encodeURIComponent(page_url)) + .replace('{{image_url}}', encodeURIComponent(image_url)) + .replace('{{raw_image_url}}', image_url) + .replace('{{text}}', encodeURIComponent(share_text)); + + shareButtonOut += + '' + + shareButtonData.label + + ''; + + if (_options.parseShareButtonOut) { + shareButtonOut = _options.parseShareButtonOut(shareButtonData, shareButtonOut); + } + } + _shareModal.children[0].innerHTML = shareButtonOut; + _shareModal.children[0].onclick = _openWindowPopup; + }, + _hasCloseClass = function (target) { + for (var i = 0; i < _options.closeElClasses.length; i++) { + if (framework.hasClass(target, 'pswp__' + _options.closeElClasses[i])) { + return true; + } + } + }, + _idleInterval, + _idleTimer, + _idleIncrement = 0, + _onIdleMouseMove = function () { + clearTimeout(_idleTimer); + _idleIncrement = 0; + if (_isIdle) { + ui.setIdle(false); + } + }, + _onMouseLeaveWindow = function (e) { + e = e ? e : window.event; + var from = e.relatedTarget || e.toElement; + if (!from || from.nodeName === 'HTML') { + clearTimeout(_idleTimer); + _idleTimer = setTimeout(function () { + ui.setIdle(true); + }, _options.timeToIdleOutside); + } + }, + _setupFullscreenAPI = function () { + if (_options.fullscreenEl && !framework.features.isOldAndroid) { + if (!_fullscrenAPI) { + _fullscrenAPI = ui.getFullscreenAPI(); + } + if (_fullscrenAPI) { + framework.bind(document, _fullscrenAPI.eventK, ui.updateFullscreen); + ui.updateFullscreen(); + framework.addClass(pswp.template, 'pswp--supports-fs'); + } else { + framework.removeClass(pswp.template, 'pswp--supports-fs'); + } + } + }, + _setupLoadingIndicator = function () { + // Setup loading indicator + if (_options.preloaderEl) { + _toggleLoadingIndicator(true); + + _listen('beforeChange', function () { + clearTimeout(_loadingIndicatorTimeout); + + // display loading indicator with delay + _loadingIndicatorTimeout = setTimeout(function () { + if (pswp.currItem && pswp.currItem.loading) { + if (!pswp.allowProgressiveImg() || (pswp.currItem.img && !pswp.currItem.img.naturalWidth)) { + // show preloader if progressive loading is not enabled, + // or image width is not defined yet (because of slow connection) + _toggleLoadingIndicator(false); + // items-controller.js function allowProgressiveImg + } + } else { + _toggleLoadingIndicator(true); // hide preloader } - + }, _options.loadingIndicatorDelay); + }); + _listen('imageLoadComplete', function (index, item) { + if (pswp.currItem === item) { + _toggleLoadingIndicator(true); + } + }); + } + }, + _toggleLoadingIndicator = function (hide) { + if (_loadingIndicatorHidden !== hide) { + _togglePswpClass(_loadingIndicator, 'preloader--active', !hide); + _loadingIndicatorHidden = hide; + } + }, + _applyNavBarGaps = function (item) { + var gap = item.vGap; + + if (_fitControlsInViewport()) { + var bars = _options.barsSize; + if (_options.captionEl && bars.bottom === 'auto') { + if (!_fakeCaptionContainer) { + _fakeCaptionContainer = framework.createEl('pswp__caption pswp__caption--fake'); + _fakeCaptionContainer.appendChild(framework.createEl('pswp__caption__center')); + _controls.insertBefore(_fakeCaptionContainer, _captionContainer); + framework.addClass(_controls, 'pswp__ui--fit'); + } + if (_options.addCaptionHTMLFn(item, _fakeCaptionContainer, true)) { + var captionSize = _fakeCaptionContainer.clientHeight; + gap.bottom = parseInt(captionSize, 10) || 44; } else { - _toggleLoadingIndicator(true); // hide preloader + gap.bottom = bars.top; // if no caption, set size of bottom gap to size of top } + } else { + gap.bottom = bars.bottom === 'auto' ? 0 : bars.bottom; + } - }, _options.loadingIndicatorDelay); - - }); - _listen('imageLoadComplete', function(index, item) { - if(pswp.currItem === item) { - _toggleLoadingIndicator(true); + // height of top bar is static, no need to calculate it + gap.top = bars.top; + } else { + gap.top = gap.bottom = 0; + } + }, + _setupIdle = function () { + // Hide controls when mouse is used + if (_options.timeToIdle) { + _listen('mouseUsed', function () { + framework.bind(document, 'mousemove', _onIdleMouseMove); + framework.bind(document, 'mouseout', _onMouseLeaveWindow); + + _idleInterval = setInterval(function () { + _idleIncrement++; + if (_idleIncrement === 2) { + ui.setIdle(true); + } + }, _options.timeToIdle / 2); + }); + } + }, + _setupHidingControlsDuringGestures = function () { + // Hide controls on vertical drag + _listen('onVerticalDrag', function (now) { + if (_controlsVisible && now < 0.95) { + ui.hideControls(); + } else if (!_controlsVisible && now >= 0.95) { + ui.showControls(); } }); - } - }, - _toggleLoadingIndicator = function(hide) { - if( _loadingIndicatorHidden !== hide ) { - _togglePswpClass(_loadingIndicator, 'preloader--active', !hide); - _loadingIndicatorHidden = hide; - } - }, - _applyNavBarGaps = function(item) { - var gap = item.vGap; - - if( _fitControlsInViewport() ) { - - var bars = _options.barsSize; - if(_options.captionEl && bars.bottom === 'auto') { - if(!_fakeCaptionContainer) { - _fakeCaptionContainer = framework.createEl('pswp__caption pswp__caption--fake'); - _fakeCaptionContainer.appendChild( framework.createEl('pswp__caption__center') ); - _controls.insertBefore(_fakeCaptionContainer, _captionContainer); - framework.addClass(_controls, 'pswp__ui--fit'); + // Hide controls when pinching to close + var pinchControlsHidden; + _listen('onPinchClose', function (now) { + if (_controlsVisible && now < 0.9) { + ui.hideControls(); + pinchControlsHidden = true; + } else if (pinchControlsHidden && !_controlsVisible && now > 0.9) { + ui.showControls(); } - if( _options.addCaptionHTMLFn(item, _fakeCaptionContainer, true) ) { + }); - var captionSize = _fakeCaptionContainer.clientHeight; - gap.bottom = parseInt(captionSize,10) || 44; - } else { - gap.bottom = bars.top; // if no caption, set size of bottom gap to size of top + _listen('zoomGestureEnded', function () { + pinchControlsHidden = false; + if (pinchControlsHidden && !_controlsVisible) { + ui.showControls(); } - } else { - gap.bottom = bars.bottom === 'auto' ? 0 : bars.bottom; - } - - // height of top bar is static, no need to calculate it - gap.top = bars.top; - } else { - gap.top = gap.bottom = 0; - } - }, - _setupIdle = function() { - // Hide controls when mouse is used - if(_options.timeToIdle) { - _listen('mouseUsed', function() { - - framework.bind(document, 'mousemove', _onIdleMouseMove); - framework.bind(document, 'mouseout', _onMouseLeaveWindow); - - _idleInterval = setInterval(function() { - _idleIncrement++; - if(_idleIncrement === 2) { - ui.setIdle(true); - } - }, _options.timeToIdle / 2); }); - } - }, - _setupHidingControlsDuringGestures = function() { + }; - // Hide controls on vertical drag - _listen('onVerticalDrag', function(now) { - if(_controlsVisible && now < 0.95) { - ui.hideControls(); - } else if(!_controlsVisible && now >= 0.95) { - ui.showControls(); + var _uiElements = [ + { + name: 'caption', + option: 'captionEl', + onInit: function (el) { + _captionContainer = el; } - }); - - // Hide controls when pinching to close - var pinchControlsHidden; - _listen('onPinchClose' , function(now) { - if(_controlsVisible && now < 0.9) { - ui.hideControls(); - pinchControlsHidden = true; - } else if(pinchControlsHidden && !_controlsVisible && now > 0.9) { - ui.showControls(); + }, + { + name: 'share-modal', + option: 'shareEl', + onInit: function (el) { + _shareModal = el; + }, + onTap: function () { + _toggleShareModal(); } - }); - - _listen('zoomGestureEnded', function() { - pinchControlsHidden = false; - if(pinchControlsHidden && !_controlsVisible) { - ui.showControls(); + }, + { + name: 'button--share', + option: 'shareEl', + onInit: function (el) { + _shareButton = el; + }, + onTap: function () { + _toggleShareModal(); } - }); - - }; - - - - var _uiElements = [ - { - name: 'caption', - option: 'captionEl', - onInit: function(el) { - _captionContainer = el; - } - }, - { - name: 'share-modal', - option: 'shareEl', - onInit: function(el) { - _shareModal = el; }, - onTap: function() { - _toggleShareModal(); - } - }, - { - name: 'button--share', - option: 'shareEl', - onInit: function(el) { - _shareButton = el; + { + name: 'button--zoom', + option: 'zoomEl', + onTap: pswp.toggleDesktopZoom }, - onTap: function() { - _toggleShareModal(); - } - }, - { - name: 'button--zoom', - option: 'zoomEl', - onTap: pswp.toggleDesktopZoom - }, - { - name: 'counter', - option: 'counterEl', - onInit: function(el) { - _indexIndicator = el; - } - }, - { - name: 'button--close', - option: 'closeEl', - onTap: function() { - setTimeout(pswp.close); - } - }, - { - name: 'button--arrow--left', - option: 'arrowEl', - onTap: pswp.prev - }, - { - name: 'button--arrow--right', - option: 'arrowEl', - onTap: pswp.next - }, - { - name: 'button--fs', - option: 'fullscreenEl', - onTap: function() { - if(_fullscrenAPI.isFullscreen()) { - _fullscrenAPI.exit(); - } else { - _fullscrenAPI.enter(); - } - } - }, - { - name: 'preloader', - option: 'preloaderEl', - onInit: function(el) { - _loadingIndicator = el; - } - } - - ]; - - var _setupUIElements = function() { - var item, - classAttr, - uiElement; - - var loopThroughChildElements = function(sChildren) { - if(!sChildren) { - return; + { + name: 'counter', + option: 'counterEl', + onInit: function (el) { + _indexIndicator = el; + } + }, + { + name: 'button--close', + option: 'closeEl', + onTap: function () { + setTimeout(pswp.close); + } + }, + { + name: 'button--arrow--left', + option: 'arrowEl', + onTap: pswp.prev + }, + { + name: 'button--arrow--right', + option: 'arrowEl', + onTap: pswp.next + }, + { + name: 'button--fs', + option: 'fullscreenEl', + onTap: function () { + if (_fullscrenAPI.isFullscreen()) { + _fullscrenAPI.exit(); + } else { + _fullscrenAPI.enter(); + } + } + }, + { + name: 'preloader', + option: 'preloaderEl', + onInit: function (el) { + _loadingIndicator = el; + } } + ]; + + var _setupUIElements = function () { + var item, classAttr, uiElement; + + var loopThroughChildElements = function (sChildren) { + if (!sChildren) { + return; + } + + var l = sChildren.length; + for (var i = 0; i < l; i++) { + item = sChildren[i]; + classAttr = item.className; - var l = sChildren.length; - for(var i = 0; i < l; i++) { - item = sChildren[i]; - classAttr = item.className; + for (var a = 0; a < _uiElements.length; a++) { + uiElement = _uiElements[a]; - for(var a = 0; a < _uiElements.length; a++) { - uiElement = _uiElements[a]; + if (classAttr.indexOf('pswp__' + uiElement.name) > -1) { + if (_options[uiElement.option]) { + // if element is not disabled from options - if(classAttr.indexOf('pswp__' + uiElement.name) > -1 ) { + framework.removeClass(item, 'pswp__element--disabled'); + if (uiElement.onInit) { + uiElement.onInit(item); + } - if( _options[uiElement.option] ) { // if element is not disabled from options - - framework.removeClass(item, 'pswp__element--disabled'); - if(uiElement.onInit) { - uiElement.onInit(item); + //item.style.display = 'block'; + } else { + framework.addClass(item, 'pswp__element--disabled'); + //item.style.display = 'none'; } - - //item.style.display = 'block'; - } else { - framework.addClass(item, 'pswp__element--disabled'); - //item.style.display = 'none'; } } } + }; + loopThroughChildElements(_controls.children); + + var topBar = framework.getChildByClass(_controls, 'pswp__top-bar'); + if (topBar) { + loopThroughChildElements(topBar.children); } }; - loopThroughChildElements(_controls.children); - - var topBar = framework.getChildByClass(_controls, 'pswp__top-bar'); - if(topBar) { - loopThroughChildElements( topBar.children ); - } - }; + ui.init = function () { + // extend options + framework.extend(pswp.options, _defaultUIOptions, true); - + // create local link for fast access + _options = pswp.options; - ui.init = function() { + // find pswp__ui element + _controls = framework.getChildByClass(pswp.scrollWrap, 'pswp__ui'); - // extend options - framework.extend(pswp.options, _defaultUIOptions, true); + // create local link + _listen = pswp.listen; - // create local link for fast access - _options = pswp.options; + _setupHidingControlsDuringGestures(); - // find pswp__ui element - _controls = framework.getChildByClass(pswp.scrollWrap, 'pswp__ui'); + // update controls when slides change + _listen('beforeChange', ui.update); - // create local link - _listen = pswp.listen; + // toggle zoom on double-tap + _listen('doubleTap', function (point) { + var initialZoomLevel = pswp.currItem.initialZoomLevel; + if (pswp.getZoomLevel() !== initialZoomLevel) { + pswp.zoomTo(initialZoomLevel, point, 333); + } else { + pswp.zoomTo(_options.getDoubleTapZoom(false, pswp.currItem), point, 333); + } + }); + // Allow text selection in caption + _listen('preventDragEvent', function (e, isDown, preventObj) { + var t = e.target || e.srcElement; + if ( + t && + t.getAttribute('class') && + e.type.indexOf('mouse') > -1 && + (t.getAttribute('class').indexOf('__caption') > 0 || /(SMALL|STRONG|EM)/i.test(t.tagName)) + ) { + preventObj.prevent = false; + } + }); - _setupHidingControlsDuringGestures(); + // bind events for UI + _listen('bindEvents', function () { + framework.bind(_controls, 'pswpTap click', _onControlsTap); + framework.bind(pswp.scrollWrap, 'pswpTap', ui.onGlobalTap); - // update controls when slides change - _listen('beforeChange', ui.update); + if (!pswp.likelyTouchDevice) { + framework.bind(pswp.scrollWrap, 'mouseover', ui.onMouseOver); + } + }); - // toggle zoom on double-tap - _listen('doubleTap', function(point) { - var initialZoomLevel = pswp.currItem.initialZoomLevel; - if(pswp.getZoomLevel() !== initialZoomLevel) { - pswp.zoomTo(initialZoomLevel, point, 333); - } else { - pswp.zoomTo(_options.getDoubleTapZoom(false, pswp.currItem), point, 333); - } - }); - - // Allow text selection in caption - _listen('preventDragEvent', function(e, isDown, preventObj) { - var t = e.target || e.srcElement; - if( - t && - t.getAttribute('class') && e.type.indexOf('mouse') > -1 && - ( t.getAttribute('class').indexOf('__caption') > 0 || (/(SMALL|STRONG|EM)/i).test(t.tagName) ) - ) { - preventObj.prevent = false; - } - }); + // unbind events for UI + _listen('unbindEvents', function () { + if (!_shareModalHidden) { + _toggleShareModal(); + } - // bind events for UI - _listen('bindEvents', function() { - framework.bind(_controls, 'pswpTap click', _onControlsTap); - framework.bind(pswp.scrollWrap, 'pswpTap', ui.onGlobalTap); + if (_idleInterval) { + clearInterval(_idleInterval); + } + framework.unbind(document, 'mouseout', _onMouseLeaveWindow); + framework.unbind(document, 'mousemove', _onIdleMouseMove); + framework.unbind(_controls, 'pswpTap click', _onControlsTap); + framework.unbind(pswp.scrollWrap, 'pswpTap', ui.onGlobalTap); + framework.unbind(pswp.scrollWrap, 'mouseover', ui.onMouseOver); + + if (_fullscrenAPI) { + framework.unbind(document, _fullscrenAPI.eventK, ui.updateFullscreen); + if (_fullscrenAPI.isFullscreen()) { + _options.hideAnimationDuration = 0; + _fullscrenAPI.exit(); + } + _fullscrenAPI = null; + } + }); - if(!pswp.likelyTouchDevice) { - framework.bind(pswp.scrollWrap, 'mouseover', ui.onMouseOver); - } - }); + // clean up things when gallery is destroyed + _listen('destroy', function () { + if (_options.captionEl) { + if (_fakeCaptionContainer) { + _controls.removeChild(_fakeCaptionContainer); + } + framework.removeClass(_captionContainer, 'pswp__caption--empty'); + } - // unbind events for UI - _listen('unbindEvents', function() { - if(!_shareModalHidden) { - _toggleShareModal(); - } + if (_shareModal) { + _shareModal.children[0].onclick = null; + } + framework.removeClass(_controls, 'pswp__ui--over-close'); + framework.addClass(_controls, 'pswp__ui--hidden'); + ui.setIdle(false); + }); - if(_idleInterval) { - clearInterval(_idleInterval); + if (!_options.showAnimationDuration) { + framework.removeClass(_controls, 'pswp__ui--hidden'); } - framework.unbind(document, 'mouseout', _onMouseLeaveWindow); - framework.unbind(document, 'mousemove', _onIdleMouseMove); - framework.unbind(_controls, 'pswpTap click', _onControlsTap); - framework.unbind(pswp.scrollWrap, 'pswpTap', ui.onGlobalTap); - framework.unbind(pswp.scrollWrap, 'mouseover', ui.onMouseOver); - - if(_fullscrenAPI) { - framework.unbind(document, _fullscrenAPI.eventK, ui.updateFullscreen); - if(_fullscrenAPI.isFullscreen()) { - _options.hideAnimationDuration = 0; - _fullscrenAPI.exit(); - } - _fullscrenAPI = null; - } - }); + _listen('initialZoomIn', function () { + if (_options.showAnimationDuration) { + framework.removeClass(_controls, 'pswp__ui--hidden'); + } + }); + _listen('initialZoomOut', function () { + framework.addClass(_controls, 'pswp__ui--hidden'); + }); + _listen('parseVerticalMargin', _applyNavBarGaps); - // clean up things when gallery is destroyed - _listen('destroy', function() { - if(_options.captionEl) { - if(_fakeCaptionContainer) { - _controls.removeChild(_fakeCaptionContainer); - } - framework.removeClass(_captionContainer, 'pswp__caption--empty'); - } + _setupUIElements(); - if(_shareModal) { - _shareModal.children[0].onclick = null; + if (_options.shareEl && _shareButton && _shareModal) { + _shareModalHidden = true; } - framework.removeClass(_controls, 'pswp__ui--over-close'); - framework.addClass( _controls, 'pswp__ui--hidden'); - ui.setIdle(false); - }); - - - if(!_options.showAnimationDuration) { - framework.removeClass( _controls, 'pswp__ui--hidden'); - } - _listen('initialZoomIn', function() { - if(_options.showAnimationDuration) { - framework.removeClass( _controls, 'pswp__ui--hidden'); - } - }); - _listen('initialZoomOut', function() { - framework.addClass( _controls, 'pswp__ui--hidden'); - }); - - _listen('parseVerticalMargin', _applyNavBarGaps); - - _setupUIElements(); - if(_options.shareEl && _shareButton && _shareModal) { - _shareModalHidden = true; - } + _countNumItems(); - _countNumItems(); + _setupIdle(); - _setupIdle(); + _setupFullscreenAPI(); - _setupFullscreenAPI(); + _setupLoadingIndicator(); + }; - _setupLoadingIndicator(); - }; + ui.setIdle = function (isIdle) { + _isIdle = isIdle; + _togglePswpClass(_controls, 'ui--idle', isIdle); + }; - ui.setIdle = function(isIdle) { - _isIdle = isIdle; - _togglePswpClass(_controls, 'ui--idle', isIdle); - }; + ui.update = function () { + // Don't update UI if it's hidden + if (_controlsVisible && pswp.currItem) { + ui.updateIndexIndicator(); - ui.update = function() { - // Don't update UI if it's hidden - if(_controlsVisible && pswp.currItem) { - - ui.updateIndexIndicator(); + if (_options.captionEl) { + _options.addCaptionHTMLFn(pswp.currItem, _captionContainer); - if(_options.captionEl) { - _options.addCaptionHTMLFn(pswp.currItem, _captionContainer); + _togglePswpClass(_captionContainer, 'caption--empty', !pswp.currItem.title); + } - _togglePswpClass(_captionContainer, 'caption--empty', !pswp.currItem.title); + _overlayUIUpdated = true; + } else { + _overlayUIUpdated = false; } - _overlayUIUpdated = true; - - } else { - _overlayUIUpdated = false; - } - - if(!_shareModalHidden) { - _toggleShareModal(); - } + if (!_shareModalHidden) { + _toggleShareModal(); + } - _countNumItems(); - }; + _countNumItems(); + }; - ui.updateFullscreen = function(e) { - - if(e) { - // some browsers change window scroll position during the fullscreen - // so PhotoSwipe updates it just in case - setTimeout(function() { - pswp.setScrollOffset( 0, framework.getScrollY() ); - }, 50); - } - - // toogle pswp--fs class on root element - framework[ (_fullscrenAPI.isFullscreen() ? 'add' : 'remove') + 'Class' ](pswp.template, 'pswp--fs'); - }; + ui.updateFullscreen = function (e) { + if (e) { + // some browsers change window scroll position during the fullscreen + // so PhotoSwipe updates it just in case + setTimeout(function () { + pswp.setScrollOffset(0, framework.getScrollY()); + }, 50); + } - ui.updateIndexIndicator = function() { - if(_options.counterEl) { - _indexIndicator.innerHTML = (pswp.getCurrentIndex()+1) + - _options.indexIndicatorSep + - _options.getNumItemsFn(); - } - }; - - ui.onGlobalTap = function(e) { - e = e || window.event; - var target = e.target || e.srcElement; + // toogle pswp--fs class on root element + framework[(_fullscrenAPI.isFullscreen() ? 'add' : 'remove') + 'Class'](pswp.template, 'pswp--fs'); + }; - if(_blockControlsTap) { - return; - } + ui.updateIndexIndicator = function () { + if (_options.counterEl) { + _indexIndicator.innerHTML = pswp.getCurrentIndex() + 1 + _options.indexIndicatorSep + _options.getNumItemsFn(); + } + }; - if(e.detail && e.detail.pointerType === 'mouse') { + ui.onGlobalTap = function (e) { + e = e || window.event; + var target = e.target || e.srcElement; - // Silently ignore right-click events. - if (!e.detail.rightClick) { + if (_blockControlsTap) { + return; + } - // close gallery if clicked outside of the image - if(_options.closeOnOutsideClick && _hasCloseClass(target)) { - pswp.close(); - return; - } + if (e.detail && e.detail.pointerType === 'mouse') { + // Silently ignore right-click events. + if (!e.detail.rightClick) { + // close gallery if clicked outside of the image + if (_options.closeOnOutsideClick && _hasCloseClass(target)) { + pswp.close(); + return; + } - if(framework.hasClass(target, 'pswp__img')) { - if(pswp.getZoomLevel() === 1 && pswp.getZoomLevel() <= pswp.currItem.fitRatio) { - if(_options.clickToCloseNonZoomable) { - pswp.close(); + if (framework.hasClass(target, 'pswp__img')) { + if (pswp.getZoomLevel() === 1 && pswp.getZoomLevel() <= pswp.currItem.fitRatio) { + if (_options.clickToCloseNonZoomable) { + pswp.close(); + } + } else { + pswp.toggleDesktopZoom(e.detail.releasePoint); } + } + } + } else { + // tap anywhere (except buttons) to toggle visibility of controls + if (_options.tapToToggleControls) { + if (_controlsVisible) { + ui.hideControls(); } else { - pswp.toggleDesktopZoom(e.detail.releasePoint); + ui.showControls(); } } - - } - - } else { - // tap anywhere (except buttons) to toggle visibility of controls - if(_options.tapToToggleControls) { - if(_controlsVisible) { - ui.hideControls(); - } else { - ui.showControls(); + // tap to close gallery + if ( + _options.tapToClose && + (framework.hasClass(target, 'pswp__img') || (_options.closeOnOutsideClick && _hasCloseClass(target))) + ) { + pswp.close(); + return; } } + }; + ui.onMouseOver = function (e) { + e = e || window.event; + var target = e.target || e.srcElement; - // tap to close gallery - if(_options.tapToClose && (framework.hasClass(target, 'pswp__img') || _options.closeOnOutsideClick && _hasCloseClass(target)) ) { - pswp.close(); - return; - } - - } - }; - ui.onMouseOver = function(e) { - e = e || window.event; - var target = e.target || e.srcElement; - - // add class when mouse is over an element that should close the gallery - _togglePswpClass(_controls, 'ui--over-close', _hasCloseClass(target)); - }; - - ui.hideControls = function() { - framework.addClass(_controls,'pswp__ui--hidden'); - _controlsVisible = false; - }; - - ui.showControls = function() { - _controlsVisible = true; - if(!_overlayUIUpdated) { - ui.update(); - } - framework.removeClass(_controls,'pswp__ui--hidden'); - }; - - ui.supportsFullscreen = function() { - var d = document; - return !!(d.exitFullscreen || d.mozCancelFullScreen || d.webkitExitFullscreen || d.msExitFullscreen); - }; - - ui.getFullscreenAPI = function() { - var dE = document.documentElement, - api, - tF = 'fullscreenchange'; - - if (dE.requestFullscreen) { - api = { - enterK: 'requestFullscreen', - exitK: 'exitFullscreen', - elementK: 'fullscreenElement', - eventK: tF - }; - - } else if(dE.mozRequestFullScreen ) { - api = { - enterK: 'mozRequestFullScreen', - exitK: 'mozCancelFullScreen', - elementK: 'mozFullScreenElement', - eventK: 'moz' + tF - }; - - - - } else if(dE.webkitRequestFullscreen) { - api = { - enterK: 'webkitRequestFullscreen', - exitK: 'webkitExitFullscreen', - elementK: 'webkitFullscreenElement', - eventK: 'webkit' + tF - }; + // add class when mouse is over an element that should close the gallery + _togglePswpClass(_controls, 'ui--over-close', _hasCloseClass(target)); + }; - } else if(dE.msRequestFullscreen) { - api = { - enterK: 'msRequestFullscreen', - exitK: 'msExitFullscreen', - elementK: 'msFullscreenElement', - eventK: 'MSFullscreenChange' - }; - } + ui.hideControls = function () { + framework.addClass(_controls, 'pswp__ui--hidden'); + _controlsVisible = false; + }; - if(api) { - api.enter = function() { - // disable close-on-scroll in fullscreen - _initalCloseOnScrollValue = _options.closeOnScroll; - _options.closeOnScroll = false; + ui.showControls = function () { + _controlsVisible = true; + if (!_overlayUIUpdated) { + ui.update(); + } + framework.removeClass(_controls, 'pswp__ui--hidden'); + }; - if(this.enterK === 'webkitRequestFullscreen') { - pswp.template[this.enterK]( Element.ALLOW_KEYBOARD_INPUT ); - } else { - return pswp.template[this.enterK](); - } - }; - api.exit = function() { - _options.closeOnScroll = _initalCloseOnScrollValue; + ui.supportsFullscreen = function () { + var d = document; + return !!(d.exitFullscreen || d.mozCancelFullScreen || d.webkitExitFullscreen || d.msExitFullscreen); + }; - return document[this.exitK](); + ui.getFullscreenAPI = function () { + var dE = document.documentElement, + api, + tF = 'fullscreenchange'; + + if (dE.requestFullscreen) { + api = { + enterK: 'requestFullscreen', + exitK: 'exitFullscreen', + elementK: 'fullscreenElement', + eventK: tF + }; + } else if (dE.mozRequestFullScreen) { + api = { + enterK: 'mozRequestFullScreen', + exitK: 'mozCancelFullScreen', + elementK: 'mozFullScreenElement', + eventK: 'moz' + tF + }; + } else if (dE.webkitRequestFullscreen) { + api = { + enterK: 'webkitRequestFullscreen', + exitK: 'webkitExitFullscreen', + elementK: 'webkitFullscreenElement', + eventK: 'webkit' + tF + }; + } else if (dE.msRequestFullscreen) { + api = { + enterK: 'msRequestFullscreen', + exitK: 'msExitFullscreen', + elementK: 'msFullscreenElement', + eventK: 'MSFullscreenChange' + }; + } + + if (api) { + api.enter = function () { + // disable close-on-scroll in fullscreen + _initalCloseOnScrollValue = _options.closeOnScroll; + _options.closeOnScroll = false; + + if (this.enterK === 'webkitRequestFullscreen') { + pswp.template[this.enterK](Element.ALLOW_KEYBOARD_INPUT); + } else { + return pswp.template[this.enterK](); + } + }; + api.exit = function () { + _options.closeOnScroll = _initalCloseOnScrollValue; - }; - api.isFullscreen = function() { return document[this.elementK]; }; - } + return document[this.exitK](); + }; + api.isFullscreen = function () { + return document[this.elementK]; + }; + } - return api; + return api; + }; }; - - - -}; -return PhotoSwipeUI_Default; - - + return PhotoSwipeUI_Default; }); diff --git a/dist/photoswipe.css b/dist/photoswipe.css index 93596cf7c..ba6058f1f 100644 --- a/dist/photoswipe.css +++ b/dist/photoswipe.css @@ -168,8 +168,8 @@ font-size: 14px; line-height: 16px; margin-top: -8px; - color: #CCC; } + color: #ccc; } .pswp__error-msg a { - color: #CCC; + color: #ccc; text-decoration: underline; } \ No newline at end of file diff --git a/dist/photoswipe.css.map b/dist/photoswipe.css.map index 05a8c9548..9b1c86414 100644 --- a/dist/photoswipe.css.map +++ b/dist/photoswipe.css.map @@ -6,5 +6,5 @@ "../src/css/_main-settings.scss" ], "names": [], - "mappings": "AAAA,2EAA2E;AAE3E;;EAEE;AAOF,uBAAuB;AACvB,AAAA,KAAK,CAAC;EACL,OAAO,EAAE,IAAI;EACb,QAAQ,EAAC,QAAQ;EACjB,KAAK,EAAE,IAAI;EACX,MAAM,EAAE,IAAI;EACZ,IAAI,EAAC,CAAC;EACN,GAAG,EAAC,CAAC;EACL,QAAQ,EAAE,MAAM;EAChB,gBAAgB,EAAE,IAAI;EACtB,YAAY,EAAE,IAAI;EAClB,OAAO,ECjBa,IAAI;EDkBxB,wBAAwB,EAAE,IAAI;EAC9B,8EAA8E;EAC9E,2BAA2B,EAAE,MAAM;EACnC,OAAO,EAAE,IAAI,GAWb;EAzBD,AAiBE,KAjBG,CAiBH,CAAC,CAAC;IACD,UAAU,EAAE,UAAU,GACtB;EAnBH,AAsBC,KAtBI,CAsBJ,GAAG,CAAC;IACH,SAAS,EAAE,IAAI,GACf;;AAGF,kEAAkE;AAClE,AAAA,sBAAsB,CAAC;EACtB,oGAAoG;EACpG,OAAO,EAAE,KAAK;EACd,WAAW,EAAC,OAAO;EACnB,+BAA+B;EAC/B,UAAU,EAAE,OAAO,CC7CkB,KAAK,CD6Ce,6BAAwB,GACjF;;AAED,AAAA,WAAW,CAAC;EACX,OAAO,EAAE,KAAK,GACd;;AAED,AAAA,mBAAmB,CAAC,UAAU,CAAC;EAC9B,uBAAuB;EACvB,MAAM,EAAE,eAAe;EACvB,MAAM,EAAE,YAAY;EACpB,MAAM,EAAE,OAAO,GACf;;AAED,AAAA,gBAAgB,CAAC,UAAU,CAAC;EAC3B,uBAAuB;EACvB,MAAM,EAAE,YAAY;EACpB,MAAM,EAAE,S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a 100644 --- a/dist/photoswipe.js +++ b/dist/photoswipe.js @@ -1,4 +1,4 @@ -/*! PhotoSwipe - v4.1.4 - 2020-08-09 +/*! PhotoSwipe - v4.1.4 - 2020-08-12 * http://photoswipe.com * Copyright (c) 2020 Dmitry Semenov; */ (function (root, factory) { @@ -18,72 +18,75 @@ /** * * Set of generic functions used by gallery. - * + * * You're free to modify anything here as long as functionality is kept. - * + * */ var framework = { features: null, - bind: function(target, type, listener, unbind) { + bind: function (target, type, listener, unbind) { var methodName = (unbind ? 'remove' : 'add') + 'EventListener'; type = type.split(' '); - for(var i = 0; i < type.length; i++) { - if(type[i]) { - target[methodName]( type[i], listener, false); + for (var i = 0; i < type.length; i++) { + if (type[i]) { + target[methodName](type[i], listener, false); } } }, - isArray: function(obj) { - return (obj instanceof Array); + isArray: function (obj) { + return obj instanceof Array; }, - createEl: function(classes, tag) { + createEl: function (classes, tag) { var el = document.createElement(tag || 'div'); - if(classes) { + if (classes) { el.className = classes; } return el; }, - getScrollY: function() { + getScrollY: function () { var yOffset = window.pageYOffset; return yOffset !== undefined ? yOffset : document.documentElement.scrollTop; }, - unbind: function(target, type, listener) { - framework.bind(target,type,listener,true); + unbind: function (target, type, listener) { + framework.bind(target, type, listener, true); }, - removeClass: function(el, className) { + removeClass: function (el, className) { var reg = new RegExp('(\\s|^)' + className + '(\\s|$)'); - el.className = el.className.replace(reg, ' ').replace(/^\s\s*/, '').replace(/\s\s*$/, ''); + el.className = el.className + .replace(reg, ' ') + .replace(/^\s\s*/, '') + .replace(/\s\s*$/, ''); }, - addClass: function(el, className) { - if( !framework.hasClass(el,className) ) { + addClass: function (el, className) { + if (!framework.hasClass(el, className)) { el.className += (el.className ? ' ' : '') + className; } }, - hasClass: function(el, className) { + hasClass: function (el, className) { return el.className && new RegExp('(^|\\s)' + className + '(\\s|$)').test(el.className); }, - getChildByClass: function(parentEl, childClassName) { + getChildByClass: function (parentEl, childClassName) { var node = parentEl.firstChild; - while(node) { - if( framework.hasClass(node, childClassName) ) { + while (node) { + if (framework.hasClass(node, childClassName)) { return node; } node = node.nextSibling; } }, - arraySearch: function(array, value, key) { + arraySearch: function (array, value, key) { var i = array.length; - while(i--) { - if(array[i][key] === value) { + while (i--) { + if (array[i][key] === value) { return i; - } + } } return -1; }, - extend: function(o1, o2, preventOverwrite) { + extend: function (o1, o2, preventOverwrite) { for (var prop in o2) { if (o2.hasOwnProperty(prop)) { - if(preventOverwrite && o1.hasOwnProperty(prop)) { + if (preventOverwrite && o1.hasOwnProperty(prop)) { continue; } o1[prop] = o2[prop]; @@ -92,15 +95,15 @@ var framework = { }, easing: { sine: { - out: function(k) { + out: function (k) { return Math.sin(k * (Math.PI / 2)); }, - inOut: function(k) { - return - (Math.cos(Math.PI * k) - 1) / 2; + inOut: function (k) { + return -(Math.cos(Math.PI * k) - 1) / 2; } }, cubic: { - out: function(k) { + out: function (k) { return --k * k * k + 1; } } @@ -127,19 +130,19 @@ var framework = { }, /** - * + * * @return {object} - * + * * { * raf : request animation frame function * caf : cancel animation frame function * transfrom : transform property key (with vendor), or null if not supported * oldIE : IE8 or below * } - * + * */ - detectFeatures: function() { - if(framework.features) { + detectFeatures: function () { + if (framework.features) { return framework.features; } var helperEl = framework.createEl(), @@ -152,32 +155,31 @@ var framework = { features.touch = 'ontouchstart' in window; - if(window.requestAnimationFrame) { + if (window.requestAnimationFrame) { features.raf = window.requestAnimationFrame; features.caf = window.cancelAnimationFrame; } - features.pointerEvent = !!(window.PointerEvent) || navigator.msPointerEnabled; + features.pointerEvent = !!window.PointerEvent || navigator.msPointerEnabled; // fix false-positive detection of old Android in new IE // (IE11 ua string contains "Android 4.0") - - if(!features.pointerEvent) { + if (!features.pointerEvent) { var ua = navigator.userAgent; // Detect if device is iPhone or iPod and if it's older than iOS 8 // http://stackoverflow.com/a/14223920 - // + // // This detection is made because of buggy top/bottom toolbars // that don't trigger window.resize event. // For more info refer to _isFixedPosition variable in core.js if (/iP(hone|od)/.test(navigator.platform)) { - var v = (navigator.appVersion).match(/OS (\d+)_(\d+)_?(\d+)?/); - if(v && v.length > 0) { + var v = navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/); + if (v && v.length > 0) { v = parseInt(v[1], 10); - if(v >= 1 && v < 8 ) { + if (v >= 1 && v < 8) { features.isOldIOSPhone = true; } } @@ -186,67 +188,67 @@ var framework = { // Detect old Android (before KitKat) // due to bugs related to position:fixed // http://stackoverflow.com/questions/7184573/pick-up-the-android-version-in-the-browser-by-javascript - + var match = ua.match(/Android\s([0-9\.]*)/); - var androidversion = match ? match[1] : 0; + var androidversion = match ? match[1] : 0; androidversion = parseFloat(androidversion); - if(androidversion >= 1 ) { - if(androidversion < 4.4) { + if (androidversion >= 1) { + if (androidversion < 4.4) { features.isOldAndroid = true; // for fixed position bug & performance } features.androidVersion = androidversion; // for touchend bug - } + } features.isMobileOpera = /opera mini|opera mobi/i.test(ua); // p.s. yes, yes, UA sniffing is bad, propose your solution for above bugs. } - + var styleChecks = ['transform', 'perspective', 'animationName'], - vendors = ['', 'webkit','Moz','ms','O'], + vendors = ['', 'webkit', 'Moz', 'ms', 'O'], styleCheckItem, styleName; - for(var i = 0; i < 4; i++) { + for (var i = 0; i < 4; i++) { vendor = vendors[i]; - for(var a = 0; a < 3; a++) { + for (var a = 0; a < 3; a++) { styleCheckItem = styleChecks[a]; // uppercase first letter of property name, if vendor is present - styleName = vendor + (vendor ? - styleCheckItem.charAt(0).toUpperCase() + styleCheckItem.slice(1) : - styleCheckItem); - - if(!features[styleCheckItem] && styleName in helperStyle ) { + styleName = vendor + (vendor ? styleCheckItem.charAt(0).toUpperCase() + styleCheckItem.slice(1) : styleCheckItem); + + if (!features[styleCheckItem] && styleName in helperStyle) { features[styleCheckItem] = styleName; } } - if(vendor && !features.raf) { + if (vendor && !features.raf) { vendor = vendor.toLowerCase(); - features.raf = window[vendor+'RequestAnimationFrame']; - if(features.raf) { - features.caf = window[vendor+'CancelAnimationFrame'] || - window[vendor+'CancelRequestAnimationFrame']; + features.raf = window[vendor + 'RequestAnimationFrame']; + if (features.raf) { + features.caf = window[vendor + 'CancelAnimationFrame'] || window[vendor + 'CancelRequestAnimationFrame']; } } } - - if(!features.raf) { + + if (!features.raf) { var lastTime = 0; - features.raf = function(fn) { + features.raf = function (fn) { var currTime = new Date().getTime(); var timeToCall = Math.max(0, 16 - (currTime - lastTime)); - var id = window.setTimeout(function() { fn(currTime + timeToCall); }, timeToCall); + var id = window.setTimeout(function () { + fn(currTime + timeToCall); + }, timeToCall); lastTime = currTime + timeToCall; return id; }; - features.caf = function(id) { clearTimeout(id); }; + features.caf = function (id) { + clearTimeout(id); + }; } // Detect SVG support - features.svg = !!document.createElementNS && - !!document.createElementNS('http://www.w3.org/2000/svg', 'svg').createSVGRect; + features.svg = !!document.createElementNS && !!document.createElementNS('http://www.w3.org/2000/svg', 'svg').createSVGRect; framework.features = features; @@ -257,42 +259,38 @@ var framework = { framework.detectFeatures(); // Override addEventListener for old versions of IE -if(framework.features.oldIE) { - - framework.bind = function(target, type, listener, unbind) { - +if (framework.features.oldIE) { + framework.bind = function (target, type, listener, unbind) { type = type.split(' '); var methodName = (unbind ? 'detach' : 'attach') + 'Event', evName, - _handleEv = function() { + _handleEv = function () { listener.handleEvent.call(listener); }; - for(var i = 0; i < type.length; i++) { + for (var i = 0; i < type.length; i++) { evName = type[i]; - if(evName) { - - if(typeof listener === 'object' && listener.handleEvent) { - if(!unbind) { + if (evName) { + if (typeof listener === 'object' && listener.handleEvent) { + if (!unbind) { listener['oldIE' + evName] = _handleEv; } else { - if(!listener['oldIE' + evName]) { + if (!listener['oldIE' + evName]) { return false; } } - target[methodName]( 'on' + evName, listener['oldIE' + evName]); + target[methodName]('on' + evName, listener['oldIE' + evName]); } else { - target[methodName]( 'on' + evName, listener); + target[methodName]('on' + evName, listener); } - } } }; - } + /*>>framework-bridge*/ /*>>core*/ @@ -310,7 +308,7 @@ var DOUBLE_TAP_RADIUS = 25, * Options */ var _options = { - allowPanToNext:true, + allowPanToNext: true, spacing: 0.12, bgOpacity: 1, mouseUsed: false, @@ -327,17 +325,17 @@ var _options = { arrowKeys: true, mainScrollEndFriction: 0.35, panEndFriction: 0.35, - isClickableElement: function(el) { - return el.tagName === 'A'; - }, - getDoubleTapZoom: function(isMouseClick, item) { - if(isMouseClick) { - return 1; - } else { - return item.initialZoomLevel < 0.7 ? 1 : 1.33; - } - }, - maxSpreadZoom: 1.33, + isClickableElement: function (el) { + return el.tagName === 'A'; + }, + getDoubleTapZoom: function (isMouseClick, item) { + if (isMouseClick) { + return 1; + } else { + return item.initialZoomLevel < 0.7 ? 1 : 1.33; + } + }, + maxSpreadZoom: 1.33, modal: true, // not fully implemented yet @@ -345,14 +343,13 @@ var _options = { }; framework.extend(_options, options); - /** * Private helper variables & functions */ -var _getEmptyPoint = function() { - return {x:0,y:0}; - }; +var _getEmptyPoint = function () { + return {x: 0, y: 0}; +}; var _isOpen, _isDestroying, @@ -398,102 +395,87 @@ var _isOpen, _windowVisibleSize = {}, _renderMaxResolution = false, _orientationChangeTimeout, - - // Registers PhotoSWipe module (History, Controller ...) - _registerModule = function(name, module) { + _registerModule = function (name, module) { framework.extend(self, module.publicMethods); _modules.push(name); }, - - _getLoopedId = function(index) { + _getLoopedId = function (index) { var numSlides = _getNumItems(); - if(index > numSlides - 1) { + if (index > numSlides - 1) { return index - numSlides; - } else if(index < 0) { + } else if (index < 0) { return numSlides + index; } return index; }, - // Micro bind/trigger _listeners = {}, - _listen = function(name, fn) { - if(!_listeners[name]) { + _listen = function (name, fn) { + if (!_listeners[name]) { _listeners[name] = []; } return _listeners[name].push(fn); }, - _shout = function(name) { + _shout = function (name) { var listeners = _listeners[name]; - if(listeners) { + if (listeners) { var args = Array.prototype.slice.call(arguments); args.shift(); - for(var i = 0; i < listeners.length; i++) { + for (var i = 0; i < listeners.length; i++) { listeners[i].apply(self, args); } } }, - - _getCurrentTime = function() { + _getCurrentTime = function () { return new Date().getTime(); }, - _applyBgOpacity = function(opacity) { + _applyBgOpacity = function (opacity) { _bgOpacity = opacity; self.bg.style.opacity = opacity * _options.bgOpacity; }, - - _applyZoomTransform = function(styleObj,x,y,zoom,item) { - if(!_renderMaxResolution || (item && item !== self.currItem) ) { + _applyZoomTransform = function (styleObj, x, y, zoom, item) { + if (!_renderMaxResolution || (item && item !== self.currItem)) { zoom = zoom / (item ? item.fitRatio : self.currItem.fitRatio); } styleObj[_transformKey] = _translatePrefix + x + 'px, ' + y + 'px' + _translateSufix + ' scale(' + zoom + ')'; }, - _applyCurrentZoomPan = function( allowRenderResolution ) { - if(_currZoomElementStyle && !self.currItem.loadError) { - - if(allowRenderResolution) { - if(_currZoomLevel > self.currItem.fitRatio) { - if(!_renderMaxResolution) { + _applyCurrentZoomPan = function (allowRenderResolution) { + if (_currZoomElementStyle && !self.currItem.loadError) { + if (allowRenderResolution) { + if (_currZoomLevel > self.currItem.fitRatio) { + if (!_renderMaxResolution) { _setImageSize(self.currItem, false, true); _renderMaxResolution = true; } } else { - if(_renderMaxResolution) { + if (_renderMaxResolution) { _setImageSize(self.currItem); _renderMaxResolution = false; } } } - _applyZoomTransform(_currZoomElementStyle, _panOffset.x, _panOffset.y, _currZoomLevel); } }, - _applyZoomPanToItem = function(item) { - if(item.container) { - - _applyZoomTransform(item.container.style, - item.initialPosition.x, - item.initialPosition.y, - item.initialZoomLevel, - item); + _applyZoomPanToItem = function (item) { + if (item.container) { + _applyZoomTransform(item.container.style, item.initialPosition.x, item.initialPosition.y, item.initialZoomLevel, item); } }, - _setTranslateX = function(x, elStyle) { + _setTranslateX = function (x, elStyle) { elStyle[_transformKey] = _translatePrefix + x + 'px, 0px' + _translateSufix; }, - _moveMainScroll = function(x, dragging) { - - if(!_options.loop && dragging) { + _moveMainScroll = function (x, dragging) { + if (!_options.loop && dragging) { 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) ) { + if ((newSlideIndexOffset < 0 && delta > 0) || (newSlideIndexOffset >= _getNumItems() - 1 && delta < 0)) { x = _mainScrollPos.x + delta * _options.mainScrollEndFriction; } } @@ -501,48 +483,44 @@ var _isOpen, _mainScrollPos.x = x; _setTranslateX(x, _containerStyle); }, - _calculatePanOffset = function(axis, zoomLevel) { + _calculatePanOffset = function (axis, zoomLevel) { var m = _midZoomPoint[axis] - _offset[axis]; - return _startPanOffset[axis] + _currPanDist[axis] + m - m * ( zoomLevel / _startZoomLevel ); + return _startPanOffset[axis] + _currPanDist[axis] + m - m * (zoomLevel / _startZoomLevel); }, - - _equalizePoints = function(p1, p2) { + _equalizePoints = function (p1, p2) { p1.x = p2.x; p1.y = p2.y; - if(p2.id) { + if (p2.id) { p1.id = p2.id; } }, - _roundPoint = function(p) { + _roundPoint = function (p) { p.x = Math.round(p.x); p.y = Math.round(p.y); }, - _mouseMoveTimeout = null, - _onFirstMouseMove = function() { + _onFirstMouseMove = function () { // Wait until mouse move event is fired at least twice during 100ms // We do this, because some mobile browsers trigger it on touchstart - if(_mouseMoveTimeout ) { + if (_mouseMoveTimeout) { framework.unbind(document, 'mousemove', _onFirstMouseMove); framework.addClass(template, 'pswp--has_mouse'); _options.mouseUsed = true; _shout('mouseUsed'); } - _mouseMoveTimeout = setTimeout(function() { + _mouseMoveTimeout = setTimeout(function () { _mouseMoveTimeout = null; }, 100); }, - - _bindEvents = function() { + _bindEvents = function () { framework.bind(document, 'keydown', self); - if(_features.transform) { + if (_features.transform) { // don't bind click event in browsers that don't support transform (mostly IE8) framework.bind(self.scrollWrap, 'click', self); } - - if(!_options.mouseUsed) { + if (!_options.mouseUsed) { framework.bind(document, 'mousemove', _onFirstMouseMove); } @@ -550,18 +528,17 @@ var _isOpen, _shout('bindEvents'); }, - - _unbindEvents = function() { + _unbindEvents = function () { framework.unbind(window, 'resize scroll orientationchange', self); framework.unbind(window, 'scroll', _globalEventHandlers.scroll); framework.unbind(document, 'keydown', self); framework.unbind(document, 'mousemove', _onFirstMouseMove); - if(_features.transform) { + if (_features.transform) { framework.unbind(self.scrollWrap, 'click', self); } - if(_isDragging) { + if (_isDragging) { framework.unbind(window, _upMoveEvents, self); } @@ -569,50 +546,45 @@ var _isOpen, _shout('unbindEvents'); }, - - _calculatePanBounds = function(zoomLevel, update) { - var bounds = _calculateItemSize( self.currItem, _viewportSize, zoomLevel ); - if(update) { + _calculatePanBounds = function (zoomLevel, update) { + var bounds = _calculateItemSize(self.currItem, _viewportSize, zoomLevel); + if (update) { _currPanBounds = bounds; } return bounds; }, - - _getMinZoomLevel = function(item) { - if(!item) { + _getMinZoomLevel = function (item) { + if (!item) { item = self.currItem; } return item.initialZoomLevel; }, - _getMaxZoomLevel = function(item) { - if(!item) { + _getMaxZoomLevel = function (item) { + if (!item) { item = self.currItem; } return item.w > 0 ? _options.maxSpreadZoom : 1; }, - // Return true if offset is out of the bounds - _modifyDestPanOffset = function(axis, destPanBounds, destPanOffset, destZoomLevel) { - if(destZoomLevel === self.currItem.initialZoomLevel) { + _modifyDestPanOffset = function (axis, destPanBounds, destPanOffset, destZoomLevel) { + if (destZoomLevel === self.currItem.initialZoomLevel) { destPanOffset[axis] = self.currItem.initialPosition[axis]; return true; } else { destPanOffset[axis] = _calculatePanOffset(axis, destZoomLevel); - if(destPanOffset[axis] > destPanBounds.min[axis]) { + if (destPanOffset[axis] > destPanBounds.min[axis]) { destPanOffset[axis] = destPanBounds.min[axis]; return true; - } else if(destPanOffset[axis] < destPanBounds.max[axis] ) { + } else if (destPanOffset[axis] < destPanBounds.max[axis]) { destPanOffset[axis] = destPanBounds.max[axis]; return true; } } return false; }, - - _setupTransforms = function() { - - if(_transformKey) { + _setupTransforms = function () { + if (_transformKey) { // setup 3d transforms var allow3dTransform = _features.perspective && !_likelyTouchDevice; _translatePrefix = 'translate' + (allow3dTransform ? '3d(' : '('); @@ -626,11 +598,10 @@ var _isOpen, _transformKey = 'left'; framework.addClass(template, 'pswp--ie'); - _setTranslateX = function(x, elStyle) { + _setTranslateX = function (x, elStyle) { elStyle.left = x + 'px'; }; - _applyZoomPanToItem = function(item) { - + _applyZoomPanToItem = function (item) { var zoomRatio = item.fitRatio > 1 ? 1 : item.fitRatio, s = item.container.style, w = zoomRatio * item.w, @@ -640,11 +611,9 @@ var _isOpen, s.height = h + 'px'; s.left = item.initialPosition.x + 'px'; s.top = item.initialPosition.y + 'px'; - }; - _applyCurrentZoomPan = function() { - if(_currZoomElementStyle) { - + _applyCurrentZoomPan = function () { + if (_currZoomElementStyle) { var s = _currZoomElementStyle, item = self.currItem, zoomRatio = item.fitRatio > 1 ? 1 : item.fitRatio, @@ -654,31 +623,28 @@ var _isOpen, s.width = w + 'px'; s.height = h + 'px'; - s.left = _panOffset.x + 'px'; s.top = _panOffset.y + 'px'; } - }; }, - - _onKeyDown = function(e) { + _onKeyDown = function (e) { var keydownAction = ''; - if(_options.escKey && e.keyCode === 27) { + if (_options.escKey && e.keyCode === 27) { keydownAction = 'close'; - } else if(_options.arrowKeys) { - if(e.keyCode === 37) { + } else if (_options.arrowKeys) { + if (e.keyCode === 37) { keydownAction = 'prev'; - } else if(e.keyCode === 39) { + } else if (e.keyCode === 39) { keydownAction = 'next'; } } - if(keydownAction) { + if (keydownAction) { // don't do anything if special key pressed to prevent from overriding default browser actions // e.g. in Chrome on Mac cmd+arrow-left returns to previous page - if( !e.ctrlKey && !e.altKey && !e.shiftKey && !e.metaKey ) { - if(e.preventDefault) { + if (!e.ctrlKey && !e.altKey && !e.shiftKey && !e.metaKey) { + if (e.preventDefault) { e.preventDefault(); } else { e.returnValue = false; @@ -687,79 +653,69 @@ var _isOpen, } } }, - - _onGlobalClick = function(e) { - if(!e) { + _onGlobalClick = function (e) { + if (!e) { return; } // don't allow click event to pass through when triggering after drag or some other gesture - if(_moved || _zoomStarted || _mainScrollAnimating || _verticalDragInitiated) { + if (_moved || _zoomStarted || _mainScrollAnimating || _verticalDragInitiated) { e.preventDefault(); e.stopPropagation(); } }, - - _updatePageScrollOffset = function() { + _updatePageScrollOffset = function () { self.setScrollOffset(0, framework.getScrollY()); }; - - - - - - // Micro animation engine var _animations = {}, _numAnimations = 0, - _stopAnimation = function(name) { - if(_animations[name]) { - if(_animations[name].raf) { - _cancelAF( _animations[name].raf ); + _stopAnimation = function (name) { + if (_animations[name]) { + if (_animations[name].raf) { + _cancelAF(_animations[name].raf); } _numAnimations--; delete _animations[name]; } }, - _registerStartAnimation = function(name) { - if(_animations[name]) { + _registerStartAnimation = function (name) { + if (_animations[name]) { _stopAnimation(name); } - if(!_animations[name]) { + if (!_animations[name]) { _numAnimations++; _animations[name] = {}; } }, - _stopAllAnimations = function() { + _stopAllAnimations = function () { for (var prop in _animations) { - - if( _animations.hasOwnProperty( prop ) ) { + if (_animations.hasOwnProperty(prop)) { _stopAnimation(prop); } - } }, - _animateProp = function(name, b, endProp, d, easingFn, onUpdate, onComplete) { - var startAnimTime = _getCurrentTime(), t; + _animateProp = function (name, b, endProp, d, easingFn, onUpdate, onComplete) { + var startAnimTime = _getCurrentTime(), + t; _registerStartAnimation(name); - var animloop = function(){ - if ( _animations[name] ) { - + var animloop = function () { + if (_animations[name]) { t = _getCurrentTime() - startAnimTime; // time diff //b - beginning (start prop) //d - anim duration - if ( t >= d ) { + if (t >= d) { _stopAnimation(name); onUpdate(endProp); - if(onComplete) { + if (onComplete) { onComplete(); } return; } - onUpdate( (endProp - b) * easingFn(t/d) + b ); + onUpdate((endProp - b) * easingFn(t / d) + b); _animations[name].raf = _requestAF(animloop); } @@ -767,46 +723,42 @@ var _animations = {}, animloop(); }; - - var publicMethods = { - // make a few local variables and functions public shout: _shout, listen: _listen, viewportSize: _viewportSize, options: _options, - isMainScrollAnimating: function() { + isMainScrollAnimating: function () { return _mainScrollAnimating; }, - getZoomLevel: function() { + getZoomLevel: function () { return _currZoomLevel; }, - getCurrentIndex: function() { + getCurrentIndex: function () { return _currentItemIndex; }, - isDragging: function() { + isDragging: function () { return _isDragging; }, - isZooming: function() { + isZooming: function () { return _isZooming; }, - setScrollOffset: function(x,y) { + setScrollOffset: function (x, y) { _offset.x = x; _currentWindowScrollY = _offset.y = y; _shout('updateScrollOffset', _offset); }, - applyZoomPan: function(zoomLevel,panX,panY,allowRenderResolution) { + applyZoomPan: function (zoomLevel, panX, panY, allowRenderResolution) { _panOffset.x = panX; _panOffset.y = panY; _currZoomLevel = zoomLevel; - _applyCurrentZoomPan( allowRenderResolution ); + _applyCurrentZoomPan(allowRenderResolution); }, - init: function() { - - if(_isOpen || _isDestroying) { + init: function () { + if (_isOpen || _isDestroying) { return; } @@ -832,9 +784,9 @@ var publicMethods = { // Objects that hold slides (there are only 3 in DOM) self.itemHolders = _itemHolders = [ - {el:self.container.children[0] , wrap:0, index: -1}, - {el:self.container.children[1] , wrap:0, index: -1}, - {el:self.container.children[2] , wrap:0, index: -1} + {el: self.container.children[0], wrap: 0, index: -1}, + {el: self.container.children[1], wrap: 0, index: -1}, + {el: self.container.children[2], wrap: 0, index: -1} ]; // hide nearby item holders until initial zoom animation finishes (to avoid extra Paints) @@ -849,10 +801,10 @@ var publicMethods = { // Fixes: iOS 10.3 resize event // does not update scrollWrap.clientWidth instantly after resize // https://github.com/dimsemenov/PhotoSwipe/issues/1315 - orientationchange: function() { + orientationchange: function () { clearTimeout(_orientationChangeTimeout); - _orientationChangeTimeout = setTimeout(function() { - if(_viewportSize.x !== self.scrollWrap.clientWidth) { + _orientationChangeTimeout = setTimeout(function () { + if (_viewportSize.x !== self.scrollWrap.clientWidth) { self.updateSize(); } }, 500); @@ -865,37 +817,36 @@ var publicMethods = { // disable show/hide effects on old browsers that don't support CSS animations or transforms, // old IOS, Android and Opera mobile. Blackberry seems to work fine, even older models. var oldPhone = _features.isOldIOSPhone || _features.isOldAndroid || _features.isMobileOpera; - if(!_features.animationName || !_features.transform || oldPhone) { + if (!_features.animationName || !_features.transform || oldPhone) { _options.showAnimationDuration = _options.hideAnimationDuration = 0; } // init modules - for(i = 0; i < _modules.length; i++) { + for (i = 0; i < _modules.length; i++) { self['init' + _modules[i]](); } // init - if(UiClass) { - var ui = self.ui = new UiClass(self, framework); + if (UiClass) { + var ui = (self.ui = new UiClass(self, framework)); ui.init(); } _shout('firstUpdate'); _currentItemIndex = _currentItemIndex || _options.index || 0; // validate index - if( isNaN(_currentItemIndex) || _currentItemIndex < 0 || _currentItemIndex >= _getNumItems() ) { + if (isNaN(_currentItemIndex) || _currentItemIndex < 0 || _currentItemIndex >= _getNumItems()) { _currentItemIndex = 0; } - self.currItem = _getItemAt( _currentItemIndex ); - + self.currItem = _getItemAt(_currentItemIndex); - if(_features.isOldIOSPhone || _features.isOldAndroid) { + if (_features.isOldIOSPhone || _features.isOldAndroid) { _isFixedPosition = false; } template.setAttribute('aria-hidden', 'false'); - if(_options.modal) { - if(!_isFixedPosition) { + if (_options.modal) { + if (!_isFixedPosition) { template.style.position = 'absolute'; template.style.top = framework.getScrollY() + 'px'; } else { @@ -903,17 +854,17 @@ var publicMethods = { } } - if(_currentWindowScrollY === undefined) { + if (_currentWindowScrollY === undefined) { _shout('initialLayout'); _currentWindowScrollY = _initalWindowScrollY = framework.getScrollY(); } // add classes to root element of PhotoSwipe var rootClasses = 'pswp--open '; - if(_options.mainClass) { + if (_options.mainClass) { rootClasses += _options.mainClass + ' '; } - if(_options.showHideOpacity) { + if (_options.showHideOpacity) { rootClasses += 'pswp--animate_opacity '; } rootClasses += _likelyTouchDevice ? 'pswp--touch' : 'pswp--notouch'; @@ -926,28 +877,27 @@ var publicMethods = { // initial update _containerShiftIndex = -1; _indexDiff = null; - for(i = 0; i < NUM_HOLDERS; i++) { - _setTranslateX( (i+_containerShiftIndex) * _slideSize.x, _itemHolders[i].el.style); + for (i = 0; i < NUM_HOLDERS; i++) { + _setTranslateX((i + _containerShiftIndex) * _slideSize.x, _itemHolders[i].el.style); } - if(!_oldIE) { + if (!_oldIE) { framework.bind(self.scrollWrap, _downEvents, self); // no dragging for old IE } - _listen('initialZoomInEnd', function() { - self.setContent(_itemHolders[0], _currentItemIndex-1); - self.setContent(_itemHolders[2], _currentItemIndex+1); + _listen('initialZoomInEnd', function () { + self.setContent(_itemHolders[0], _currentItemIndex - 1); + self.setContent(_itemHolders[2], _currentItemIndex + 1); _itemHolders[0].el.style.display = _itemHolders[2].el.style.display = 'block'; - if(_options.focus) { + if (_options.focus) { // focus causes layout, // which causes lag during the animation, // that's why we delay it untill the initial zoom transition ends template.focus(); } - _bindEvents(); }); @@ -958,8 +908,7 @@ var publicMethods = { _shout('afterInit'); - if(!_isFixedPosition) { - + if (!_isFixedPosition) { // On all versions of iOS lower than 8.0, we check size of viewport every second. // // This is done to detect when Safari top & bottom bars appear, @@ -969,8 +918,8 @@ var publicMethods = { // // 10 Nov 2014: iOS 7 usage ~40%. iOS 8 usage 56%. - _updateSizeInterval = setInterval(function() { - if(!_numAnimations && !_isDragging && !_isZooming && (_currZoomLevel === self.currItem.initialZoomLevel) ) { + _updateSizeInterval = setInterval(function () { + if (!_numAnimations && !_isDragging && !_isZooming && _currZoomLevel === self.currItem.initialZoomLevel) { self.updateSize(); } }, 1000); @@ -980,8 +929,8 @@ var publicMethods = { }, // Close the gallery, then destroy it - close: function() { - if(!_isOpen) { + close: function () { + if (!_isOpen) { return; } @@ -994,17 +943,17 @@ var publicMethods = { }, // destroys the gallery (unbinds events, cleans up intervals and timeouts to avoid memory leaks) - destroy: function() { + destroy: function () { _shout('destroy'); - if(_showOrHideTimeout) { + if (_showOrHideTimeout) { clearTimeout(_showOrHideTimeout); } template.setAttribute('aria-hidden', 'true'); template.className = _initalClassName; - if(_updateSizeInterval) { + if (_updateSizeInterval) { clearInterval(_updateSizeInterval); } @@ -1026,17 +975,17 @@ var publicMethods = { * @param {Number} y * @param {Boolean} force Will ignore bounds if set to true. */ - panTo: function(x,y,force) { - if(!force) { - if(x > _currPanBounds.min.x) { + panTo: function (x, y, force) { + if (!force) { + if (x > _currPanBounds.min.x) { x = _currPanBounds.min.x; - } else if(x < _currPanBounds.max.x) { + } else if (x < _currPanBounds.max.x) { x = _currPanBounds.max.x; } - if(y > _currPanBounds.min.y) { + if (y > _currPanBounds.min.y) { y = _currPanBounds.min.y; - } else if(y < _currPanBounds.max.y) { + } else if (y < _currPanBounds.max.y) { y = _currPanBounds.max.y; } } @@ -1048,39 +997,36 @@ var publicMethods = { handleEvent: function (e) { e = e || window.event; - if(_globalEventHandlers[e.type]) { + if (_globalEventHandlers[e.type]) { _globalEventHandlers[e.type](e); } }, - - goTo: function(index) { - + goTo: function (index) { index = _getLoopedId(index); var diff = index - _currentItemIndex; _indexDiff = diff; _currentItemIndex = index; - self.currItem = _getItemAt( _currentItemIndex ); + self.currItem = _getItemAt(_currentItemIndex); _currPositionIndex -= diff; _moveMainScroll(_slideSize.x * _currPositionIndex); - _stopAllAnimations(); _mainScrollAnimating = false; self.updateCurrItem(); }, - next: function() { - self.goTo( parseInt(_currentItemIndex) + 1); + next: function () { + self.goTo(parseInt(_currentItemIndex) + 1); }, - prev: function() { - self.goTo( parseInt(_currentItemIndex) - 1); + prev: function () { + self.goTo(parseInt(_currentItemIndex) - 1); }, - setItems: function(items) { + setItems: function (items) { var last = items.length - 1; var currItem = self.currItem; var prevItem = self.items[_prevItemIndex]; @@ -1088,18 +1034,18 @@ var publicMethods = { var newIndex; for (var i = 0; i < items.length; i++) { self.items.push(items[i]); - if(items[i] === currItem) { + if (items[i] === currItem) { newIndex = i; } } - if(!newIndex) { - if(_currentItemIndex >= last) { + if (!newIndex) { + if (_currentItemIndex >= last) { _currentItemIndex = last; } } else { _currentItemIndex = newIndex; } - if(self.items[_currentItemIndex - 1] === prevItem) { + if (self.items[_currentItemIndex - 1] === prevItem) { _prevItemIndex = _currentItemIndex - 1; } else { _prevItemIndex = _currentItemIndex; @@ -1110,15 +1056,15 @@ var publicMethods = { }, // update current zoom/pan objects - updateCurrZoomItem: function(emulateSetContent) { - if(emulateSetContent) { + updateCurrZoomItem: function (emulateSetContent) { + if (emulateSetContent) { _shout('beforeChange', 0); } // itemHolder[1] is middle (current) item - if(_itemHolders[1].el.children.length) { + if (_itemHolders[1].el.children.length) { var zoomElement = _itemHolders[1].el.children[0]; - if( framework.hasClass(zoomElement, 'pswp__zoom-wrap') ) { + if (framework.hasClass(zoomElement, 'pswp__zoom-wrap')) { _currZoomElementStyle = zoomElement.style; } else { _currZoomElementStyle = null; @@ -1133,73 +1079,67 @@ var publicMethods = { _panOffset.x = _currPanBounds.center.x; _panOffset.y = _currPanBounds.center.y; - if(emulateSetContent) { + if (emulateSetContent) { _shout('afterChange'); } }, - - invalidateCurrItems: function() { + invalidateCurrItems: function () { _itemsNeedUpdate = true; - for(var i = 0; i < NUM_HOLDERS; i++) { - if( _itemHolders[i].item ) { + for (var i = 0; i < NUM_HOLDERS; i++) { + if (_itemHolders[i].item) { _itemHolders[i].item.needsUpdate = true; } } }, - updateCurrItem: function(beforeAnimation) { - - if(_indexDiff === 0) { + updateCurrItem: function (beforeAnimation) { + if (_indexDiff === 0) { return; } var diffAbs = Math.abs(_indexDiff), tempHolder; - if(beforeAnimation && diffAbs < 2) { + if (beforeAnimation && diffAbs < 2) { return; } - - self.currItem = _getItemAt( _currentItemIndex ); + self.currItem = _getItemAt(_currentItemIndex); _renderMaxResolution = false; _shout('beforeChange', _indexDiff); - if(diffAbs >= NUM_HOLDERS) { + if (diffAbs >= NUM_HOLDERS) { _containerShiftIndex += _indexDiff + (_indexDiff > 0 ? -NUM_HOLDERS : NUM_HOLDERS); diffAbs = NUM_HOLDERS; } - for(var i = 0; i < diffAbs; i++) { - if(_indexDiff > 0) { + for (var i = 0; i < diffAbs; i++) { + if (_indexDiff > 0) { tempHolder = _itemHolders.shift(); - _itemHolders[NUM_HOLDERS-1] = tempHolder; // move first to last + _itemHolders[NUM_HOLDERS - 1] = tempHolder; // move first to last _containerShiftIndex++; - _setTranslateX( (_containerShiftIndex+2) * _slideSize.x, tempHolder.el.style); + _setTranslateX((_containerShiftIndex + 2) * _slideSize.x, tempHolder.el.style); self.setContent(tempHolder, _currentItemIndex - diffAbs + i + 1 + 1); } else { tempHolder = _itemHolders.pop(); - _itemHolders.unshift( tempHolder ); // move last to first + _itemHolders.unshift(tempHolder); // move last to first _containerShiftIndex--; - _setTranslateX( _containerShiftIndex * _slideSize.x, tempHolder.el.style); + _setTranslateX(_containerShiftIndex * _slideSize.x, tempHolder.el.style); self.setContent(tempHolder, _currentItemIndex + diffAbs - i - 1 - 1); } - } // reset zoom/pan on previous item - if(_currZoomElementStyle && Math.abs(_indexDiff) === 1) { - + if (_currZoomElementStyle && Math.abs(_indexDiff) === 1) { var prevItem = _getItemAt(_prevItemIndex); - if(prevItem.initialZoomLevel !== _currZoomLevel) { - _calculateItemSize(prevItem , _viewportSize ); + if (prevItem.initialZoomLevel !== _currZoomLevel) { + _calculateItemSize(prevItem, _viewportSize); _setImageSize(prevItem); - _applyZoomPanToItem( prevItem ); + _applyZoomPanToItem(prevItem); } - } // reset diff after update @@ -1210,20 +1150,16 @@ var publicMethods = { _prevItemIndex = _currentItemIndex; _shout('afterChange'); - }, - - - updateSize: function(force) { - - if(!_isFixedPosition && _options.modal) { + updateSize: function (force) { + if (!_isFixedPosition && _options.modal) { var windowScrollY = framework.getScrollY(); - if(_currentWindowScrollY !== windowScrollY) { + if (_currentWindowScrollY !== windowScrollY) { template.style.top = windowScrollY + 'px'; _currentWindowScrollY = windowScrollY; } - if(!force && _windowVisibleSize.x === window.innerWidth && _windowVisibleSize.y === window.innerHeight) { + if (!force && _windowVisibleSize.x === window.innerWidth && _windowVisibleSize.y === window.innerHeight) { return; } _windowVisibleSize.x = window.innerWidth; @@ -1233,8 +1169,6 @@ var publicMethods = { template.style.height = _windowVisibleSize.y + 'px'; } - - _viewportSize.x = self.scrollWrap.clientWidth; _viewportSize.y = self.scrollWrap.clientHeight; @@ -1247,53 +1181,46 @@ var publicMethods = { _shout('beforeResize'); // even may be used for example to switch image sources - // don't re-calculate size on inital size update - if(_containerShiftIndex !== undefined) { + if (_containerShiftIndex !== undefined) { + var holder, item, hIndex; - var holder, - item, - hIndex; - - for(var i = 0; i < NUM_HOLDERS; i++) { + for (var i = 0; i < NUM_HOLDERS; i++) { holder = _itemHolders[i]; - _setTranslateX( (i+_containerShiftIndex) * _slideSize.x, holder.el.style); + _setTranslateX((i + _containerShiftIndex) * _slideSize.x, holder.el.style); - hIndex = _currentItemIndex+i-1; + hIndex = _currentItemIndex + i - 1; - if(_options.loop && _getNumItems() > 2) { + if (_options.loop && _getNumItems() > 2) { hIndex = _getLoopedId(hIndex); } // update zoom level on items and refresh source (if needsUpdate) - item = _getItemAt( hIndex ); + item = _getItemAt(hIndex); // re-render gallery item if `needsUpdate`, // or doesn't have `bounds` (entirely new slide object) - if( item && (_itemsNeedUpdate || item.needsUpdate || !item.bounds) ) { - - self.cleanSlide( item ); + if (item && (_itemsNeedUpdate || item.needsUpdate || !item.bounds)) { + self.cleanSlide(item); - self.setContent( holder, hIndex ); + self.setContent(holder, hIndex); // if "center" slide - if(i === 1) { + if (i === 1) { self.currItem = item; self.updateCurrZoomItem(true); } item.needsUpdate = false; - - } else if(holder.index === -1 && hIndex >= 0) { + } else if (holder.index === -1 && hIndex >= 0) { // add content first time - self.setContent( holder, hIndex ); + self.setContent(holder, hIndex); } - if(item && item.container) { + if (item && item.container) { _calculateItemSize(item, _viewportSize); _setImageSize(item); - _applyZoomPanToItem( item ); + _applyZoomPanToItem(item); } - } _itemsNeedUpdate = false; } @@ -1301,17 +1228,17 @@ var publicMethods = { _startZoomLevel = _currZoomLevel = self.currItem.initialZoomLevel; _currPanBounds = self.currItem.bounds; - if(_currPanBounds) { + if (_currPanBounds) { _panOffset.x = _currPanBounds.center.x; _panOffset.y = _currPanBounds.center.y; - _applyCurrentZoomPan( true ); + _applyCurrentZoomPan(true); } _shout('resize'); }, // Zoom current item to - zoomTo: function(destZoomLevel, centerPoint, speed, easingFn, updateFn) { + zoomTo: function (destZoomLevel, centerPoint, speed, easingFn, updateFn) { /* if(destZoomLevel === 'fit') { destZoomLevel = self.currItem.fitRatio; @@ -1320,10 +1247,10 @@ var publicMethods = { } */ - if(centerPoint) { + if (centerPoint) { _startZoomLevel = _currZoomLevel; - _midZoomPoint.x = Math.abs(centerPoint.x) - _panOffset.x ; - _midZoomPoint.y = Math.abs(centerPoint.y) - _panOffset.y ; + _midZoomPoint.x = Math.abs(centerPoint.x) - _panOffset.x; + _midZoomPoint.y = Math.abs(centerPoint.y) - _panOffset.y; _equalizePoints(_startPanOffset, _panOffset); } @@ -1341,8 +1268,8 @@ var publicMethods = { _roundPoint(destPanOffset); - var onUpdate = function(now) { - if(now === 1) { + var onUpdate = function (now) { + if (now === 1) { _currZoomLevel = destZoomLevel; _panOffset.x = destPanOffset.x; _panOffset.y = destPanOffset.y; @@ -1352,21 +1279,19 @@ var publicMethods = { _panOffset.y = (destPanOffset.y - initialPanOffset.y) * now + initialPanOffset.y; } - if(updateFn) { + if (updateFn) { updateFn(now); } - _applyCurrentZoomPan( now === 1 ); + _applyCurrentZoomPan(now === 1); }; - if(speed) { + if (speed) { _animateProp('customZoomTo', 0, 1, speed, easingFn || framework.easing.sine.inOut, onUpdate); } else { onUpdate(1); } } - - }; @@ -1375,7 +1300,7 @@ var publicMethods = { /*>>gestures*/ /** * Mouse/touch/pointer event handlers. - * + * * separated from @core.js for readability */ @@ -1384,7 +1309,6 @@ var MIN_SWIPE_DISTANCE = 30, var _gestureStartTime, _gestureCheckSpeedTime, - // pool of objects that are used during dragging of zooming p = {}, // first point p2 = {}, // second point (for zoom gesture) @@ -1396,7 +1320,6 @@ var _gestureStartTime, _releaseAnimData, _posPoints = [], // array of points during dragging, used to determine type of gesture _tempPoint = {}, - _isZoomingIn, _verticalDragInitiated, _oldAndroidTouchEndTimeout, @@ -1424,131 +1347,119 @@ var _gestureStartTime, _opacityChanged, _bgOpacity, _wasOverInitialZoom, - - _isEqualPoints = function(p1, p2) { + _isEqualPoints = function (p1, p2) { return p1.x === p2.x && p1.y === p2.y; }, - _isNearbyPoints = function(touch0, touch1) { + _isNearbyPoints = function (touch0, touch1) { return Math.abs(touch0.x - touch1.x) < DOUBLE_TAP_RADIUS && Math.abs(touch0.y - touch1.y) < DOUBLE_TAP_RADIUS; }, - _calculatePointsDistance = function(p1, p2) { - _tempPoint.x = Math.abs( p1.x - p2.x ); - _tempPoint.y = Math.abs( p1.y - p2.y ); + _calculatePointsDistance = function (p1, p2) { + _tempPoint.x = Math.abs(p1.x - p2.x); + _tempPoint.y = Math.abs(p1.y - p2.y); return Math.sqrt(_tempPoint.x * _tempPoint.x + _tempPoint.y * _tempPoint.y); }, - _stopDragUpdateLoop = function() { - if(_dragAnimFrame) { + _stopDragUpdateLoop = function () { + if (_dragAnimFrame) { _cancelAF(_dragAnimFrame); _dragAnimFrame = null; } }, - _dragUpdateLoop = function() { - if(_isDragging) { + _dragUpdateLoop = function () { + if (_isDragging) { _dragAnimFrame = _requestAF(_dragUpdateLoop); _renderMovement(); } }, - _canPan = function() { - return !(_options.scaleMode === 'fit' && _currZoomLevel === self.currItem.initialZoomLevel); + _canPan = function () { + return !(_options.scaleMode === 'fit' && _currZoomLevel === self.currItem.initialZoomLevel); }, - // find the closest parent DOM element - _closestElement = function(el, fn) { - if(!el || el === document) { - return false; - } + _closestElement = function (el, fn) { + if (!el || el === document) { + return false; + } - // don't search elements above pswp__scroll-wrap - if(el.getAttribute('class') && el.getAttribute('class').indexOf('pswp__scroll-wrap') > -1 ) { - return false; - } + // don't search elements above pswp__scroll-wrap + if (el.getAttribute('class') && el.getAttribute('class').indexOf('pswp__scroll-wrap') > -1) { + return false; + } - if( fn(el) ) { - return el; - } + if (fn(el)) { + return el; + } - return _closestElement(el.parentNode, fn); + return _closestElement(el.parentNode, fn); }, - _preventObj = {}, - _preventDefaultEventBehaviour = function(e, isDown) { - _preventObj.prevent = !_closestElement(e.target, _options.isClickableElement); + _preventDefaultEventBehaviour = function (e, isDown) { + _preventObj.prevent = !_closestElement(e.target, _options.isClickableElement); _shout('preventDragEvent', e, isDown, _preventObj); return _preventObj.prevent; - }, - _convertTouchToPoint = function(touch, p) { + _convertTouchToPoint = function (touch, p) { p.x = touch.pageX; p.y = touch.pageY; p.id = touch.identifier; return p; }, - _findCenterOfPoints = function(p1, p2, pCenter) { + _findCenterOfPoints = function (p1, p2, pCenter) { pCenter.x = (p1.x + p2.x) * 0.5; pCenter.y = (p1.y + p2.y) * 0.5; }, - _pushPosPoint = function(time, x, y) { - if(time - _gestureCheckSpeedTime > 50) { + _pushPosPoint = function (time, x, y) { + if (time - _gestureCheckSpeedTime > 50) { var o = _posPoints.length > 2 ? _posPoints.shift() : {}; o.x = x; - o.y = y; + o.y = y; _posPoints.push(o); _gestureCheckSpeedTime = time; } }, - - _calculateVerticalDragOpacityRatio = function() { + _calculateVerticalDragOpacityRatio = function () { var yOffset = _panOffset.y - self.currItem.initialPosition.y; // difference between initial and current position - return 1 - Math.abs( yOffset / (_viewportSize.y / 2) ); + return 1 - Math.abs(yOffset / (_viewportSize.y / 2)); }, - - // points pool, reused during touch events _ePoint1 = {}, _ePoint2 = {}, _tempPointsArr = [], _tempCounter, - _getTouchPoints = function(e) { + _getTouchPoints = function (e) { // clean up previous points, without recreating array - while(_tempPointsArr.length > 0) { + while (_tempPointsArr.length > 0) { _tempPointsArr.pop(); } - if(!_pointerEventEnabled) { - if(e.type.indexOf('touch') > -1) { - - if(e.touches && e.touches.length > 0) { + if (!_pointerEventEnabled) { + if (e.type.indexOf('touch') > -1) { + if (e.touches && e.touches.length > 0) { _tempPointsArr[0] = _convertTouchToPoint(e.touches[0], _ePoint1); - if(e.touches.length > 1) { + if (e.touches.length > 1) { _tempPointsArr[1] = _convertTouchToPoint(e.touches[1], _ePoint2); } } - } else { _ePoint1.x = e.pageX; _ePoint1.y = e.pageY; _ePoint1.id = ''; - _tempPointsArr[0] = _ePoint1;//_ePoint1; + _tempPointsArr[0] = _ePoint1; //_ePoint1; } } else { _tempCounter = 0; // we can use forEach, as pointer events are supported only in modern browsers - _currPointers.forEach(function(p) { - if(_tempCounter === 0) { + _currPointers.forEach(function (p) { + if (_tempCounter === 0) { _tempPointsArr[0] = p; - } else if(_tempCounter === 1) { + } else if (_tempCounter === 1) { _tempPointsArr[1] = p; } _tempCounter++; - }); } return _tempPointsArr; }, - - _panOrMoveMainScroll = function(axis, delta) { - + _panOrMoveMainScroll = function (axis, delta) { var panFriction, overDiff = 0, newOffset = _panOffset[axis] + delta[axis], @@ -1560,150 +1471,126 @@ var _gestureStartTime, newMainScrollPos; // calculate fdistance over the bounds and friction - if(newOffset > _currPanBounds.min[axis] || newOffset < _currPanBounds.max[axis]) { + if (newOffset > _currPanBounds.min[axis] || newOffset < _currPanBounds.max[axis]) { panFriction = _options.panEndFriction; - // Linear increasing of friction, so at 1/4 of viewport it's at max value. + // Linear increasing of friction, so at 1/4 of viewport it's at max value. // Looks not as nice as was expected. Left for history. // panFriction = (1 - (_panOffset[axis] + delta[axis] + panBounds.min[axis]) / (_viewportSize[axis] / 4) ); } else { panFriction = 1; } - + newOffset = _panOffset[axis] + delta[axis] * panFriction; // move main scroll or start panning - if(_options.allowPanToNext || _currZoomLevel === self.currItem.initialZoomLevel) { - - - if(!_currZoomElementStyle) { - + if (_options.allowPanToNext || _currZoomLevel === self.currItem.initialZoomLevel) { + if (!_currZoomElementStyle) { newMainScrollPos = newMainScrollPosition; - - } else if(_direction === 'h' && axis === 'x' && !_zoomStarted ) { - - if(dir) { - if(newOffset > _currPanBounds.min[axis]) { + } else if (_direction === 'h' && axis === 'x' && !_zoomStarted) { + if (dir) { + if (newOffset > _currPanBounds.min[axis]) { panFriction = _options.panEndFriction; overDiff = _currPanBounds.min[axis] - newOffset; startOverDiff = _currPanBounds.min[axis] - _startPanOffset[axis]; } - + // drag right - if( (startOverDiff <= 0 || mainScrollDiff < 0) && _getNumItems() > 1 ) { + if ((startOverDiff <= 0 || mainScrollDiff < 0) && _getNumItems() > 1) { newMainScrollPos = newMainScrollPosition; - if(mainScrollDiff < 0 && newMainScrollPosition > _startMainScrollPos.x) { + if (mainScrollDiff < 0 && newMainScrollPosition > _startMainScrollPos.x) { newMainScrollPos = _startMainScrollPos.x; } } else { - if(_currPanBounds.min.x !== _currPanBounds.max.x) { + if (_currPanBounds.min.x !== _currPanBounds.max.x) { newPanPos = newOffset; } - } - } else { - - if(newOffset < _currPanBounds.max[axis] ) { - panFriction =_options.panEndFriction; + if (newOffset < _currPanBounds.max[axis]) { + panFriction = _options.panEndFriction; overDiff = newOffset - _currPanBounds.max[axis]; startOverDiff = _startPanOffset[axis] - _currPanBounds.max[axis]; } - if( (startOverDiff <= 0 || mainScrollDiff > 0) && _getNumItems() > 1 ) { + if ((startOverDiff <= 0 || mainScrollDiff > 0) && _getNumItems() > 1) { newMainScrollPos = newMainScrollPosition; - if(mainScrollDiff > 0 && newMainScrollPosition < _startMainScrollPos.x) { + if (mainScrollDiff > 0 && newMainScrollPosition < _startMainScrollPos.x) { newMainScrollPos = _startMainScrollPos.x; } - } else { - if(_currPanBounds.min.x !== _currPanBounds.max.x) { + if (_currPanBounds.min.x !== _currPanBounds.max.x) { newPanPos = newOffset; } } - } - // } - if(axis === 'x') { - - if(newMainScrollPos !== undefined) { + if (axis === 'x') { + if (newMainScrollPos !== undefined) { _moveMainScroll(newMainScrollPos, true); - if(newMainScrollPos === _startMainScrollPos.x) { + if (newMainScrollPos === _startMainScrollPos.x) { _mainScrollShifted = false; } else { _mainScrollShifted = true; } } - if(_currPanBounds.min.x !== _currPanBounds.max.x) { - if(newPanPos !== undefined) { + if (_currPanBounds.min.x !== _currPanBounds.max.x) { + if (newPanPos !== undefined) { _panOffset.x = newPanPos; - } else if(!_mainScrollShifted) { + } else if (!_mainScrollShifted) { _panOffset.x += delta.x * panFriction; } } return newMainScrollPos !== undefined; } - } - if(!_mainScrollAnimating) { - - if(!_mainScrollShifted) { - if(_currZoomLevel > self.currItem.fitRatio) { + if (!_mainScrollAnimating) { + if (!_mainScrollShifted) { + if (_currZoomLevel > self.currItem.fitRatio) { _panOffset[axis] += delta[axis] * panFriction; - } } - - } - }, - // Pointerdown/touchstart/mousedown handler - _onDragStart = function(e) { - + _onDragStart = function (e) { // Allow dragging only via left mouse button. // As this handler is not added in IE8 - we ignore e.which - // + // // http://www.quirksmode.org/js/events_properties.html // https://developer.mozilla.org/en-US/docs/Web/API/event.button - if(e.type === 'mousedown' && (e.button > 0 || e.buttons === 0)) { + if (e.type === 'mousedown' && (e.button > 0 || e.buttons === 0)) { return; } - if(_initialZoomRunning) { + if (_initialZoomRunning) { e.preventDefault(); return; } - if(_oldAndroidTouchEndTimeout && e.type === 'mousedown') { + if (_oldAndroidTouchEndTimeout && e.type === 'mousedown') { return; } - if(_preventDefaultEventBehaviour(e, true)) { + if (_preventDefaultEventBehaviour(e, true)) { e.preventDefault(); } - - _shout('pointerDown'); - if(_pointerEventEnabled) { + if (_pointerEventEnabled) { var pointerIndex = framework.arraySearch(_currPointers, e.pointerId, 'id'); - if(pointerIndex < 0) { + if (pointerIndex < 0) { pointerIndex = _currPointers.length; } - _currPointers[pointerIndex] = {x:e.pageX, y:e.pageY, id: e.pointerId}; + _currPointers[pointerIndex] = {x: e.pageX, y: e.pageY, id: e.pointerId}; } - - var startPointsList = _getTouchPoints(e), numPoints = startPointsList.length; @@ -1713,21 +1600,11 @@ var _gestureStartTime, _stopAllAnimations(); // init drag - if(!_isDragging || numPoints === 1) { - - - + if (!_isDragging || numPoints === 1) { _isDragging = _isFirstMove = true; framework.bind(window, _upMoveEvents, self); - _isZoomingIn = - _wasOverInitialZoom = - _opacityChanged = - _verticalDragInitiated = - _mainScrollShifted = - _moved = - _isMultitouch = - _zoomStarted = false; + _isZoomingIn = _wasOverInitialZoom = _opacityChanged = _verticalDragInitiated = _mainScrollShifted = _moved = _isMultitouch = _zoomStarted = false; _direction = null; @@ -1742,24 +1619,25 @@ var _gestureStartTime, //_equalizePoints(_startMainScrollPos, _mainScrollPos); _startMainScrollPos.x = _slideSize.x * _currPositionIndex; - _posPoints = [{ - x: _currPoint.x, - y: _currPoint.y - }]; + _posPoints = [ + { + x: _currPoint.x, + y: _currPoint.y + } + ]; _gestureCheckSpeedTime = _gestureStartTime = _getCurrentTime(); //_mainScrollAnimationEnd(true); - _calculatePanBounds( _currZoomLevel, true ); - + _calculatePanBounds(_currZoomLevel, true); + // Start rendering _stopDragUpdateLoop(); _dragUpdateLoop(); - } // init zoom - if(!_isZooming && numPoints > 1 && !_mainScrollAnimating && !_mainScrollShifted) { + if (!_isZooming && numPoints > 1 && !_mainScrollAnimating && !_mainScrollShifted) { _startZoomLevel = _currZoomLevel; _zoomStarted = false; // true if zoom changed at least once @@ -1777,55 +1655,48 @@ var _gestureStartTime, _midZoomPoint.y = Math.abs(_currCenterPoint.y) - _panOffset.y; _currPointsDistance = _startPointsDistance = _calculatePointsDistance(p, p2); } - - }, - // Pointermove/touchmove/mousemove handler - _onDragMove = function(e) { - + _onDragMove = function (e) { e.preventDefault(); - if(_pointerEventEnabled) { + if (_pointerEventEnabled) { var pointerIndex = framework.arraySearch(_currPointers, e.pointerId, 'id'); - if(pointerIndex > -1) { + if (pointerIndex > -1) { var p = _currPointers[pointerIndex]; p.x = e.pageX; - p.y = e.pageY; + p.y = e.pageY; } } - if(_isDragging) { + if (_isDragging) { var touchesList = _getTouchPoints(e); - if(!_direction && !_moved && !_isZooming) { - - if(_mainScrollPos.x !== _slideSize.x * _currPositionIndex) { + if (!_direction && !_moved && !_isZooming) { + if (_mainScrollPos.x !== _slideSize.x * _currPositionIndex) { // if main scroll position is shifted – direction is always horizontal _direction = 'h'; } else { var diff = Math.abs(touchesList[0].x - _currPoint.x) - Math.abs(touchesList[0].y - _currPoint.y); // check the direction of movement - if(Math.abs(diff) >= DIRECTION_CHECK_OFFSET) { + if (Math.abs(diff) >= DIRECTION_CHECK_OFFSET) { _direction = diff > 0 ? 'h' : 'v'; _currentPoints = touchesList; } } - } else { _currentPoints = touchesList; } - } + } }, - // - _renderMovement = function() { - - if(!_currentPoints) { + // + _renderMovement = function () { + if (!_currentPoints) { return; } var numPoints = _currentPoints.length; - if(numPoints === 0) { + if (numPoints === 0) { return; } @@ -1834,32 +1705,31 @@ var _gestureStartTime, delta.x = p.x - _currPoint.x; delta.y = p.y - _currPoint.y; - if(_isZooming && numPoints > 1) { + if (_isZooming && numPoints > 1) { // Handle behaviour for more than 1 point _currPoint.x = p.x; _currPoint.y = p.y; - + // check if one of two points changed - if( !delta.x && !delta.y && _isEqualPoints(_currentPoints[1], p2) ) { + if (!delta.x && !delta.y && _isEqualPoints(_currentPoints[1], p2)) { return; } _equalizePoints(p2, _currentPoints[1]); - - if(!_zoomStarted) { + if (!_zoomStarted) { _zoomStarted = true; _shout('zoomGestureStarted'); } - + // Distance between two points - var pointsDistance = _calculatePointsDistance(p,p2); + var pointsDistance = _calculatePointsDistance(p, p2); var zoomLevel = _calculateZoomLevel(pointsDistance); // slightly over the of initial zoom level - if(zoomLevel > self.currItem.initialZoomLevel + self.currItem.initialZoomLevel / 15) { + if (zoomLevel > self.currItem.initialZoomLevel + self.currItem.initialZoomLevel / 15) { _wasOverInitialZoom = true; } @@ -1868,9 +1738,8 @@ var _gestureStartTime, minZoomLevel = _getMinZoomLevel(), maxZoomLevel = _getMaxZoomLevel(); - if ( zoomLevel < minZoomLevel ) { - - if(_options.pinchToClose && !_wasOverInitialZoom && _startZoomLevel <= self.currItem.initialZoomLevel) { + if (zoomLevel < minZoomLevel) { + if (_options.pinchToClose && !_wasOverInitialZoom && _startZoomLevel <= self.currItem.initialZoomLevel) { // fade out background if zooming out var minusDiff = minZoomLevel - zoomLevel; var percent = 1 - minusDiff / (minZoomLevel / 1.2); @@ -1880,22 +1749,21 @@ var _gestureStartTime, _opacityChanged = true; } else { zoomFriction = (minZoomLevel - zoomLevel) / minZoomLevel; - if(zoomFriction > 1) { + if (zoomFriction > 1) { zoomFriction = 1; } zoomLevel = minZoomLevel - zoomFriction * (minZoomLevel / 3); } - - } else if ( zoomLevel > maxZoomLevel ) { + } else if (zoomLevel > maxZoomLevel) { // 1.5 - extra zoom level above the max. E.g. if max is x6, real max 6 + 1.5 = 7.5 - zoomFriction = (zoomLevel - maxZoomLevel) / ( minZoomLevel * 6 ); - if(zoomFriction > 1) { + zoomFriction = (zoomLevel - maxZoomLevel) / (minZoomLevel * 6); + if (zoomFriction > 1) { zoomFriction = 1; } zoomLevel = maxZoomLevel + zoomFriction * minZoomLevel; } - if(zoomFriction < 0) { + if (zoomFriction < 0) { zoomFriction = 0; } @@ -1904,7 +1772,7 @@ var _gestureStartTime, // _centerPoint - The point in the middle of two pointers _findCenterOfPoints(p, p2, _centerPoint); - + // paning with two pointers pressed _currPanDist.x += _centerPoint.x - _currCenterPoint.x; _currPanDist.y += _centerPoint.y - _currCenterPoint.y; @@ -1916,25 +1784,23 @@ var _gestureStartTime, _isZoomingIn = zoomLevel > _currZoomLevel; _currZoomLevel = zoomLevel; _applyCurrentZoomPan(); - } else { - // handle behaviour for one point (dragging or panning) - if(!_direction) { + if (!_direction) { return; } - if(_isFirstMove) { + if (_isFirstMove) { _isFirstMove = false; - // subtract drag distance that was used during the detection direction + // subtract drag distance that was used during the detection direction - if( Math.abs(delta.x) >= DIRECTION_CHECK_OFFSET) { + if (Math.abs(delta.x) >= DIRECTION_CHECK_OFFSET) { delta.x -= _currentPoints[0].x - _startPoint.x; } - - if( Math.abs(delta.y) >= DIRECTION_CHECK_OFFSET) { + + if (Math.abs(delta.y) >= DIRECTION_CHECK_OFFSET) { delta.y -= _currentPoints[0].y - _startPoint.y; } } @@ -1943,12 +1809,12 @@ var _gestureStartTime, _currPoint.y = p.y; // do nothing if pointers position hasn't changed - if(delta.x === 0 && delta.y === 0) { + if (delta.x === 0 && delta.y === 0) { return; } - if(_direction === 'v' && _options.closeOnVerticalDrag) { - if(!_canPan()) { + if (_direction === 'v' && _options.closeOnVerticalDrag) { + if (!_canPan()) { _currPanDist.y += delta.y; _panOffset.y += delta.y; @@ -1959,7 +1825,7 @@ var _gestureStartTime, _applyBgOpacity(opacityRatio); _applyCurrentZoomPan(); - return ; + return; } } @@ -1967,70 +1833,63 @@ var _gestureStartTime, _moved = true; _currPanBounds = self.currItem.bounds; - + var mainScrollChanged = _panOrMoveMainScroll('x', delta); - if(!mainScrollChanged) { + if (!mainScrollChanged) { _panOrMoveMainScroll('y', delta); _roundPoint(_panOffset); _applyCurrentZoomPan(); } - } - }, - // Pointerup/pointercancel/touchend/touchcancel/mouseup event handler - _onDragRelease = function(e) { - - if(_features.isOldAndroid ) { - - if(_oldAndroidTouchEndTimeout && e.type === 'mouseup') { + _onDragRelease = function (e) { + if (_features.isOldAndroid) { + if (_oldAndroidTouchEndTimeout && e.type === 'mouseup') { return; } - // on Android (v4.1, 4.2, 4.3 & possibly older) + // on Android (v4.1, 4.2, 4.3 & possibly older) // ghost mousedown/up event isn't preventable via e.preventDefault, // which causes fake mousedown event // so we block mousedown/up for 600ms - if( e.type.indexOf('touch') > -1 ) { + if (e.type.indexOf('touch') > -1) { clearTimeout(_oldAndroidTouchEndTimeout); - _oldAndroidTouchEndTimeout = setTimeout(function() { + _oldAndroidTouchEndTimeout = setTimeout(function () { _oldAndroidTouchEndTimeout = 0; }, 600); } - } _shout('pointerUp'); - if(_preventDefaultEventBehaviour(e, false)) { + if (_preventDefaultEventBehaviour(e, false)) { e.preventDefault(); } var releasePoint; - if(_pointerEventEnabled) { + if (_pointerEventEnabled) { var pointerIndex = framework.arraySearch(_currPointers, e.pointerId, 'id'); - - if(pointerIndex > -1) { + + if (pointerIndex > -1) { releasePoint = _currPointers.splice(pointerIndex, 1)[0]; - if(navigator.msPointerEnabled) { + if (navigator.msPointerEnabled) { var MSPOINTER_TYPES = { 4: 'mouse', // event.MSPOINTER_TYPE_MOUSE - 2: 'touch', // event.MSPOINTER_TYPE_TOUCH + 2: 'touch', // event.MSPOINTER_TYPE_TOUCH 3: 'pen' // event.MSPOINTER_TYPE_PEN }; releasePoint.type = MSPOINTER_TYPES[e.pointerType]; - if(!releasePoint.type) { + if (!releasePoint.type) { releasePoint.type = e.pointerType || 'mouse'; } } else { releasePoint.type = e.pointerType || 'mouse'; } - } } @@ -2038,30 +1897,29 @@ var _gestureStartTime, gestureType, numPoints = touchList.length; - if(e.type === 'mouseup') { + if (e.type === 'mouseup') { numPoints = 0; } // Do nothing if there were 3 touch points or more - if(numPoints === 2) { + if (numPoints === 2) { _currentPoints = null; return true; } // if second pointer released - if(numPoints === 1) { + if (numPoints === 1) { _equalizePoints(_startPoint, touchList[0]); - } - + } // pointer hasn't moved, send "tap release" point - if(numPoints === 0 && !_direction && !_mainScrollAnimating) { - if(!releasePoint) { - if(e.type === 'mouseup') { - releasePoint = {x: e.pageX, y: e.pageY, type:'mouse'}; - } else if(e.changedTouches && e.changedTouches[0]) { - releasePoint = {x: e.changedTouches[0].pageX, y: e.changedTouches[0].pageY, type:'touch'}; - } + if (numPoints === 0 && !_direction && !_mainScrollAnimating) { + if (!releasePoint) { + if (e.type === 'mouseup') { + releasePoint = {x: e.pageX, y: e.pageY, type: 'mouse'}; + } else if (e.changedTouches && e.changedTouches[0]) { + releasePoint = {x: e.changedTouches[0].pageX, y: e.changedTouches[0].pageY, type: 'touch'}; + } } _shout('touchRelease', e, releasePoint); @@ -2071,68 +1929,64 @@ var _gestureStartTime, var releaseTimeDiff = -1; // Gesture completed, no pointers left - if(numPoints === 0) { + if (numPoints === 0) { _isDragging = false; framework.unbind(window, _upMoveEvents, self); _stopDragUpdateLoop(); - if(_isZooming) { + if (_isZooming) { // Two points released at the same time releaseTimeDiff = 0; - } else if(_lastReleaseTime !== -1) { + } else if (_lastReleaseTime !== -1) { releaseTimeDiff = _getCurrentTime() - _lastReleaseTime; } } _lastReleaseTime = numPoints === 1 ? _getCurrentTime() : -1; - - if(releaseTimeDiff !== -1 && releaseTimeDiff < 150) { + + if (releaseTimeDiff !== -1 && releaseTimeDiff < 150) { gestureType = 'zoom'; } else { gestureType = 'swipe'; } - if(_isZooming && numPoints < 2) { + if (_isZooming && numPoints < 2) { _isZooming = false; // Only second point released - if(numPoints === 1) { + if (numPoints === 1) { gestureType = 'zoomPointerUp'; } _shout('zoomGestureEnded'); } _currentPoints = null; - if(!_moved && !_zoomStarted && !_mainScrollAnimating && !_verticalDragInitiated) { + if (!_moved && !_zoomStarted && !_mainScrollAnimating && !_verticalDragInitiated) { // nothing to animate return; } - + _stopAllAnimations(); - - if(!_releaseAnimData) { + if (!_releaseAnimData) { _releaseAnimData = _initDragReleaseAnimationData(); } - - _releaseAnimData.calculateSwipeSpeed('x'); + _releaseAnimData.calculateSwipeSpeed('x'); - if(_verticalDragInitiated) { - + if (_verticalDragInitiated) { var opacityRatio = _calculateVerticalDragOpacityRatio(); - if(opacityRatio < _options.verticalDragRange) { + if (opacityRatio < _options.verticalDragRange) { self.close(); } else { var initalPanY = _panOffset.y, initialBgOpacity = _bgOpacity; - _animateProp('verticalDrag', 0, 1, 300, framework.easing.cubic.out, function(now) { - + _animateProp('verticalDrag', 0, 1, 300, framework.easing.cubic.out, function (now) { _panOffset.y = (self.currItem.initialPosition.y - initalPanY) * now + initalPanY; - _applyBgOpacity( (1 - initialBgOpacity) * now + initialBgOpacity ); + _applyBgOpacity((1 - initialBgOpacity) * now + initialBgOpacity); _applyCurrentZoomPan(); }); @@ -2142,171 +1996,158 @@ var _gestureStartTime, return; } - - // main scroll - if( (_mainScrollShifted || _mainScrollAnimating) && numPoints === 0) { + // main scroll + if ((_mainScrollShifted || _mainScrollAnimating) && numPoints === 0) { var itemChanged = _finishSwipeMainScrollGesture(gestureType, _releaseAnimData); - if(itemChanged) { + if (itemChanged) { return; } gestureType = 'zoomPointerUp'; } // prevent zoom/pan animation when main scroll animation runs - if(_mainScrollAnimating) { + if (_mainScrollAnimating) { return; } - - // Complete simple zoom gesture (reset zoom level if it's out of the bounds) - if(gestureType !== 'swipe') { + + // Complete simple zoom gesture (reset zoom level if it's out of the bounds) + if (gestureType !== 'swipe') { _completeZoomGesture(); return; } - + // Complete pan gesture if main scroll is not shifted, and it's possible to pan current image - if(!_mainScrollShifted && _currZoomLevel > self.currItem.fitRatio) { + if (!_mainScrollShifted && _currZoomLevel > self.currItem.fitRatio) { _completePanGesture(_releaseAnimData); } }, - - // Returns object with data about gesture // It's created only once and then reused - _initDragReleaseAnimationData = function() { + _initDragReleaseAnimationData = function () { // temp local vars - var lastFlickDuration, - tempReleasePos; + var lastFlickDuration, tempReleasePos; // s = this var s = { lastFlickOffset: {}, lastFlickDist: {}, lastFlickSpeed: {}, - slowDownRatio: {}, - slowDownRatioReverse: {}, - speedDecelerationRatio: {}, - speedDecelerationRatioAbs: {}, - distanceOffset: {}, + slowDownRatio: {}, + slowDownRatioReverse: {}, + speedDecelerationRatio: {}, + speedDecelerationRatioAbs: {}, + distanceOffset: {}, backAnimDestination: {}, backAnimStarted: {}, - calculateSwipeSpeed: function(axis) { - - - if( _posPoints.length > 1) { + calculateSwipeSpeed: function (axis) { + if (_posPoints.length > 1) { lastFlickDuration = _getCurrentTime() - _gestureCheckSpeedTime + 50; - tempReleasePos = _posPoints[_posPoints.length-2][axis]; + tempReleasePos = _posPoints[_posPoints.length - 2][axis]; } else { lastFlickDuration = _getCurrentTime() - _gestureStartTime; // total gesture duration tempReleasePos = _startPoint[axis]; } s.lastFlickOffset[axis] = _currPoint[axis] - tempReleasePos; s.lastFlickDist[axis] = Math.abs(s.lastFlickOffset[axis]); - if(s.lastFlickDist[axis] > 20) { + if (s.lastFlickDist[axis] > 20) { s.lastFlickSpeed[axis] = s.lastFlickOffset[axis] / lastFlickDuration; } else { s.lastFlickSpeed[axis] = 0; } - if( Math.abs(s.lastFlickSpeed[axis]) < 0.1 ) { + if (Math.abs(s.lastFlickSpeed[axis]) < 0.1) { s.lastFlickSpeed[axis] = 0; } - + s.slowDownRatio[axis] = 0.95; s.slowDownRatioReverse[axis] = 1 - s.slowDownRatio[axis]; s.speedDecelerationRatio[axis] = 1; }, - calculateOverBoundsAnimOffset: function(axis, speed) { - if(!s.backAnimStarted[axis]) { - - if(_panOffset[axis] > _currPanBounds.min[axis]) { + calculateOverBoundsAnimOffset: function (axis, speed) { + if (!s.backAnimStarted[axis]) { + if (_panOffset[axis] > _currPanBounds.min[axis]) { s.backAnimDestination[axis] = _currPanBounds.min[axis]; - - } else if(_panOffset[axis] < _currPanBounds.max[axis]) { + } else if (_panOffset[axis] < _currPanBounds.max[axis]) { s.backAnimDestination[axis] = _currPanBounds.max[axis]; } - if(s.backAnimDestination[axis] !== undefined) { + if (s.backAnimDestination[axis] !== undefined) { s.slowDownRatio[axis] = 0.7; s.slowDownRatioReverse[axis] = 1 - s.slowDownRatio[axis]; - if(s.speedDecelerationRatioAbs[axis] < 0.05) { - + if (s.speedDecelerationRatioAbs[axis] < 0.05) { s.lastFlickSpeed[axis] = 0; s.backAnimStarted[axis] = true; - _animateProp('bounceZoomPan'+axis,_panOffset[axis], - s.backAnimDestination[axis], - speed || 300, - framework.easing.sine.out, - function(pos) { + _animateProp( + 'bounceZoomPan' + axis, + _panOffset[axis], + s.backAnimDestination[axis], + speed || 300, + framework.easing.sine.out, + function (pos) { _panOffset[axis] = pos; _applyCurrentZoomPan(); } ); - } } } }, // Reduces the speed by slowDownRatio (per 10ms) - calculateAnimOffset: function(axis) { - if(!s.backAnimStarted[axis]) { - s.speedDecelerationRatio[axis] = s.speedDecelerationRatio[axis] * (s.slowDownRatio[axis] + - s.slowDownRatioReverse[axis] - - s.slowDownRatioReverse[axis] * s.timeDiff / 10); + calculateAnimOffset: function (axis) { + if (!s.backAnimStarted[axis]) { + s.speedDecelerationRatio[axis] = + s.speedDecelerationRatio[axis] * + (s.slowDownRatio[axis] + s.slowDownRatioReverse[axis] - (s.slowDownRatioReverse[axis] * s.timeDiff) / 10); s.speedDecelerationRatioAbs[axis] = Math.abs(s.lastFlickSpeed[axis] * s.speedDecelerationRatio[axis]); s.distanceOffset[axis] = s.lastFlickSpeed[axis] * s.speedDecelerationRatio[axis] * s.timeDiff; _panOffset[axis] += s.distanceOffset[axis]; - } }, - panAnimLoop: function() { - if ( _animations.zoomPan ) { + panAnimLoop: function () { + if (_animations.zoomPan) { _animations.zoomPan.raf = _requestAF(s.panAnimLoop); s.now = _getCurrentTime(); s.timeDiff = s.now - s.lastNow; s.lastNow = s.now; - + s.calculateAnimOffset('x'); s.calculateAnimOffset('y'); _applyCurrentZoomPan(); - + s.calculateOverBoundsAnimOffset('x'); s.calculateOverBoundsAnimOffset('y'); - if (s.speedDecelerationRatioAbs.x < 0.05 && s.speedDecelerationRatioAbs.y < 0.05) { - // round pan position _panOffset.x = Math.round(_panOffset.x); _panOffset.y = Math.round(_panOffset.y); _applyCurrentZoomPan(); - + _stopAnimation('zoomPan'); return; } } - } }; return s; }, - - _completePanGesture = function(animData) { + _completePanGesture = function (animData) { // calculate swipe speed for Y axis (paanning) animData.calculateSwipeSpeed('y'); _currPanBounds = self.currItem.bounds; - + animData.backAnimDestination = {}; animData.backAnimStarted = {}; // Avoid acceleration animation if speed is too low - if(Math.abs(animData.lastFlickSpeed.x) <= 0.05 && Math.abs(animData.lastFlickSpeed.y) <= 0.05 ) { + if (Math.abs(animData.lastFlickSpeed.x) <= 0.05 && Math.abs(animData.lastFlickSpeed.y) <= 0.05) { animData.speedDecelerationRatioAbs.x = animData.speedDecelerationRatioAbs.y = 0; // Run pan drag release animation. E.g. if you drag image and release finger without momentum. @@ -2320,30 +2161,24 @@ var _gestureStartTime, animData.lastNow = _getCurrentTime(); animData.panAnimLoop(); }, - - - _finishSwipeMainScrollGesture = function(gestureType, _releaseAnimData) { + _finishSwipeMainScrollGesture = function (gestureType, _releaseAnimData) { var itemChanged; - if(!_mainScrollAnimating) { + if (!_mainScrollAnimating) { _currZoomedItemIndex = _currentItemIndex; } - - var itemsDiff; - if(gestureType === 'swipe') { + if (gestureType === 'swipe') { var totalShiftDist = _currPoint.x - _startPoint.x, isFastLastFlick = _releaseAnimData.lastFlickDist.x < 10; - // if container is shifted for more than MIN_SWIPE_DISTANCE, + // if container is shifted for more than MIN_SWIPE_DISTANCE, // and last flick gesture was in right direction - if(totalShiftDist > MIN_SWIPE_DISTANCE && - (isFastLastFlick || _releaseAnimData.lastFlickOffset.x > 20) ) { + if (totalShiftDist > MIN_SWIPE_DISTANCE && (isFastLastFlick || _releaseAnimData.lastFlickOffset.x > 20)) { // go to prev item itemsDiff = -1; - } else if(totalShiftDist < -MIN_SWIPE_DISTANCE && - (isFastLastFlick || _releaseAnimData.lastFlickOffset.x < -20) ) { + } else if (totalShiftDist < -MIN_SWIPE_DISTANCE && (isFastLastFlick || _releaseAnimData.lastFlickOffset.x < -20)) { // go to next item itemsDiff = 1; } @@ -2351,88 +2186,85 @@ var _gestureStartTime, var nextCircle; - if(itemsDiff) { - + if (itemsDiff) { _currentItemIndex += itemsDiff; - if(_currentItemIndex < 0) { - _currentItemIndex = _options.loop ? _getNumItems()-1 : 0; + if (_currentItemIndex < 0) { + _currentItemIndex = _options.loop ? _getNumItems() - 1 : 0; nextCircle = true; - } else if(_currentItemIndex >= _getNumItems()) { - _currentItemIndex = _options.loop ? 0 : _getNumItems()-1; + } else if (_currentItemIndex >= _getNumItems()) { + _currentItemIndex = _options.loop ? 0 : _getNumItems() - 1; nextCircle = true; } - if(!nextCircle || _options.loop) { + if (!nextCircle || _options.loop) { _indexDiff += itemsDiff; _currPositionIndex -= itemsDiff; itemChanged = true; } - - - } var animateToX = _slideSize.x * _currPositionIndex; - var animateToDist = Math.abs( animateToX - _mainScrollPos.x ); + var animateToDist = Math.abs(animateToX - _mainScrollPos.x); var finishAnimDuration; - - if(!itemChanged && animateToX > _mainScrollPos.x !== _releaseAnimData.lastFlickSpeed.x > 0) { + if (!itemChanged && animateToX > _mainScrollPos.x !== _releaseAnimData.lastFlickSpeed.x > 0) { // "return to current" duration, e.g. when dragging from slide 0 to -1 - finishAnimDuration = 333; + finishAnimDuration = 333; } else { - finishAnimDuration = Math.abs(_releaseAnimData.lastFlickSpeed.x) > 0 ? - animateToDist / Math.abs(_releaseAnimData.lastFlickSpeed.x) : - 333; + finishAnimDuration = + Math.abs(_releaseAnimData.lastFlickSpeed.x) > 0 ? animateToDist / Math.abs(_releaseAnimData.lastFlickSpeed.x) : 333; finishAnimDuration = Math.min(finishAnimDuration, 400); finishAnimDuration = Math.max(finishAnimDuration, 250); } - if(_currZoomedItemIndex === _currentItemIndex) { + if (_currZoomedItemIndex === _currentItemIndex) { itemChanged = false; } - + _mainScrollAnimating = true; - + _shout('mainScrollAnimStart'); - _animateProp('mainScroll', _mainScrollPos.x, animateToX, finishAnimDuration, framework.easing.cubic.out, + _animateProp( + 'mainScroll', + _mainScrollPos.x, + animateToX, + finishAnimDuration, + framework.easing.cubic.out, _moveMainScroll, - function() { + function () { _stopAllAnimations(); _mainScrollAnimating = false; _currZoomedItemIndex = -1; - - if(itemChanged || _currZoomedItemIndex !== _currentItemIndex) { + + if (itemChanged || _currZoomedItemIndex !== _currentItemIndex) { self.updateCurrItem(); } - + _shout('mainScrollAnimComplete'); } ); - if(itemChanged) { + if (itemChanged) { self.updateCurrItem(true); } return itemChanged; }, - - _calculateZoomLevel = function(touchesDistance) { - return 1 / _startPointsDistance * touchesDistance * _startZoomLevel; + _calculateZoomLevel = function (touchesDistance) { + return (1 / _startPointsDistance) * touchesDistance * _startZoomLevel; }, - // Resets zoom if it's out of bounds - _completeZoomGesture = function() { + _completeZoomGesture = function () { var destZoomLevel = _currZoomLevel, minZoomLevel = _getMinZoomLevel(), maxZoomLevel = _getMaxZoomLevel(); - if ( _currZoomLevel < minZoomLevel ) { + if (_currZoomLevel < minZoomLevel) { destZoomLevel = minZoomLevel; - } else if ( _currZoomLevel > maxZoomLevel ) { + } else if (_currZoomLevel > maxZoomLevel) { destZoomLevel = maxZoomLevel; } @@ -2440,34 +2272,31 @@ var _gestureStartTime, onUpdate, initialOpacity = _bgOpacity; - if(_opacityChanged && !_isZoomingIn && !_wasOverInitialZoom && _currZoomLevel < minZoomLevel) { + if (_opacityChanged && !_isZoomingIn && !_wasOverInitialZoom && _currZoomLevel < minZoomLevel) { //_closedByScroll = true; self.close(); return true; } - if(_opacityChanged) { - onUpdate = function(now) { - _applyBgOpacity( (destOpacity - initialOpacity) * now + initialOpacity ); + if (_opacityChanged) { + onUpdate = function (now) { + _applyBgOpacity((destOpacity - initialOpacity) * now + initialOpacity); }; } - self.zoomTo(destZoomLevel, 0, 200, framework.easing.cubic.out, onUpdate); + self.zoomTo(destZoomLevel, 0, 200, framework.easing.cubic.out, onUpdate); return true; }; - _registerModule('Gestures', { publicMethods: { - - initGestures: function() { - + initGestures: function () { // helper function that builds touch/pointer/mouse events - var addEventNames = function(pref, down, move, up, cancel) { + var addEventNames = function (pref, down, move, up, cancel) { _dragStartEvent = pref + down; _dragMoveEvent = pref + move; _dragEndEvent = pref + up; - if(cancel) { + if (cancel) { _dragCancelEvent = pref + cancel; } else { _dragCancelEvent = ''; @@ -2475,44 +2304,44 @@ _registerModule('Gestures', { }; _pointerEventEnabled = _features.pointerEvent; - if(_pointerEventEnabled && _features.touch) { + if (_pointerEventEnabled && _features.touch) { // we don't need touch events, if browser supports pointer events _features.touch = false; } - if(_pointerEventEnabled) { - if(navigator.msPointerEnabled) { + if (_pointerEventEnabled) { + if (navigator.msPointerEnabled) { // IE10 pointer events are case-sensitive addEventNames('MSPointer', 'Down', 'Move', 'Up', 'Cancel'); } else { addEventNames('pointer', 'down', 'move', 'up', 'cancel'); } - } else if(_features.touch) { + } else if (_features.touch) { addEventNames('touch', 'start', 'move', 'end', 'cancel'); _likelyTouchDevice = true; } else { - addEventNames('mouse', 'down', 'move', 'up'); + addEventNames('mouse', 'down', 'move', 'up'); } - _upMoveEvents = _dragMoveEvent + ' ' + _dragEndEvent + ' ' + _dragCancelEvent; + _upMoveEvents = _dragMoveEvent + ' ' + _dragEndEvent + ' ' + _dragCancelEvent; _downEvents = _dragStartEvent; - if(_pointerEventEnabled && !_likelyTouchDevice) { - _likelyTouchDevice = (navigator.maxTouchPoints > 1) || (navigator.msMaxTouchPoints > 1); + if (_pointerEventEnabled && !_likelyTouchDevice) { + _likelyTouchDevice = navigator.maxTouchPoints > 1 || navigator.msMaxTouchPoints > 1; } // make variable public - self.likelyTouchDevice = _likelyTouchDevice; - + self.likelyTouchDevice = _likelyTouchDevice; + _globalEventHandlers[_dragStartEvent] = _onDragStart; _globalEventHandlers[_dragMoveEvent] = _onDragMove; _globalEventHandlers[_dragEndEvent] = _onDragRelease; // the Kraken - if(_dragCancelEvent) { + if (_dragCancelEvent) { _globalEventHandlers[_dragCancelEvent] = _globalEventHandlers[_dragEndEvent]; } // Bind mouse events on device with detected hardware touch support, in case it supports multiple types of input. - if(_features.touch) { + if (_features.touch) { _downEvents += ' mousedown'; _upMoveEvents += ' mousemove mouseup'; _globalEventHandlers.mousedown = _globalEventHandlers[_dragStartEvent]; @@ -2520,12 +2349,11 @@ _registerModule('Gestures', { _globalEventHandlers.mouseup = _globalEventHandlers[_dragEndEvent]; } - if(!_likelyTouchDevice) { + if (!_likelyTouchDevice) { // don't allow pan to next slide from zoomed state on Desktop _options.allowPanToNext = false; } } - } }); @@ -2541,24 +2369,22 @@ _registerModule('Gestures', { * If you're not planning to use transition for gallery at all, * you may set options hideAnimationDuration and showAnimationDuration to 0, * and just delete startAnimation function. - * + * */ - var _showOrHideTimeout, - _showOrHide = function(item, img, out, completeFn) { - - if(_showOrHideTimeout) { + _showOrHide = function (item, img, out, completeFn) { + if (_showOrHideTimeout) { clearTimeout(_showOrHideTimeout); } _initialZoomRunning = true; _initialContentSet = true; - + // dimensions of small thumbnail {x:,y:,w:}. // Height is optional, as calculated based on large image. - var thumbBounds; - if(item.initialLayout) { + var thumbBounds; + if (item.initialLayout) { thumbBounds = item.initialLayout; item.initialLayout = null; } else { @@ -2567,11 +2393,11 @@ var _showOrHideTimeout, var duration = out ? _options.hideAnimationDuration : _options.showAnimationDuration; - var onComplete = function() { + var onComplete = function () { _stopAnimation('initialZoom'); - if(!out) { + if (!out) { _applyBgOpacity(1); - if(img) { + if (img) { img.style.display = 'block'; } framework.addClass(template, 'pswp--animated-in'); @@ -2581,26 +2407,25 @@ var _showOrHideTimeout, } _shout('initialZoom' + (out ? 'OutEnd' : 'InEnd')); - if(completeFn) { + if (completeFn) { completeFn(); } _initialZoomRunning = false; }; // if bounds aren't provided, just open gallery without animation - if(!duration || !thumbBounds || thumbBounds.x === undefined) { - - _shout('initialZoom' + (out ? 'Out' : 'In') ); + if (!duration || !thumbBounds || thumbBounds.x === undefined) { + _shout('initialZoom' + (out ? 'Out' : 'In')); _currZoomLevel = item.initialZoomLevel; - _equalizePoints(_panOffset, item.initialPosition ); + _equalizePoints(_panOffset, item.initialPosition); _applyCurrentZoomPan(); template.style.opacity = out ? 0 : 1; _applyBgOpacity(1); - if(duration) { - setTimeout(function() { + if (duration) { + setTimeout(function () { onComplete(); }, duration); } else { @@ -2610,16 +2435,16 @@ var _showOrHideTimeout, return; } - var startAnimation = function() { + var startAnimation = function () { var closeWithRaf = _closedByScroll, fadeEverything = !self.currItem.src || self.currItem.loadError || _options.showHideOpacity; - + // apply hw-acceleration to image - if(item.miniImg) { + if (item.miniImg) { item.miniImg.style.webkitBackfaceVisibility = 'hidden'; } - if(!out) { + if (!out) { _currZoomLevel = thumbBounds.w / item.w; _panOffset.x = thumbBounds.x; _panOffset.y = thumbBounds.y - _initalWindowScrollY; @@ -2629,100 +2454,96 @@ var _showOrHideTimeout, } _registerStartAnimation('initialZoom'); - - if(out && !closeWithRaf) { + + if (out && !closeWithRaf) { framework.removeClass(template, 'pswp--animated-in'); } - if(fadeEverything) { - if(out) { - framework[ (closeWithRaf ? 'remove' : 'add') + 'Class' ](template, 'pswp--animate_opacity'); + if (fadeEverything) { + if (out) { + framework[(closeWithRaf ? 'remove' : 'add') + 'Class'](template, 'pswp--animate_opacity'); } else { - setTimeout(function() { + setTimeout(function () { framework.addClass(template, 'pswp--animate_opacity'); }, 30); } } - _showOrHideTimeout = setTimeout(function() { + _showOrHideTimeout = setTimeout( + function () { + _shout('initialZoom' + (out ? 'Out' : 'In')); - _shout('initialZoom' + (out ? 'Out' : 'In') ); - + if (!out) { + // "in" animation always uses CSS transitions (instead of rAF). + // CSS transition work faster here, + // as developer may also want to animate other things, + // like ui on top of sliding area, which can be animated just via CSS - if(!out) { + _currZoomLevel = item.initialZoomLevel; + _equalizePoints(_panOffset, item.initialPosition); + _applyCurrentZoomPan(); + _applyBgOpacity(1); - // "in" animation always uses CSS transitions (instead of rAF). - // CSS transition work faster here, - // as developer may also want to animate other things, - // like ui on top of sliding area, which can be animated just via CSS - - _currZoomLevel = item.initialZoomLevel; - _equalizePoints(_panOffset, item.initialPosition ); - _applyCurrentZoomPan(); - _applyBgOpacity(1); + if (fadeEverything) { + template.style.opacity = 1; + } else { + _applyBgOpacity(1); + } - if(fadeEverything) { - template.style.opacity = 1; + _showOrHideTimeout = setTimeout(onComplete, duration + 20); } else { - _applyBgOpacity(1); - } - - _showOrHideTimeout = setTimeout(onComplete, duration + 20); - } else { + // "out" animation uses rAF only when PhotoSwipe is closed by browser scroll, to recalculate position + var destZoomLevel = thumbBounds.w / item.w, + initialPanOffset = { + x: _panOffset.x, + y: _panOffset.y + }, + initialZoomLevel = _currZoomLevel, + initalBgOpacity = _bgOpacity, + onUpdate = function (now) { + if (now === 1) { + _currZoomLevel = destZoomLevel; + _panOffset.x = thumbBounds.x; + _panOffset.y = thumbBounds.y - _currentWindowScrollY; + } else { + _currZoomLevel = (destZoomLevel - initialZoomLevel) * now + initialZoomLevel; + _panOffset.x = (thumbBounds.x - initialPanOffset.x) * now + initialPanOffset.x; + _panOffset.y = (thumbBounds.y - _currentWindowScrollY - initialPanOffset.y) * now + initialPanOffset.y; + } - // "out" animation uses rAF only when PhotoSwipe is closed by browser scroll, to recalculate position - var destZoomLevel = thumbBounds.w / item.w, - initialPanOffset = { - x: _panOffset.x, - y: _panOffset.y - }, - initialZoomLevel = _currZoomLevel, - initalBgOpacity = _bgOpacity, - onUpdate = function(now) { - - if(now === 1) { - _currZoomLevel = destZoomLevel; - _panOffset.x = thumbBounds.x; - _panOffset.y = thumbBounds.y - _currentWindowScrollY; - } else { - _currZoomLevel = (destZoomLevel - initialZoomLevel) * now + initialZoomLevel; - _panOffset.x = (thumbBounds.x - initialPanOffset.x) * now + initialPanOffset.x; - _panOffset.y = (thumbBounds.y - _currentWindowScrollY - initialPanOffset.y) * now + initialPanOffset.y; - } - - _applyCurrentZoomPan(); - if(fadeEverything) { - template.style.opacity = 1 - now; - } else { - _applyBgOpacity( initalBgOpacity - now * initalBgOpacity ); - } - }; + _applyCurrentZoomPan(); + if (fadeEverything) { + template.style.opacity = 1 - now; + } else { + _applyBgOpacity(initalBgOpacity - now * initalBgOpacity); + } + }; - if(closeWithRaf) { - _animateProp('initialZoom', 0, 1, duration, framework.easing.cubic.out, onUpdate, onComplete); - } else { - onUpdate(1); - _showOrHideTimeout = setTimeout(onComplete, duration + 20); + if (closeWithRaf) { + _animateProp('initialZoom', 0, 1, duration, framework.easing.cubic.out, onUpdate, onComplete); + } else { + onUpdate(1); + _showOrHideTimeout = setTimeout(onComplete, duration + 20); + } } - } - - }, out ? 25 : 90); // Main purpose of this delay is to give browser time to paint and - // create composite layers of PhotoSwipe UI parts (background, controls, caption, arrows). - // Which avoids lag at the beginning of scale transition. + }, + out ? 25 : 90 + ); // Main purpose of this delay is to give browser time to paint and + // create composite layers of PhotoSwipe UI parts (background, controls, caption, arrows). + // Which avoids lag at the beginning of scale transition. }; startAnimation(); - - }; + /*>>show-hide-transition*/ /*>>items-controller*/ /** -* -* Controller manages gallery items, their dimensions, and their content. -* -*/ + * + * Controller manages gallery items, their dimensions, and their content. + * + */ var _items, _tempPanAreaSize = {}, @@ -2733,24 +2554,23 @@ var _items, index: 0, errorMsg: '
The image could not be loaded.
', forceProgressiveLoading: false, // TODO - preload: [1,1], - getNumItemsFn: function() { + preload: [1, 1], + getNumItemsFn: function () { return _items.length; } }; - var _getItemAt, _getNumItems, _initialIsLoop, - _getZeroBounds = function() { + _getZeroBounds = function () { return { - center:{x:0,y:0}, - max:{x:0,y:0}, - min:{x:0,y:0} + center: {x: 0, y: 0}, + max: {x: 0, y: 0}, + min: {x: 0, y: 0} }; }, - _calculateSingleItemPanBounds = function(item, realPanElementW, realPanElementH ) { + _calculateSingleItemPanBounds = function (item, realPanElementW, realPanElementH) { var bounds = item.bounds; // position of element when it's centered @@ -2758,32 +2578,27 @@ var _getItemAt, bounds.center.y = Math.round((_tempPanAreaSize.y - realPanElementH) / 2) + item.vGap.top; // maximum pan position - bounds.max.x = (realPanElementW > _tempPanAreaSize.x) ? - Math.round(_tempPanAreaSize.x - realPanElementW) : - bounds.center.x; - - bounds.max.y = (realPanElementH > _tempPanAreaSize.y) ? - Math.round(_tempPanAreaSize.y - realPanElementH) + item.vGap.top : - bounds.center.y; - + bounds.max.x = realPanElementW > _tempPanAreaSize.x ? Math.round(_tempPanAreaSize.x - realPanElementW) : bounds.center.x; + + bounds.max.y = + realPanElementH > _tempPanAreaSize.y ? Math.round(_tempPanAreaSize.y - realPanElementH) + item.vGap.top : bounds.center.y; + // minimum pan position - bounds.min.x = (realPanElementW > _tempPanAreaSize.x) ? 0 : bounds.center.x; - bounds.min.y = (realPanElementH > _tempPanAreaSize.y) ? item.vGap.top : bounds.center.y; + bounds.min.x = realPanElementW > _tempPanAreaSize.x ? 0 : bounds.center.x; + bounds.min.y = realPanElementH > _tempPanAreaSize.y ? item.vGap.top : bounds.center.y; }, - _calculateItemSize = function(item, viewportSize, zoomLevel) { - + _calculateItemSize = function (item, viewportSize, zoomLevel) { if (item.src && !item.loadError) { var isInitial = !zoomLevel; - - if(isInitial) { - if(!item.vGap) { - item.vGap = {top:0,bottom:0}; + + if (isInitial) { + if (!item.vGap) { + item.vGap = {top: 0, bottom: 0}; } // allows overriding vertical margin for individual items _shout('parseVerticalMargin', item); } - _tempPanAreaSize.x = viewportSize.x; _tempPanAreaSize.y = viewportSize.y - item.vGap.top - item.vGap.bottom; @@ -2807,14 +2622,14 @@ var _getItemAt, } item.initialZoomLevel = zoomLevel; - - if(!item.bounds) { + + if (!item.bounds) { // reuse bounds object - item.bounds = _getZeroBounds(); + item.bounds = _getZeroBounds(); } } - if(!zoomLevel) { + if (!zoomLevel) { return; } @@ -2834,29 +2649,21 @@ var _getItemAt, // if it's not image, we return zero bounds (content is not zoomable) return item.bounds; } - }, - - - - - _appendImage = function(index, item, baseDiv, img, preventAnimation, keepPlaceholder) { - - - if(item.loadError) { + _appendImage = function (index, item, baseDiv, img, preventAnimation, keepPlaceholder) { + if (item.loadError) { return; } - if(img) { - + if (img) { item.imageAppended = true; - _setImageSize(item, img, (item === self.currItem && _renderMaxResolution) ); - + _setImageSize(item, img, item === self.currItem && _renderMaxResolution); + baseDiv.appendChild(img); - if(keepPlaceholder) { - setTimeout(function() { - if(item && item.loaded && item.placeholder) { + if (keepPlaceholder) { + setTimeout(function () { + if (item && item.loaded && item.placeholder) { item.placeholder.style.display = 'none'; item.placeholder = null; } @@ -2864,26 +2671,23 @@ var _getItemAt, } } }, - - - - _preloadImage = function(item) { + _preloadImage = function (item) { item.loading = true; item.loaded = false; - var img = item.img = framework.createEl('pswp__img', 'img'); - var onComplete = function() { + var img = (item.img = framework.createEl('pswp__img', 'img')); + var onComplete = function () { item.loading = false; item.loaded = true; - + // set natural image size - if(item.autoSize) { + if (item.autoSize) { item.w = img.naturalWidth; item.h = img.naturalHeight; item.autoSize = false; self.updateSize(); } - if(item.loadComplete) { + if (item.loadComplete) { item.loadComplete(item); } else { item.img = null; // no need to store image object @@ -2892,43 +2696,41 @@ var _getItemAt, img = null; }; img.onload = onComplete; - img.onerror = function() { + img.onerror = function () { item.loadError = true; onComplete(); - }; + }; - img.src = item.src;// + '?a=' + Math.random(); + img.src = item.src; // + '?a=' + Math.random(); return img; }, - _checkForError = function(item, cleanUp) { - if(item.src && item.loadError && item.container) { - - if(cleanUp) { + _checkForError = function (item, cleanUp) { + if (item.src && item.loadError && item.container) { + if (cleanUp) { item.container.innerHTML = ''; } - item.container.innerHTML = _options.errorMsg.replace('%url%', item.src ); + item.container.innerHTML = _options.errorMsg.replace('%url%', item.src); return true; - } }, - _setImageSize = function(item, img, maxRes) { - if(!item.src) { + _setImageSize = function (item, img, maxRes) { + if (!item.src) { return; } - if(!img) { + if (!img) { img = item.container.lastChild; } var w = maxRes ? item.w : Math.round(item.w * item.fitRatio), h = maxRes ? item.h : Math.round(item.h * item.fitRatio); - + // ensure correct aspect ratio - if(img.naturalHeight && img.naturalWidth) { + if (img.naturalHeight && img.naturalWidth) { var newHeight = w * (img.naturalHeight / img.naturalWidth); - if(newHeight > h) { + if (newHeight > h) { var newWidth = h * (img.naturalWidth / img.naturalHeight); img.style.marginLeft = (w - newWidth) / 2 + 'px'; w = newWidth; @@ -2937,8 +2739,8 @@ var _getItemAt, h = newHeight; } } - - if(item.placeholder && !item.loaded) { + + if (item.placeholder && !item.loaded) { item.placeholder.style.width = w + 'px'; item.placeholder.style.height = h + 'px'; } @@ -2946,32 +2748,27 @@ var _getItemAt, img.style.width = w + 'px'; img.style.height = h + 'px'; }, - _appendImagesPool = function() { - - if(_imagesToAppendPool.length) { + _appendImagesPool = function () { + if (_imagesToAppendPool.length) { var poolItem; - for(var i = 0; i < _imagesToAppendPool.length; i++) { + for (var i = 0; i < _imagesToAppendPool.length; i++) { poolItem = _imagesToAppendPool[i]; - if( poolItem.holder.index === poolItem.index ) { + if (poolItem.holder.index === poolItem.index) { _appendImage(poolItem.index, poolItem.item, poolItem.baseDiv, poolItem.img, false, poolItem.clearPlaceholder); } } _imagesToAppendPool = []; } }; - - _registerModule('Controller', { - publicMethods: { - - lazyLoadItem: function(index) { + lazyLoadItem: function (index) { index = _getLoopedId(index); var item = _getItemAt(index); - if(!item || ((item.loaded || item.loading) && !_itemsNeedUpdate)) { + if (!item || ((item.loaded || item.loading) && !_itemsNeedUpdate)) { return; } @@ -2983,63 +2780,57 @@ _registerModule('Controller', { _preloadImage(item); }, - initController: function() { + initController: function () { framework.extend(_options, _controllerDefaultOptions, true); self.items = _items = items; _getItemAt = self.getItemAt; _getNumItems = _options.getNumItemsFn; //self.getNumItems; - - _initialIsLoop = _options.loop; - if(_getNumItems() < 3) { + if (_getNumItems() < 3) { _options.loop = false; // disable loop if less then 3 items } - _listen('beforeChange', function(diff) { - + _listen('beforeChange', function (diff) { var p = _options.preload, - isNext = diff === null ? true : (diff >= 0), - preloadBefore = Math.min(p[0], _getNumItems() ), - preloadAfter = Math.min(p[1], _getNumItems() ), + isNext = diff === null ? true : diff >= 0, + preloadBefore = Math.min(p[0], _getNumItems()), + preloadAfter = Math.min(p[1], _getNumItems()), i; - - for(i = 1; i <= (isNext ? preloadAfter : preloadBefore); i++) { - self.lazyLoadItem(_currentItemIndex+i); + for (i = 1; i <= (isNext ? preloadAfter : preloadBefore); i++) { + self.lazyLoadItem(_currentItemIndex + i); } - for(i = 1; i <= (isNext ? preloadBefore : preloadAfter); i++) { - self.lazyLoadItem(_currentItemIndex-i); + for (i = 1; i <= (isNext ? preloadBefore : preloadAfter); i++) { + self.lazyLoadItem(_currentItemIndex - i); } }); - _listen('initialLayout', function() { + _listen('initialLayout', function () { self.currItem.initialLayout = _options.getThumbBoundsFn && _options.getThumbBoundsFn(_currentItemIndex); }); _listen('mainScrollAnimComplete', _appendImagesPool); _listen('initialZoomInEnd', _appendImagesPool); - - - _listen('destroy', function() { + _listen('destroy', function () { var item; - for(var i = 0; i < _items.length; i++) { + for (var i = 0; i < _items.length; i++) { item = _items[i]; // remove reference to DOM elements, for GC - if(item.container) { - item.container = null; + if (item.container) { + item.container = null; } - if(item.placeholder) { + if (item.placeholder) { item.placeholder = null; } - if(item.img) { + if (item.img) { item.img = null; } - if(item.preloader) { + if (item.preloader) { item.preloader = null; } - if(item.loadError) { + if (item.loadError) { item.loaded = item.loadError = false; } } @@ -3047,49 +2838,51 @@ _registerModule('Controller', { }); }, - - getItemAt: function(index) { + getItemAt: function (index) { if (index >= 0) { var item = _items[index] !== undefined ? _items[index] : false; - if(item && item.autoSize) { - if(item.w == null) item.w = 0; - if(item.h == null) item.h = 0; + if (item && item.autoSize) { + if (item.w == null) { + item.w = 0; + } + if (item.h == null) { + item.h = 0; + } } return item; } return false; }, - allowProgressiveImg: function() { - // 1. Progressive image loading isn't working on webkit/blink + allowProgressiveImg: function () { + // 1. Progressive image loading isn't working on webkit/blink // when hw-acceleration (e.g. translateZ) is applied to IMG element. // That's why in PhotoSwipe parent element gets zoom transform, not image itself. - // + // // 2. Progressive image loading sometimes blinks in webkit/blink when applying animation to parent element. // That's why it's disabled on touch devices (mainly because of swipe transition) - // + // // 3. Progressive image loading sometimes doesn't work in IE (up to 11). // Don't allow progressive loading on non-large touch devices - return _options.forceProgressiveLoading || !_likelyTouchDevice || _options.mouseUsed || screen.width > 1200; + return _options.forceProgressiveLoading || !_likelyTouchDevice || _options.mouseUsed || screen.width > 1200; // 1200 - to eliminate touch devices with large screen (like Chromebook Pixel) }, - setContent: function(holder, index) { - - if(_options.loop) { + setContent: function (holder, index) { + if (_options.loop) { index = _getLoopedId(index); } var prevItem = self.getItemAt(holder.index); - if(prevItem) { + if (prevItem) { prevItem.container = null; } - + var item = self.getItemAt(index), img; - - if(!item) { + + if (!item) { holder.el.innerHTML = ''; return; } @@ -3101,12 +2894,10 @@ _registerModule('Controller', { holder.item = item; // base container DIV is created only once for each of 3 holders - var baseDiv = item.container = framework.createEl('pswp__zoom-wrap'); + var baseDiv = (item.container = framework.createEl('pswp__zoom-wrap')); - - - if(!item.src && item.html) { - if(item.html.tagName) { + if (!item.src && item.html) { + if (item.html.tagName) { baseDiv.appendChild(item.html); } else { baseDiv.innerHTML = item.html; @@ -3116,45 +2907,43 @@ _registerModule('Controller', { _checkForError(item); _calculateItemSize(item, _viewportSize); - - if(item.src && !item.loadError && !item.loaded) { - - item.loadComplete = function(item) { + if (item.src && !item.loadError && !item.loaded) { + item.loadComplete = function (item) { // gallery closed before image finished loading - if(!_isOpen) { + if (!_isOpen) { return; } // check if holder hasn't changed while image was loading - if(holder && holder.index === index ) { - if( _checkForError(item, true) ) { + if (holder && holder.index === index) { + if (_checkForError(item, true)) { item.loadComplete = item.img = null; _calculateItemSize(item, _viewportSize); _applyZoomPanToItem(item); - if(holder.index === _currentItemIndex) { + if (holder.index === _currentItemIndex) { // recalculate dimensions self.updateCurrZoomItem(); } return; } - if( !item.imageAppended ) { - if(_features.transform && (_mainScrollAnimating || _initialZoomRunning) ) { + if (!item.imageAppended) { + if (_features.transform && (_mainScrollAnimating || _initialZoomRunning)) { _imagesToAppendPool.push({ - item:item, - baseDiv:baseDiv, - img:item.img, - index:index, - holder:holder, - clearPlaceholder:true + item: item, + baseDiv: baseDiv, + img: item.img, + index: index, + holder: holder, + clearPlaceholder: true }); } else { _appendImage(index, item, baseDiv, item.img, _mainScrollAnimating || _initialZoomRunning, true); } } else { // remove preloader & mini-img - if(!_initialZoomRunning && item.placeholder) { + if (!_initialZoomRunning && item.placeholder) { item.placeholder.style.display = 'none'; item.placeholder = null; } @@ -3167,47 +2956,40 @@ _registerModule('Controller', { _shout('imageLoadComplete', index, item); }; - if(framework.features.transform) { - - var placeholderClassName = 'pswp__img pswp__img--placeholder'; - placeholderClassName += (item.msrc ? '' : ' pswp__img--placeholder--blank'); + if (framework.features.transform) { + var placeholderClassName = 'pswp__img pswp__img--placeholder'; + placeholderClassName += item.msrc ? '' : ' pswp__img--placeholder--blank'; var placeholder = framework.createEl(placeholderClassName, item.msrc ? 'img' : ''); - if(item.msrc) { + if (item.msrc) { placeholder.src = item.msrc; } - + _setImageSize(item, placeholder); baseDiv.appendChild(placeholder); item.placeholder = placeholder; - } - - - - if(!item.loading) { + if (!item.loading) { _preloadImage(item); } - - if( self.allowProgressiveImg() ) { + if (self.allowProgressiveImg()) { // just append image - if(!_initialContentSet && _features.transform) { + if (!_initialContentSet && _features.transform) { _imagesToAppendPool.push({ - item:item, - baseDiv:baseDiv, - img:item.img, - index:index, - holder:holder + item: item, + baseDiv: baseDiv, + img: item.img, + index: index, + holder: holder }); } else { _appendImage(index, item, baseDiv, item.img, true, true); } } - - } else if(item.src && !item.loadError) { + } else if (item.src && !item.loadError) { // image object is created every time, due to bugs of image loading & delay when switching images img = framework.createEl('pswp__img', 'img'); img.style.opacity = 1; @@ -3215,11 +2997,10 @@ _registerModule('Controller', { _setImageSize(item, img); _appendImage(index, item, baseDiv, img, true); } - - if(!_initialContentSet && index === _currentItemIndex) { + if (!_initialContentSet && index === _currentItemIndex) { _currZoomElementStyle = baseDiv.style; - _showOrHide(item, (img ||item.img) ); + _showOrHide(item, img || item.img); } else { _applyZoomPanToItem(item); } @@ -3228,13 +3009,12 @@ _registerModule('Controller', { holder.el.appendChild(baseDiv); }, - cleanSlide: function( item ) { - if(item.img ) { + cleanSlide: function (item) { + if (item.img) { item.img.onload = item.img.onerror = null; } item.loaded = item.loading = item.img = item.imageAppended = false; } - } }); @@ -3246,13 +3026,13 @@ _registerModule('Controller', { * tap.js: * * Displatches tap and double-tap events. - * + * */ var tapTimer, tapReleasePoint = {}, - _dispatchTapEvent = function(origEvent, releasePoint, pointerType) { - var e = document.createEvent( 'CustomEvent' ), + _dispatchTapEvent = function (origEvent, releasePoint, pointerType) { + var e = document.createEvent('CustomEvent'), eDetail = { origEvent: origEvent, pointerType: pointerType || 'touch', @@ -3261,59 +3041,59 @@ var tapTimer, rightClick: pointerType === 'mouse' && origEvent.which === 3 }; - e.initCustomEvent( 'pswpTap', true, true, eDetail ); + e.initCustomEvent('pswpTap', true, true, eDetail); origEvent.target.dispatchEvent(e); }; _registerModule('Tap', { publicMethods: { - initTap: function() { + initTap: function () { _listen('firstTouchStart', self.onTapStart); _listen('touchRelease', self.onTapRelease); - _listen('destroy', function() { + _listen('destroy', function () { tapReleasePoint = {}; tapTimer = null; }); }, - onTapStart: function(touchList) { - if(touchList.length > 1) { + onTapStart: function (touchList) { + if (touchList.length > 1) { clearTimeout(tapTimer); tapTimer = null; } }, - onTapRelease: function(e, releasePoint) { - if(!releasePoint) { + onTapRelease: function (e, releasePoint) { + if (!releasePoint) { return; } - if(!_moved && !_isMultitouch && !_numAnimations) { + if (!_moved && !_isMultitouch && !_numAnimations) { var p0 = releasePoint; - if(tapTimer) { + if (tapTimer) { clearTimeout(tapTimer); tapTimer = null; // Check if taped on the same place - if ( _isNearbyPoints(p0, tapReleasePoint) ) { + if (_isNearbyPoints(p0, tapReleasePoint)) { _shout('doubleTap', p0); return; } } - if(releasePoint.type === 'mouse') { + if (releasePoint.type === 'mouse') { _dispatchTapEvent(e, releasePoint, 'mouse'); return; } var clickedTagName = e.target.tagName.toUpperCase(); // avoid double tap delay on buttons and elements that have class pswp__single-tap - if(clickedTagName === 'BUTTON' || framework.hasClass(e.target, 'pswp__single-tap') ) { + if (clickedTagName === 'BUTTON' || framework.hasClass(e.target, 'pswp__single-tap')) { _dispatchTapEvent(e, releasePoint); return; } _equalizePoints(tapReleasePoint, p0); - tapTimer = setTimeout(function() { + tapTimer = setTimeout(function () { _dispatchTapEvent(e, releasePoint); tapTimer = null; }, 300); @@ -3322,6 +3102,7 @@ _registerModule('Tap', { } }); + /*>>tap*/ /*>>desktop-zoom*/ @@ -3333,46 +3114,41 @@ _registerModule('Tap', { * - Manages "dragging", "zoomed-in", "zoom-out" classes. * (which are used for cursors and zoom icon) * - Adds toggleDesktopZoom function. - * + * */ var _wheelDelta; - -_registerModule('DesktopZoom', { +_registerModule('DesktopZoom', { publicMethods: { - - initDesktopZoom: function() { - - if(_oldIE) { + initDesktopZoom: function () { + if (_oldIE) { // no zoom for old IE (<=8) return; } - if(_likelyTouchDevice) { + if (_likelyTouchDevice) { // if detected hardware touch support, we wait until mouse is used, // and only then apply desktop-zoom features - _listen('mouseUsed', function() { + _listen('mouseUsed', function () { self.setupDesktopZoom(); }); } else { self.setupDesktopZoom(true); } - }, - setupDesktopZoom: function(onInit) { - + setupDesktopZoom: function (onInit) { _wheelDelta = {}; var events = 'wheel mousewheel DOMMouseScroll'; - - _listen('bindEvents', function() { - framework.bind(template, events, self.handleMouseWheel); + + _listen('bindEvents', function () { + framework.bind(template, events, self.handleMouseWheel); }); - _listen('unbindEvents', function() { - if(_wheelDelta) { + _listen('unbindEvents', function () { + if (_wheelDelta) { framework.unbind(template, events, self.handleMouseWheel); } }); @@ -3380,55 +3156,51 @@ _registerModule('DesktopZoom', { self.mouseZoomedIn = false; var hasDraggingClass, - updateZoomable = function() { - if(self.mouseZoomedIn) { + updateZoomable = function () { + if (self.mouseZoomedIn) { framework.removeClass(template, 'pswp--zoomed-in'); self.mouseZoomedIn = false; } - if(_currZoomLevel < 1) { + if (_currZoomLevel < 1) { framework.addClass(template, 'pswp--zoom-allowed'); } else { framework.removeClass(template, 'pswp--zoom-allowed'); } removeDraggingClass(); }, - removeDraggingClass = function() { - if(hasDraggingClass) { + removeDraggingClass = function () { + if (hasDraggingClass) { framework.removeClass(template, 'pswp--dragging'); hasDraggingClass = false; } }; - _listen('resize' , updateZoomable); - _listen('afterChange' , updateZoomable); - _listen('pointerDown', function() { - if(self.mouseZoomedIn) { + _listen('resize', updateZoomable); + _listen('afterChange', updateZoomable); + _listen('pointerDown', function () { + if (self.mouseZoomedIn) { hasDraggingClass = true; framework.addClass(template, 'pswp--dragging'); } }); _listen('pointerUp', removeDraggingClass); - if(!onInit) { + if (!onInit) { updateZoomable(); } - }, - handleMouseWheel: function(e) { - - if(_currZoomLevel <= self.currItem.fitRatio) { - if( _options.modal ) { - + handleMouseWheel: function (e) { + if (_currZoomLevel <= self.currItem.fitRatio) { + if (_options.modal) { if (!_options.closeOnScroll || _numAnimations || _isDragging) { e.preventDefault(); - } else if(_transformKey && Math.abs(e.deltaY) > 2) { + } else if (_transformKey && Math.abs(e.deltaY) > 2) { // close PhotoSwipe // if browser supports transforms & scroll changed enough _closedByScroll = true; self.close(); } - } return true; } @@ -3439,8 +3211,8 @@ _registerModule('DesktopZoom', { // https://developer.mozilla.org/en-US/docs/Web/Events/wheel _wheelDelta.x = 0; - if('deltaX' in e) { - if(e.deltaMode === 1 /* DOM_DELTA_LINE */) { + if ('deltaX' in e) { + if (e.deltaMode === 1 /* DOM_DELTA_LINE */) { // 18 - average line height _wheelDelta.x = e.deltaX * 18; _wheelDelta.y = e.deltaY * 18; @@ -3448,16 +3220,16 @@ _registerModule('DesktopZoom', { _wheelDelta.x = e.deltaX; _wheelDelta.y = e.deltaY; } - } else if('wheelDelta' in e) { - if(e.wheelDeltaX) { + } else if ('wheelDelta' in e) { + if (e.wheelDeltaX) { _wheelDelta.x = -0.16 * e.wheelDeltaX; } - if(e.wheelDeltaY) { + if (e.wheelDeltaY) { _wheelDelta.y = -0.16 * e.wheelDeltaY; } else { _wheelDelta.y = -0.16 * e.wheelDelta; } - } else if('detail' in e) { + } else if ('detail' in e) { _wheelDelta.y = e.detail; } else { return; @@ -3469,11 +3241,13 @@ _registerModule('DesktopZoom', { newPanY = _panOffset.y - _wheelDelta.y; // only prevent scrolling in nonmodal mode when not at edges - if (_options.modal || - ( - newPanX <= _currPanBounds.min.x && newPanX >= _currPanBounds.max.x && - newPanY <= _currPanBounds.min.y && newPanY >= _currPanBounds.max.y - ) ) { + if ( + _options.modal || + (newPanX <= _currPanBounds.min.x && + newPanX >= _currPanBounds.max.x && + newPanY <= _currPanBounds.min.y && + newPanY >= _currPanBounds.max.y) + ) { e.preventDefault(); } @@ -3481,18 +3255,17 @@ _registerModule('DesktopZoom', { self.panTo(newPanX, newPanY); }, - toggleDesktopZoom: function(centerPoint) { - centerPoint = centerPoint || {x:_viewportSize.x/2 + _offset.x, y:_viewportSize.y/2 + _offset.y }; + toggleDesktopZoom: function (centerPoint) { + centerPoint = centerPoint || {x: _viewportSize.x / 2 + _offset.x, y: _viewportSize.y / 2 + _offset.y}; var doubleTapZoomLevel = _options.getDoubleTapZoom(true, self.currItem); var zoomOut = _currZoomLevel === doubleTapZoomLevel; - + self.mouseZoomedIn = !zoomOut; self.zoomTo(zoomOut ? self.currItem.initialZoomLevel : doubleTapZoomLevel, centerPoint, 333); - framework[ (!zoomOut ? 'add' : 'remove') + 'Class'](template, 'pswp--zoomed-in'); + framework[(!zoomOut ? 'add' : 'remove') + 'Class'](template, 'pswp--zoomed-in'); } - } }); @@ -3505,15 +3278,14 @@ _registerModule('DesktopZoom', { * history.js: * * - Back button to close gallery. - * + * * - Unique URL for each slide: example.com/&pid=1&gid=3 * (where PID is picture index, and GID and gallery index) - * + * * - Switch URL when slides change. - * + * */ - var _historyDefaultOptions = { history: true, galleryUID: 1 @@ -3530,257 +3302,220 @@ var _historyUpdateTimeout, _closedFromURL, _urlChangedOnce, _windowLoc, - _supportsPushState, - - _getHash = function() { + _getHash = function () { return _windowLoc.hash.substring(1); }, - _cleanHistoryTimeouts = function() { - - if(_historyUpdateTimeout) { + _cleanHistoryTimeouts = function () { + if (_historyUpdateTimeout) { clearTimeout(_historyUpdateTimeout); } - if(_hashAnimCheckTimeout) { + if (_hashAnimCheckTimeout) { clearTimeout(_hashAnimCheckTimeout); } }, - // pid - Picture index // gid - Gallery index - _parseItemIndexFromURL = function() { + _parseItemIndexFromURL = function () { var hash = _getHash(), params = {}; - if(hash.length < 5) { // pid=1 + if (hash.length < 5) { + // pid=1 return params; } - var i, vars = hash.split('&'); + var i, + vars = hash.split('&'); for (i = 0; i < vars.length; i++) { - if(!vars[i]) { + if (!vars[i]) { continue; } - var pair = vars[i].split('='); - if(pair.length < 2) { + var pair = vars[i].split('='); + if (pair.length < 2) { continue; } params[pair[0]] = pair[1]; } - if(_options.galleryPIDs) { + if (_options.galleryPIDs) { // detect custom pid in hash and search for it among the items collection var searchfor = params.pid; params.pid = 0; // if custom pid cannot be found, fallback to the first item - for(i = 0; i < _items.length; i++) { - if(_items[i].pid === searchfor) { + for (i = 0; i < _items.length; i++) { + if (_items[i].pid === searchfor) { params.pid = i; break; } } } else { - params.pid = parseInt(params.pid,10)-1; + params.pid = parseInt(params.pid, 10) - 1; } - if( params.pid < 0 ) { + if (params.pid < 0) { params.pid = 0; } return params; }, - _updateHash = function() { - - if(_hashAnimCheckTimeout) { + _updateHash = function () { + if (_hashAnimCheckTimeout) { clearTimeout(_hashAnimCheckTimeout); } - - if(_numAnimations || _isDragging) { + if (_numAnimations || _isDragging) { // changing browser URL forces layout/paint in some browsers, which causes noticable lag during animation // that's why we update hash only when no animations running _hashAnimCheckTimeout = setTimeout(_updateHash, 500); return; } - - if(_hashChangedByScript) { + + if (_hashChangedByScript) { clearTimeout(_hashChangeTimeout); } else { _hashChangedByScript = true; } - - var pid = (_currentItemIndex + 1); - var item = _getItemAt( _currentItemIndex ); - if(item.hasOwnProperty('pid')) { + var pid = _currentItemIndex + 1; + var item = _getItemAt(_currentItemIndex); + if (item.hasOwnProperty('pid')) { // carry forward any custom pid assigned to the item pid = item.pid; } - var newHash = _initialHash + '&' + 'gid=' + _options.galleryUID + '&' + 'pid=' + pid; + var newHash = _initialHash + '&' + 'gid=' + _options.galleryUID + '&' + 'pid=' + pid; - if(!_historyChanged) { - if(_windowLoc.hash.indexOf(newHash) === -1) { + if (!_historyChanged) { + if (_windowLoc.hash.indexOf(newHash) === -1) { _urlChangedOnce = true; } // first time - add new hisory record, then just replace } - var newURL = _windowLoc.href.split('#')[0] + '#' + newHash; - - if( _supportsPushState ) { + var newURL = _windowLoc.href.split('#')[0] + '#' + newHash; - if('#' + newHash !== window.location.hash) { + if (_supportsPushState) { + if ('#' + newHash !== window.location.hash) { history[_historyChanged ? 'replaceState' : 'pushState']('', document.title, newURL); } - } else { - if(_historyChanged) { - _windowLoc.replace( newURL ); + if (_historyChanged) { + _windowLoc.replace(newURL); } else { _windowLoc.hash = newHash; } } - - _historyChanged = true; - _hashChangeTimeout = setTimeout(function() { + _hashChangeTimeout = setTimeout(function () { _hashChangedByScript = false; }, 60); }; - - - - _registerModule('History', { - - - publicMethods: { - initHistory: function() { - + initHistory: function () { framework.extend(_options, _historyDefaultOptions, true); - if( !_options.history ) { + if (!_options.history) { return; } - _windowLoc = window.location; _urlChangedOnce = false; _closedFromURL = false; _historyChanged = false; _initialHash = _getHash(); - _supportsPushState = ('pushState' in history); + _supportsPushState = 'pushState' in history; - - if(_initialHash.indexOf('gid=') > -1) { + if (_initialHash.indexOf('gid=') > -1) { _initialHash = _initialHash.split('&gid=')[0]; _initialHash = _initialHash.split('?gid=')[0]; } - _listen('afterChange', self.updateURL); - _listen('unbindEvents', function() { + _listen('unbindEvents', function () { framework.unbind(window, 'hashchange', self.onHashChange); }); - - var returnToOriginal = function() { + var returnToOriginal = function () { _hashReseted = true; - if(!_closedFromURL) { - - if(_urlChangedOnce) { + if (!_closedFromURL) { + if (_urlChangedOnce) { history.back(); } else { - - if(_initialHash) { + if (_initialHash) { _windowLoc.hash = _initialHash; } else { if (_supportsPushState) { - // remove hash from url without refreshing it or scrolling to top - history.pushState('', document.title, _windowLoc.pathname + _windowLoc.search ); + history.pushState('', document.title, _windowLoc.pathname + _windowLoc.search); } else { _windowLoc.hash = ''; } } } - } _cleanHistoryTimeouts(); }; - - _listen('unbindEvents', function() { - if(_closedByScroll) { + _listen('unbindEvents', function () { + if (_closedByScroll) { // if PhotoSwipe is closed by scroll, we go "back" before the closing animation starts // this is done to keep the scroll position returnToOriginal(); } }); - _listen('destroy', function() { - if(!_hashReseted) { + _listen('destroy', function () { + if (!_hashReseted) { returnToOriginal(); } }); - _listen('firstUpdate', function() { + _listen('firstUpdate', function () { _currentItemIndex = _parseItemIndexFromURL().pid; }); - - - var index = _initialHash.indexOf('pid='); - if(index > -1) { + if (index > -1) { _initialHash = _initialHash.substring(0, index); - if(_initialHash.slice(-1) === '&') { + if (_initialHash.slice(-1) === '&') { _initialHash = _initialHash.slice(0, -1); } } - - setTimeout(function() { - if(_isOpen) { // hasn't destroyed yet + setTimeout(function () { + if (_isOpen) { + // hasn't destroyed yet framework.bind(window, 'hashchange', self.onHashChange); } }, 40); - }, - onHashChange: function() { - - if(_getHash() === _initialHash) { - + onHashChange: function () { + if (_getHash() === _initialHash) { _closedFromURL = true; self.close(); return; } - if(!_hashChangedByScript) { - + if (!_hashChangedByScript) { _hashChangedByHistory = true; - self.goTo( _parseItemIndexFromURL().pid ); + self.goTo(_parseItemIndexFromURL().pid); _hashChangedByHistory = false; } - }, - updateURL: function() { - - // Delay the update of URL, to avoid lag during transition, + updateURL: function () { + // Delay the update of URL, to avoid lag during transition, // and to not to trigger actions like "refresh page sound" or "blinking favicon" to often - + _cleanHistoryTimeouts(); - - if(_hashChangedByHistory) { + if (_hashChangedByHistory) { return; } - if(!_historyChanged) { + if (!_historyChanged) { _updateHash(); // first time } else { _historyUpdateTimeout = setTimeout(_updateHash, 800); } } - } });