detect-zoom icon indicating copy to clipboard operation
detect-zoom copied to clipboard

detect-zoom changes zoom when you resize the browser window in Chrome

Open jalbam opened this issue 11 years ago • 1 comments

When I am in Chrome (32.0.1700.107 m, Desktop version) and I try to resize the browser window, detect-zoom says that the zoom is applied (i.e., the zoom is not 1 or 0).

This happens because it is using "webkitMobile" function. If you try to use "webkit" function instead, you will end with a float number in devicePxPerCssPx but zoom will always be 1. If you zoom out enough, devicePxPerCssPx will return wrong numbers.

By the way, I would really like detect-zoom to be compatible with both old and newer browsers. Please, don't lose backwards compatibility.

Thanks to yonran and tombigel and everyone else involved with this script! It is great despite some issues. I hope you can fix them soom and add compatibility with any browser (old or new) whenever is possible. I would like to use it (keeping all credits, of course) for a future open source project I am developing now, but I would need detect-zoom to be reliable in all browsers, including desktop too.

jalbam avatar Feb 14 '14 16:02 jalbam

hello, I found some workaround for Chrome and FireFox :

    var tools = window.tools = {};

    tools.round = function(number, precision) {
        var factor = Math.pow(10, precision);
        var tempNumber = number * factor;
        var roundedTempNumber = Math.round(tempNumber);
        return roundedTempNumber / factor;
    };

    $(window).resize(function(event) {
        var device = detectZoom.device();
        var valid_zoom = device * 100;
        var zoom, aspect_ratio = device;

        if(valid_zoom % 5 !== 0)
            aspect_ratio = tools.round(device, 1)

        zoom = (aspect_ratio*100).toFixed()

        console.log(device,aspect_ratio, valid_zoom, zoom)
    });

but there are still some issues when zomming out under 100% in Chrome

eissasoubhi avatar Jun 27 '17 13:06 eissasoubhi