diff --git a/lib/web/fotorama/fotorama.js b/lib/web/fotorama/fotorama.js index 17736feef448f..b12c122f9f362 100644 --- a/lib/web/fotorama/fotorama.js +++ b/lib/web/fotorama/fotorama.js @@ -318,6 +318,19 @@ fotoramaVersion = '4.6.4'; return ret; }; + tests['passiveeventlisteners'] = function() { + var supportsPassiveOption = false; + try { + var opts = Object.defineProperty({}, 'passive', { + get: function() { + supportsPassiveOption = true; + } + }); + window.addEventListener('test', null, opts); + } catch (e) {} + return supportsPassiveOption; + }; + tests['csstransitions'] = function () { return testPropsAll('transition'); @@ -659,8 +672,8 @@ fotoramaVersion = '4.6.4'; function readTransform(css, dir) { return css.match(/ma/) && css.match(/-?\d+(?!d)/g)[css.match(/3d/) ? - (dir === 'vertical' ? 13 : 12) : (dir === 'vertical' ? 5 : 4) - ] + (dir === 'vertical' ? 13 : 12) : (dir === 'vertical' ? 5 : 4) + ] } function readPosition($el, dir) { @@ -1140,7 +1153,13 @@ fotoramaVersion = '4.6.4'; function addEvent(el, e, fn, bool) { if (!e) return; - el.addEventListener ? el.addEventListener(e, fn, {passive: !!bool}) : el.attachEvent('on' + e, fn); + + const options = (Modernizr.passiveeventlisteners) ? { + passive: e === 'wheel', + capture: !!bool, + } : !!bool; + + el.addEventListener(e, fn, options); } /** @@ -1519,7 +1538,7 @@ fotoramaVersion = '4.6.4'; addEvent(el, 'touchmove', onMove); addEvent(el, 'touchend', onEnd); - addEvent(document, 'touchstart', onOtherStart, true); + addEvent(document, 'touchstart', onOtherStart); addEvent(document, 'touchend', onOtherEnd); addEvent(document, 'touchcancel', onOtherEnd); @@ -2338,10 +2357,10 @@ fotoramaVersion = '4.6.4'; function loaded() { $.Fotorama.measures[src] = imgData.measures = $.Fotorama.measures[src] || { - width: img.width, - height: img.height, - ratio: img.width / img.height - }; + width: img.width, + height: img.height, + ratio: img.width / img.height + }; setMeasures(imgData.measures.width, imgData.measures.height, imgData.measures.ratio, index); @@ -2356,7 +2375,7 @@ fotoramaVersion = '4.6.4'; } fit($img, ( - $.isFunction(specialMeasures) ? specialMeasures() : specialMeasures) || measures); + $.isFunction(specialMeasures) ? specialMeasures() : specialMeasures) || measures); $.Fotorama.cache[src] = frameData.state = 'loaded'; @@ -2463,11 +2482,11 @@ fotoramaVersion = '4.6.4'; if (dataFrame.html) { $('
') .append( - dataFrame._html ? $(dataFrame.html) - .removeAttr('id') - .html(dataFrame._html) // Because of IE - : dataFrame.html - ) + dataFrame._html ? $(dataFrame.html) + .removeAttr('id') + .html(dataFrame._html) // Because of IE + : dataFrame.html + ) .appendTo($frame); } @@ -2566,7 +2585,7 @@ fotoramaVersion = '4.6.4'; }, specialMeasures = getSpecialMeasures(), exceedLimit = opts.navdir === 'vertical' ? - thisData.t > rightLimit : thisData.l > rightLimit; + thisData.t > rightLimit : thisData.l > rightLimit; specialMeasures.w = thisData.w; if ((opts.navdir !== 'vertical' && thisData.l + thisData.w < leftLimit)