In general, the problem is fictitious, you can’t even call it a problem, you can do it like in i: there is always a scroll, active - if there is scrolling, and inactive if it isn’t.
Well, the customer has stuck with me and asks me to do as in VKontakte. Ie Sroll is not positioned on the page, and when it appears, the page does not twitch.
How can I do this using jQuery do not tell me? Maybe there is some plugin.



    1 answer 1

    I wrote in the comments, now amended. An example can be found here , and I will explain the explanations in the answer.

     var detectShit = { Version: function() { var version = 999; if (navigator.appVersion.indexOf("MSIE") != -1){ version = parseFloat(navigator.appVersion.split("MSIE")[1]); return version; } } }; function scrollСompensation(){ // IE7 уже имеет поле для скроллбара, посему - для него отмена if(detectShit.Version() <= 7) return false; // если скроллбара нет, то величины равные и сравниваем их ниже, // дабы проверить наличие скролла var dH = $(document).height(); // высота документа var wH = $(window).height(); // высота окна // поправка для IE8 (вычислил вручную, посему не уверен на 100%) if (detectShit.Version() == 8) { wH += 4; } // сравниваем высоту окна и документа if(dH > wH){ // устанавливаем "поправку на скролл" $(wrapper).css('padding-left', 8.5); } else { // или "0", если скролла нет $(wrapper).css('padding-left', 0); } } // остается вызывать эту функцию при загрузке документа или при динамическом изменении контента $(window).load(scrollСompensation); 
    • jsfiddle.net/Deonis/gFfgz/4 look, probably some kind of flaw - when the scroll appears without a button (changing the frame height), the "amendment" does not occur. - zb '
    • @eicto, fix for IE8? Quite possible. jsFiddle the eighth, I refuse to boot, and when testing on LAN - it seems to be no problem. Although, and here I am not sure until the end, because My donkey is the ninth, and the eighth is simulated through mode switching. And how accurate is this imitation - I do not even know. PS Because Since jQuery 2.0 is generally going to remove support for old donkeys, it is possible that we will have to redo the same task globally ... if someone wants to bother with this)) - Deonis
    • No, it does not work in chrome, the scrolling is "twitching", I think so only with a custom bar you can decide, or hang up a fake div with a scroll with absolute coordinates. - zb '
    • Yes, there is such a letter. So it will be more accurate . - Deonis
    • :) almost test case: make the text smaller, start, show the text, drag the frame border up / down (so that the scroll appears). jsfiddle.net/oceog/gFfgz/7 that almost fixes the problem, but it still twitches a bit. - zb '