var zoom_ratioPre = 1; var zoom_ratio = 1; var zoom_timer; var zoom_continue = false; var zoom_callbackFunction; var zoom_miliSeconds = 1000; // Default is 1 second var zoom_oldW = -1; var zoom_oldH = -1; function calculateZoomLevel() { zoom_ratioPre = ClientData.zoom_ratioPre(); if (zoom_timer) { clearTimeout(zoom_timer); zoom_timer = null; } zoom_ratio = document.documentElement.clientWidth / window.innerWidth; if (zoom_ratioPre != zoom_ratio) { if (zoom_oldW == -1) { zoom_oldW = document.documentElement.clientWidth; } if (zoom_oldH == -1) { zoom_oldH = document.documentElement.clientWidth; } if (zoom_callbackFunction) { zoom_callbackFunction(zoom_ratioPre, zoom_ratio, zoom_oldW, zoom_oldH, window.innerWidth, window.innerHeight); } zoom_ratioPre = zoom_ratio; ClientData.zoom_ratioPre(zoom_ratioPre); zoom_oldW = window.innerWidth; zoom_oldH = window.innerHeight; } if (zoom_continue == true) { zoom_timer = setTimeout("calculateZoomLevel();", zoom_miliSeconds); } }; function stopDetectZoom() { zoom_continue = false; }; function startDetectZoom(params) { zoom_continue = true; if (params.callbackFunction) { zoom_callbackFunction = params.callbackFunction; } if (params.time) { zoom_miliSeconds = params.time; } zoom_timer = setTimeout("calculateZoomLevel();", zoom_miliSeconds); };