Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
jalbam opened this issue Feb 14, 2014 · 1 comment
Open

Comments

@jalbam
Copy link

jalbam commented Feb 14, 2014

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.

@eissasoubhi
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants