diff --git a/cmd/present/static/slides.js b/cmd/present/static/slides.js index df10647e..ff08b82f 100644 --- a/cmd/present/static/slides.js +++ b/cmd/present/static/slides.js @@ -442,7 +442,7 @@ function handleBodyKeyDown(event) { }; function scaleSmallViewports() { - var el = document.querySelector('.slides'); + var el = document.querySelector('section.slides'); var transform = ''; var sWidthPx = 1250; var sHeightPx = 750; @@ -468,6 +468,20 @@ function addEventListeners() { scaleSmallViewports(); }, 50); }); + + // Force reset transform property of section.slides when printing page. + // Use both onbeforeprint and matchMedia for compatibility with different browsers. + var beforePrint = function() { + var el = document.querySelector('section.slides'); + el.style.transform = ''; + }; + window.onbeforeprint = beforePrint; + if (window.matchMedia) { + var mediaQueryList = window.matchMedia('print'); + mediaQueryList.addListener(function(mql) { + if (mql.matches) beforePrint(); + }); + } } /* Initialization */