pcottle.learnGitBranching/src/js/util/zoomLevel.js
2015-04-05 22:44:17 -07:00

24 lines
670 B
JavaScript

var _ = require('underscore');
var _warnOnce = true;
function detectZoom() {
/**
* Note: this method has only been tested on Chrome
* but seems to work. A much more elaborate library is available here:
* https://github.com/yonran/detect-zoom
* but seems to return a "2" zoom level for my computer (who knows)
* so I can't use it. The ecosystem for zoom level detection is a mess
*/
if (!window.outerWidth || !window.innerWidth) {
if (_warnOnce) {
console.warn("Can't detect zoom level correctly :-/");
_warnOnce = false;
}
return 1;
}
return window.outerWidth / window.innerWidth;
}
exports.detectZoom = detectZoom;