hm17-conversations/js/slide-elastic.js
2017-06-10 17:00:09 +02:00

36 lines
No EOL
1.1 KiB
JavaScript

(function(){
var slidesEl, minWidth, minHeight;
var resize = function() {
if (window.innerWidth < minWidth || window.innerHeight < minHeight) {
var sx = window.innerWidth / minWidth;
var sy = window.innerHeight / minHeight;
var transform = 'scale(' + Math.min(sx, sy) + ')';
} else {
var transform = 'none';
}
slidesEl.style.MozTransform = transform;
slidesEl.style.WebkitTransform = transform;
slidesEl.style.OTransform = transform;
slidesEl.style.msTransform = transform;
slidesEl.style.transform = transform;
}
var onLoad = function (list) {
if (document.readyState === 'complete') {
list();
} else {
window.addEventListener('load', list);
}
}
onLoad(function() {
slidesEl = document.getElementsByTagName('slides')[0];
minWidth = slidesEl.offsetWidth;
minHeight = slidesEl.offsetHeight;
resize();
window.addEventListener('resize', resize);
})
})();