Задать вопрос
shylov
@shylov
Начинающий

Что сделать что-бы код вел себя одинаково в разных браузерах?

Во время работы на локальном сервере 'openserver' в 'firefox' все выводилось корректно без каких либо фризов . Решил проверить верстку в других браузерах 'googlechrome' , 'opera' , 'IE' где обнаружил задержку и фризы во время обработки 'js' кода .
Возможно в написание кода я использую неправильный подход (странно но почему тогда 'firefox' показывает все без проблем) . Прошу совета в данном случае .
; $(document).ready(function () {
    fix = [];
    val = [];
    sh1 = $(window).height();
    checkarrow(sh1);
    function checkarrow(sh1) { // при запуске страницы без скрола
        if ($(this).scrollTop() == 0) {
            $(".header-fixed-arrow").css({ 'position': 'fixed', 'left': '2px', 'transform': 'rotateZ(180deg)', 'top': '12px' });
            val.pop();
            val.push(5);
        }
        if ($(this).scrollTop() + sh1 <= 3170 && val == 0) {
            $(".header-fixed-arrow").css({ 'transition': 'linear 1s', 'position': 'fixed', 'top': 'unset', 'left': '2px', 'bottom': '56px' });
            val.pop();
            val.push(1);
        }
        heigst = $(".fb-wrap").offset().top;
        sh1 = $(window).height();
        sh2 = $('.header-fixed-question').outerHeight();
        sh3 = $('.header-fixed-arrow').outerHeight();
        if ($(this).scrollTop() + sh1 - 8.5 > heigst + sh3 / 2 + sh2) {
            $(".header-fixed-arrow").css({ 'transform': 'none', 'position': 'absolute', 'top': '' + heigst - sh3 / 2 + 'px' });
            fix.pop();
            fix.push(3171);
            val.pop();
            val.push(1);
        }
    };
    $(window).scroll(function () { // Во время скрола
        nt1 = sh1 - 108;
        value1();
        function value1() {
            if ($(this).scrollTop() == 0) {
                $(".header-fixed-arrow").css({ 'transition': 'linear 1s' });
                fix.pop();
                fix.push(5);
                if (val == 1) {
                    $(".header-fixed-arrow").css({ 'transform': 'translateY(-' + nt1 + 'px) rotateZ(180deg)' });
                    return;
                }
                $(".header-fixed-arrow").css({ 'transform': 'translateY(0px) rotateZ(180deg)' });
            }
        }
        value2(nt1);
        function value2(nt1) {
            if ($(this).scrollTop() > 1 && $(this).scrollTop() + (Number(fix.join())) < 3171) {
                $(".header-fixed-arrow").css({ 'transition': 'linear 1s' });
                if (val == 1) {
                    $(".header-fixed-arrow").css({ 'transform': 'translateY(0px) rotateZ(0deg)' });
                    return;
                }
                $(".header-fixed-arrow").css({ 'transform': 'translateY(' + nt1 + 'px) rotateZ(0deg)' });
            }
        }
        heigst = $(".fb-wrap").offset().top;
        sh2 = $('.header-fixed-question').outerHeight();
        sh3 = $('.header-fixed-arrow').outerHeight();
        if ($(this).scrollTop() + sh1 - 8.5 < heigst + sh3 / 2 + sh2 && fix == 3171) {
            $(".header-fixed-arrow").css({ 'transition': 'linear 1s', 'position': 'fixed', 'top': 'unset', 'left': '2px', 'bottom': '56px' });
        }
        if ($(this).scrollTop() + sh1 - 8.5 > heigst + sh3 / 2 + sh2) {
            $(".header-fixed-arrow").css({ 'transition': 'linear 0s', 'transform': 'none', 'position': 'absolute', 'top': '' + heigst - sh3 / 2 + 'px' });
            fix.pop();
            fix.push(3171);
            val.pop();
            val.push(1);
        }
    });
    $('.header-fixed-arrow').click(function () {
        if ($(window).scrollTop() == 0) {
            $('html, body').animate({ scrollTop: 2050 }, 1100);
        };
        if ($(window).scrollTop() >= 1) {
            $('html, body').animate({ scrollTop: 0 }, 1100);
        }
    })
});
  • Вопрос задан
  • 62 просмотра
Подписаться 1 Средний Комментировать
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Похожие вопросы
15 февр. 2025, в 03:09
2500 руб./за проект
14 февр. 2025, в 23:25
20000 руб./за проект
14 февр. 2025, в 22:36
5000 руб./за проект