objectFitPolyfill
Advanced tools
Comparing version
@@ -23,3 +23,3 @@ { | ||
], | ||
"version": "2.0.3" | ||
"version": "2.0.4" | ||
} |
@@ -1,1 +0,1 @@ | ||
!function(){"use strict";if("objectFit"in document.documentElement.style!=!1)return void(window.objectFitPolyfill=function(){return!1});var t=function(t){var e=window.getComputedStyle(t,null),i=e.getPropertyValue("position"),n=e.getPropertyValue("overflow"),o=e.getPropertyValue("display");i&&"static"!==i||(t.style.position="relative"),"hidden"!==n&&(t.style.overflow="hidden"),o&&"inline"!==o||(t.style.display="block"),0===t.clientHeight&&(t.style.height="100%"),t.classList.add("object-fit-polyfill")},e=function(t){var e=window.getComputedStyle(t,null),i={"max-width":"none","max-height":"none","min-width":"0px","min-height":"0px"};for(var n in i){var o=e.getPropertyValue(n);o!==i[n]&&(t.style[n]=i[n])}},i=function(i){var n=i.parentNode;t(n),e(i),i.style.position="absolute",i.style.height="100%",i.style.width="auto",i.clientWidth>n.clientWidth?(i.style.top="0",i.style.marginTop="0",i.style.left="50%",i.style.marginLeft=i.clientWidth/-2+"px"):(i.style.width="100%",i.style.height="auto",i.style.left="0",i.style.marginLeft="0",i.style.top="50%",i.style.marginTop=i.clientHeight/-2+"px")},n=function(){for(var t=document.querySelectorAll("[data-object-fit]"),e=0;e<t.length;e++){var n=t[e].nodeName.toLowerCase();"img"===n?t[e].complete?i(t[e]):t[e].addEventListener("load",function(){i(this)}):"video"===n&&(t[e].readyState>0?i(t[e]):t[e].addEventListener("loadedmetadata",function(){i(this)}))}return!0};document.addEventListener("DOMContentLoaded",function(){n()}),window.addEventListener("resize",function(){n()}),window.objectFitPolyfill=n}(); | ||
!function(){"use strict";if("objectFit"in document.documentElement.style!=!1)return void(window.objectFitPolyfill=function(){return!1});var t=function(t){var e=window.getComputedStyle(t,null),i=e.getPropertyValue("position"),n=e.getPropertyValue("overflow"),o=e.getPropertyValue("display");i&&"static"!==i||(t.style.position="relative"),"hidden"!==n&&(t.style.overflow="hidden"),o&&"inline"!==o||(t.style.display="block"),0===t.clientHeight&&(t.style.height="100%"),-1===t.className.indexOf("object-fit-polyfill")&&(t.className=t.className+" object-fit-polyfill")},e=function(t){var e=window.getComputedStyle(t,null),i={"max-width":"none","max-height":"none","min-width":"0px","min-height":"0px"};for(var n in i){e.getPropertyValue(n)!==i[n]&&(t.style[n]=i[n])}},i=function(i){var n=i.parentNode;t(n),e(i),i.style.position="absolute",i.style.height="100%",i.style.width="auto",i.clientWidth>n.clientWidth?(i.style.top="0",i.style.marginTop="0",i.style.left="50%",i.style.marginLeft=i.clientWidth/-2+"px"):(i.style.width="100%",i.style.height="auto",i.style.left="0",i.style.marginLeft="0",i.style.top="50%",i.style.marginTop=i.clientHeight/-2+"px")},n=function(){for(var t=document.querySelectorAll("[data-object-fit]"),e=0;e<t.length;e++){var n=t[e].nodeName.toLowerCase();"img"===n?t[e].complete?i(t[e]):t[e].addEventListener("load",function(){i(this)}):"video"===n&&(t[e].readyState>0?i(t[e]):t[e].addEventListener("loadedmetadata",function(){i(this)}))}return!0};document.addEventListener("DOMContentLoaded",function(){n()}),window.addEventListener("resize",function(){n()}),window.objectFitPolyfill=n}(); |
@@ -1,1 +0,1 @@ | ||
!function(){"use strict";if("objectFit"in document.documentElement.style!=!1)return void(window.objectFitPolyfill=function(){return!1});var t=function(t){var e=window.getComputedStyle(t,null),i=e.getPropertyValue("position"),n=e.getPropertyValue("overflow"),o=e.getPropertyValue("display");i&&"static"!==i||(t.style.position="relative"),"hidden"!==n&&(t.style.overflow="hidden"),o&&"inline"!==o||(t.style.display="block"),0===t.clientHeight&&(t.style.height="100%"),t.classList.add("object-fit-polyfill")},e=function(t){var e=window.getComputedStyle(t,null),i={"max-width":"none","max-height":"none","min-width":"0px","min-height":"0px"};for(var n in i){var o=e.getPropertyValue(n);o!==i[n]&&(t.style[n]=i[n])}},i=function(t,e,i){i=i.split(" ");var n,o,l,a,d;if("x"===t)n=i[0],o=i[1],l="left",a="right",d=e.clientWidth;else{if("y"!==t)return;n=i[1],o=i[0],l="top",a="bottom",d=e.clientHeight}return n===l||o===l?void(e.style[l]="0"):n===a||o===a?void(e.style[a]="0"):"center"===n||"50%"===n?(e.style[l]="50%",void(e.style["margin-"+l]=d/-2+"px")):n.indexOf("%")>=0?(n=parseInt(n),void(n<50?(e.style[l]=n+"%",e.style["margin-"+l]=d*(n/-100)+"px"):(n=100-n,e.style[a]=n+"%",e.style["margin-"+a]=d*(n/-100)+"px"))):void(e.style[l]=n)},n=function(n){var o=n.dataset?n.dataset.objectFit:n.getAttribute("data-object-fit"),l=n.dataset?n.dataset.objectPosition:n.getAttribute("data-object-position");o=o||"cover",l=l||"50% 50%";var a=n.parentNode;t(a),e(n),n.style.position="absolute",n.style.height="100%",n.style.width="auto","scale-down"===o&&(n.style.height="auto",n.clientWidth<a.clientWidth&&n.clientHeight<a.clientHeight?(i("x",n,l),i("y",n,l)):(o="contain",n.style.height="100%")),"none"===o?(n.style.width="auto",n.style.height="auto",i("x",n,l),i("y",n,l)):"cover"===o&&n.clientWidth>a.clientWidth||"contain"===o&&n.clientWidth<a.clientWidth?(n.style.top="0",n.style.marginTop="0",i("x",n,l)):"scale-down"!==o&&(n.style.width="100%",n.style.height="auto",n.style.left="0",n.style.marginLeft="0",i("y",n,l))},o=function(){for(var t=document.querySelectorAll("[data-object-fit]"),e=0;e<t.length;e++){var i=t[e].nodeName.toLowerCase();"img"===i?t[e].complete?n(t[e]):t[e].addEventListener("load",function(){n(this)}):"video"===i&&(t[e].readyState>0?n(t[e]):t[e].addEventListener("loadedmetadata",function(){n(this)}))}return!0};document.addEventListener("DOMContentLoaded",function(){o()}),window.addEventListener("resize",function(){o()}),window.objectFitPolyfill=o}(); | ||
!function(){"use strict";if("objectFit"in document.documentElement.style!=!1)return void(window.objectFitPolyfill=function(){return!1});var t=function(t){var e=window.getComputedStyle(t,null),i=e.getPropertyValue("position"),n=e.getPropertyValue("overflow"),o=e.getPropertyValue("display");i&&"static"!==i||(t.style.position="relative"),"hidden"!==n&&(t.style.overflow="hidden"),o&&"inline"!==o||(t.style.display="block"),0===t.clientHeight&&(t.style.height="100%"),-1===t.className.indexOf("object-fit-polyfill")&&(t.className=t.className+" object-fit-polyfill")},e=function(t){var e=window.getComputedStyle(t,null),i={"max-width":"none","max-height":"none","min-width":"0px","min-height":"0px"};for(var n in i){e.getPropertyValue(n)!==i[n]&&(t.style[n]=i[n])}},i=function(t,e,i){i=i.split(" ");var n,o,l,a,d;if("x"===t)n=i[0],o=i[1],l="left",a="right",d=e.clientWidth;else{if("y"!==t)return;n=i[1],o=i[0],l="top",a="bottom",d=e.clientHeight}return n===l||o===l?void(e.style[l]="0"):n===a||o===a?void(e.style[a]="0"):"center"===n||"50%"===n?(e.style[l]="50%",void(e.style["margin-"+l]=d/-2+"px")):n.indexOf("%")>=0?(n=parseInt(n),void(n<50?(e.style[l]=n+"%",e.style["margin-"+l]=d*(n/-100)+"px"):(n=100-n,e.style[a]=n+"%",e.style["margin-"+a]=d*(n/-100)+"px"))):void(e.style[l]=n)},n=function(n){var o=n.dataset?n.dataset.objectFit:n.getAttribute("data-object-fit"),l=n.dataset?n.dataset.objectPosition:n.getAttribute("data-object-position");o=o||"cover",l=l||"50% 50%";var a=n.parentNode;t(a),e(n),n.style.position="absolute",n.style.height="100%",n.style.width="auto","scale-down"===o&&(n.style.height="auto",n.clientWidth<a.clientWidth&&n.clientHeight<a.clientHeight?(i("x",n,l),i("y",n,l)):(o="contain",n.style.height="100%")),"none"===o?(n.style.width="auto",n.style.height="auto",i("x",n,l),i("y",n,l)):"cover"===o&&n.clientWidth>a.clientWidth||"contain"===o&&n.clientWidth<a.clientWidth?(n.style.top="0",n.style.marginTop="0",i("x",n,l)):"scale-down"!==o&&(n.style.width="100%",n.style.height="auto",n.style.left="0",n.style.marginLeft="0",i("y",n,l))},o=function(){for(var t=document.querySelectorAll("[data-object-fit]"),e=0;e<t.length;e++){var i=t[e].nodeName.toLowerCase();"img"===i?t[e].complete?n(t[e]):t[e].addEventListener("load",function(){n(this)}):"video"===i&&(t[e].readyState>0?n(t[e]):t[e].addEventListener("loadedmetadata",function(){n(this)}))}return!0};document.addEventListener("DOMContentLoaded",function(){o()}),window.addEventListener("resize",function(){o()}),window.objectFitPolyfill=o}(); |
{ | ||
"name": "objectFitPolyfill", | ||
"version": "2.0.3", | ||
"version": "2.0.4", | ||
"description": "A Javascript polyfill for browsers that don't support the object-fit CSS property", | ||
@@ -5,0 +5,0 @@ "main": "dist/objectFitPolyfill.min.js", |
@@ -49,3 +49,6 @@ /*---------------------------------------- | ||
$container.classList.add("object-fit-polyfill"); | ||
// Add a CSS class hook, in case people need to override styles for any reason. | ||
if ($container.className.indexOf("object-fit-polyfill") === -1) { | ||
$container.className = $container.className + " object-fit-polyfill"; | ||
} | ||
}; | ||
@@ -52,0 +55,0 @@ |
@@ -46,3 +46,6 @@ /*---------------------------------------- | ||
$container.classList.add("object-fit-polyfill"); | ||
// Add a CSS class hook, in case people need to override styles for any reason. | ||
if ($container.className.indexOf("object-fit-polyfill") === -1) { | ||
$container.className = $container.className + " object-fit-polyfill"; | ||
} | ||
}; | ||
@@ -49,0 +52,0 @@ |
25513
1.87%395
1.54%