diff --git a/dist/imgix.js b/dist/imgix.js index fefcead8..b28f5aa2 100644 --- a/dist/imgix.js +++ b/dist/imgix.js @@ -540,12 +540,6 @@ var ImgixTag = (function () { var clonedParams = util.shallowClone(this.baseParams); clonedParams.w = targetWidth; - if (this.baseParams.w != null && this.baseParams.h != null) { - clonedParams.h = Math.round( - targetWidth * (this.baseParams.h / this.baseParams.w) - ); - } - var url = this.baseUrlWithoutQuery + '?', val, params = []; @@ -807,7 +801,7 @@ var ImgixTag = require('./ImgixTag.js'), util = require('./util.js'), defaultConfig = require('./defaultConfig'); -var VERSION = '3.6.0'; +var VERSION = '3.6.1'; global.imgix = { init: function (opts) { diff --git a/dist/imgix.min.js b/dist/imgix.min.js index 2ec4972a..76ee3550 100644 --- a/dist/imgix.min.js +++ b/dist/imgix.min.js @@ -1 +1 @@ -(function(){function f(r,a,o){function u(i,t){if(!a[i]){if(!r[i]){var e="function"==typeof require&&require;if(!t&&e)return e(i,!0);if(l)return l(i,!0);var n=new Error("Cannot find module '"+i+"'");throw n.code="MODULE_NOT_FOUND",n}var s=a[i]={exports:{}};r[i][0].call(s.exports,function(t){var e=r[i][1][t];return u(e||t)},s,s.exports,f,r,a,o)}return a[i].exports}for(var l="function"==typeof require&&require,t=0;t=s||e<0||c&&i>=o}function m(){var t=j();if(b(t)){return x(t)}i=setTimeout(m,g(t))}function x(t){i=undefined;if(h&&r){return d(t)}r=a=undefined;return u}function v(){if(i!==undefined){clearTimeout(i)}f=0;r=l=a=i=undefined}function w(){return i===undefined?u:x(j())}function y(){var t=j(),e=b(t);r=arguments;a=this;l=t;if(e){if(i===undefined){return p(l)}if(c){i=setTimeout(m,s);return d(l)}}if(i===undefined){i=setTimeout(m,s)}return u}y.cancel=v;y.flush=w;return y}function I(t){var e=typeof t;return!!t&&(e=="object"||e=="function")}function d(t){return!!t&&typeof t=="object"}function p(t){return typeof t=="symbol"||d(t)&&c.call(t)==e}function P(t){if(typeof t=="number"){return t}if(p(t)){return n}if(I(t)){var e=typeof t.valueOf=="function"?t.valueOf():t;t=I(e)?e+"":e}if(typeof t!="string"){return t===0?t:+t}t=t.replace(s,"");var i=a.test(t);return i||o.test(t)?u(t.slice(2),i?2:8):r.test(t)?n:+t}b.exports=h}).call(this)}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{}],2:[function(t,e,i){var o=t("./util.js"),n=t("./targetWidths.js"),s=t("./autoSize");var r=function(){function t(t,e){this.el=t;this.settings=e||{};if(!this.el){console.warn("ImgixTag must be passed a DOM element.");return}this.window=this.settings.window?this.settings.window:null;if(this.el.hasAttribute("ix-initialized")&&!this.settings.force){return}this.ixPathVal=t.getAttribute(this.settings.pathInputAttribute);this.ixParamsVal=t.getAttribute(this.settings.paramsInputAttribute);this.ixSrcVal=t.getAttribute(this.settings.srcInputAttribute);this.ixHostVal=t.getAttribute(this.settings.hostInputAttribute)||this.settings.host;if(this.ixPathVal&&!this.ixHostVal){console.warn("You must set a value for `imgix.config.host` or specify an `ix-host` attribute to use `ix-path` and `ix-params`.");return}if(typeof this.ixPathVal==="string"&&this.ixPathVal.length==0){console.warn('`ix-path` cannot accept a value of empty string ""');return}if(typeof this.ixSrcVal==="string"&&this.ixSrcVal.length==0){console.warn('`ix-src` cannot accept a value of empty string ""');return}this.baseParams=this._extractBaseParams();this.baseUrl=this._buildBaseUrl();this.baseUrlWithoutQuery=this.baseUrl.split("?")[0];if(o.isString(this.el.className)){if(this.el.className.includes("nolazyload")){this.settings.sizesAttribute="sizes";this.settings.srcsetAttribute="srcset";this.settings.srcAttribute="src"}}if(o.isString(this.settings.sizesAttribute)){this.el.setAttribute(this.settings.sizesAttribute,this.sizes())}if(o.isString(this.settings.srcsetAttribute)){this.el.setAttribute(this.settings.srcsetAttribute,this.srcset())}if(o.isString(this.settings.srcAttribute)&&this.el.nodeName=="IMG"){this.el.setAttribute(this.settings.srcAttribute,this.src())}this.el.setAttribute("ix-initialized","ix-initialized")}t.prototype._extractBaseParams=function(){var t={};if(this.settings.defaultParams&&typeof this.settings.defaultParams==="object"&&this.settings.defaultParams!==null){t=Object.assign({},this.settings.defaultParams)}if(this.ixPathVal){t=Object.assign({},t,JSON.parse(this.ixParamsVal)||{});for(var e in t){if(e.substr(-2)==="64"){t[e]=o.encode64(t[e])}}}else{var i=this.ixSrcVal.lastIndexOf("?");if(i>-1){var n=this.ixSrcVal.substr(i+1),s=n.split("&");for(var r=0,a;rn){n=t}}return n};const r=({el:t})=>{if(!t.complete){console.warn("Imgix.js: attempted to set sizes attribute on element with complete evaluating to false");return false}if(t.naturalWidth===0){console.warn("Imgix.js: attempted to set sizes attribute on element with no naturalWidth");return false}return true};const a=({el:t,existingSizes:e,ixSizes:i,elHasAttributes:n})=>{if(!e&&!i){console.warn("Imgix.js: attempted to set sizes attribute on element without existing sizes attribute value");return false}if(!n){console.warn("Imgix.js: attempted to set sizes attribute on element with no attributes");return false}return r({el:t})};const f=({el:t,existingSizes:e,ixSizes:i,elHasAttributes:n,_window:s})=>{let r=a({el:t,existingSizes:e,ixSizes:i,elHasAttributes:n,_window:s})?l({el:t,parent:t.parentNode,width:t.offsetWidth})+"px":e;return r};const c=({el:t,existingSizes:e,ixSizes:i,_window:n,elHasAttributes:s})=>{const r=f({el:t,existingSizes:e,ixSizes:i,elHasAttributes:s,_window:n});if(r!==e){n.requestAnimationFrame(()=>{t.setAttribute("sizes",r)})}};const n=({el:t,existingSizes:e,ixSizes:i,_window:n})=>{const s=t.hasAttributes();const r=o.rICShim(n);const a=o.debounce(()=>{r(()=>c({el:t,existingSizes:e,ixSizes:i,_window:n,elHasAttributes:s}))},u);n.addEventListener("resize",a,false);return l({el:t,parent:t.parentNode,width:t.offsetWidth})+"px"};const h={getElementWidth:l,imgCanBeSized:a,updateOnResize:n};e.exports=h},{"./util":7}],4:[function(t,e,i){e.exports={host:null,useHttps:true,includeLibraryParam:true,defaultParams:{},srcAttribute:"src",srcsetAttribute:"srcset",sizesAttribute:"sizes",srcInputAttribute:"ix-src",pathInputAttribute:"ix-path",paramsInputAttribute:"ix-params",hostInputAttribute:"ix-host",window:typeof window!=="undefined"?window:null}},{}],5:[function(e,t,i){(function(r){(function(){var a=e("./ImgixTag.js"),o=e("./util.js"),s=e("./defaultConfig");var t="3.6.0";r.imgix={init:function(t){var e=o.shallowClone(this.config);o.extend(e,t||{});var i=["img["+e.srcInputAttribute+"]","source["+e.srcInputAttribute+"]","img["+e.pathInputAttribute+"]","source["+e.pathInputAttribute+"]"].join(",");var n=document.querySelectorAll(i);for(var s=0,r;s=s||e<0||c&&i>=o}function m(){var t=j();if(b(t)){return x(t)}i=setTimeout(m,g(t))}function x(t){i=undefined;if(h&&r){return d(t)}r=a=undefined;return u}function v(){if(i!==undefined){clearTimeout(i)}f=0;r=l=a=i=undefined}function w(){return i===undefined?u:x(j())}function y(){var t=j(),e=b(t);r=arguments;a=this;l=t;if(e){if(i===undefined){return p(l)}if(c){i=setTimeout(m,s);return d(l)}}if(i===undefined){i=setTimeout(m,s)}return u}y.cancel=v;y.flush=w;return y}function I(t){var e=typeof t;return!!t&&(e=="object"||e=="function")}function d(t){return!!t&&typeof t=="object"}function p(t){return typeof t=="symbol"||d(t)&&c.call(t)==e}function P(t){if(typeof t=="number"){return t}if(p(t)){return n}if(I(t)){var e=typeof t.valueOf=="function"?t.valueOf():t;t=I(e)?e+"":e}if(typeof t!="string"){return t===0?t:+t}t=t.replace(s,"");var i=a.test(t);return i||o.test(t)?u(t.slice(2),i?2:8):r.test(t)?n:+t}b.exports=h}).call(this)}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{}],2:[function(t,e,i){var o=t("./util.js"),n=t("./targetWidths.js"),s=t("./autoSize");var r=function(){function t(t,e){this.el=t;this.settings=e||{};if(!this.el){console.warn("ImgixTag must be passed a DOM element.");return}this.window=this.settings.window?this.settings.window:null;if(this.el.hasAttribute("ix-initialized")&&!this.settings.force){return}this.ixPathVal=t.getAttribute(this.settings.pathInputAttribute);this.ixParamsVal=t.getAttribute(this.settings.paramsInputAttribute);this.ixSrcVal=t.getAttribute(this.settings.srcInputAttribute);this.ixHostVal=t.getAttribute(this.settings.hostInputAttribute)||this.settings.host;if(this.ixPathVal&&!this.ixHostVal){console.warn("You must set a value for `imgix.config.host` or specify an `ix-host` attribute to use `ix-path` and `ix-params`.");return}if(typeof this.ixPathVal==="string"&&this.ixPathVal.length==0){console.warn('`ix-path` cannot accept a value of empty string ""');return}if(typeof this.ixSrcVal==="string"&&this.ixSrcVal.length==0){console.warn('`ix-src` cannot accept a value of empty string ""');return}this.baseParams=this._extractBaseParams();this.baseUrl=this._buildBaseUrl();this.baseUrlWithoutQuery=this.baseUrl.split("?")[0];if(o.isString(this.el.className)){if(this.el.className.includes("nolazyload")){this.settings.sizesAttribute="sizes";this.settings.srcsetAttribute="srcset";this.settings.srcAttribute="src"}}if(o.isString(this.settings.sizesAttribute)){this.el.setAttribute(this.settings.sizesAttribute,this.sizes())}if(o.isString(this.settings.srcsetAttribute)){this.el.setAttribute(this.settings.srcsetAttribute,this.srcset())}if(o.isString(this.settings.srcAttribute)&&this.el.nodeName=="IMG"){this.el.setAttribute(this.settings.srcAttribute,this.src())}this.el.setAttribute("ix-initialized","ix-initialized")}t.prototype._extractBaseParams=function(){var t={};if(this.settings.defaultParams&&typeof this.settings.defaultParams==="object"&&this.settings.defaultParams!==null){t=Object.assign({},this.settings.defaultParams)}if(this.ixPathVal){t=Object.assign({},t,JSON.parse(this.ixParamsVal)||{});for(var e in t){if(e.substr(-2)==="64"){t[e]=o.encode64(t[e])}}}else{var i=this.ixSrcVal.lastIndexOf("?");if(i>-1){var n=this.ixSrcVal.substr(i+1),s=n.split("&");for(var r=0,a;rn){n=t}}return n};const r=({el:t})=>{if(!t.complete){console.warn("Imgix.js: attempted to set sizes attribute on element with complete evaluating to false");return false}if(t.naturalWidth===0){console.warn("Imgix.js: attempted to set sizes attribute on element with no naturalWidth");return false}return true};const a=({el:t,existingSizes:e,ixSizes:i,elHasAttributes:n})=>{if(!e&&!i){console.warn("Imgix.js: attempted to set sizes attribute on element without existing sizes attribute value");return false}if(!n){console.warn("Imgix.js: attempted to set sizes attribute on element with no attributes");return false}return r({el:t})};const f=({el:t,existingSizes:e,ixSizes:i,elHasAttributes:n,_window:s})=>{let r=a({el:t,existingSizes:e,ixSizes:i,elHasAttributes:n,_window:s})?l({el:t,parent:t.parentNode,width:t.offsetWidth})+"px":e;return r};const c=({el:t,existingSizes:e,ixSizes:i,_window:n,elHasAttributes:s})=>{const r=f({el:t,existingSizes:e,ixSizes:i,elHasAttributes:s,_window:n});if(r!==e){n.requestAnimationFrame(()=>{t.setAttribute("sizes",r)})}};const n=({el:t,existingSizes:e,ixSizes:i,_window:n})=>{const s=t.hasAttributes();const r=o.rICShim(n);const a=o.debounce(()=>{r(()=>c({el:t,existingSizes:e,ixSizes:i,_window:n,elHasAttributes:s}))},u);n.addEventListener("resize",a,false);return l({el:t,parent:t.parentNode,width:t.offsetWidth})+"px"};const h={getElementWidth:l,imgCanBeSized:a,updateOnResize:n};e.exports=h},{"./util":7}],4:[function(t,e,i){e.exports={host:null,useHttps:true,includeLibraryParam:true,defaultParams:{},srcAttribute:"src",srcsetAttribute:"srcset",sizesAttribute:"sizes",srcInputAttribute:"ix-src",pathInputAttribute:"ix-path",paramsInputAttribute:"ix-params",hostInputAttribute:"ix-host",window:typeof window!=="undefined"?window:null}},{}],5:[function(e,t,i){(function(r){(function(){var a=e("./ImgixTag.js"),o=e("./util.js"),s=e("./defaultConfig");var t="3.6.1";r.imgix={init:function(t){var e=o.shallowClone(this.config);o.extend(e,t||{});var i=["img["+e.srcInputAttribute+"]","source["+e.srcInputAttribute+"]","img["+e.pathInputAttribute+"]","source["+e.pathInputAttribute+"]"].join(",");var n=document.querySelectorAll(i);for(var s=0,r;s