簡體   English   中英

jQuery scrollTop需要偏移量以清除固定的標頭

[英]jQuery scrollTop needs offset to clear fixed header

我正在使用這個網站游覽插件 ,該插件效果很好,只是我需要為其添加一個偏移量,以便在它回滾到頁面時清除我網站的固定標題。 當前,它將工具提示放置在視口的頂部,由於固定的標題,該工具提示會部分遮擋突出顯示的元素。 我已經嘗試了一些方法,包括在'easeInOutExpo'函數中應用了偏移量,但是我無法使其正常工作。 碼:

/*
     if the element is not in the viewport
     we scroll to it before displaying the tooltip
     */
    var w_t = $(window).scrollTop();
    var w_b = $(window).scrollTop() + $(window).height();

    //get the boundaries of the element + tooltip
    var b_t = parseFloat(properties.top, 10);

    if (e_t < b_t)
        b_t = e_t;

    var b_b = parseFloat(properties.top, 10) + $tooltip.height();
    if ((e_t + e_h) > b_b)
        b_b = e_t + e_h;


    if ((b_t < w_t || b_t > w_b) || (b_b < w_t || b_b > w_b)) {
        $('html, body').stop()

            .animate({scrollTop: b_t}, 500, 'easeInOutExpo', function () {
                //need to reset the timeout because of the animation delay
                if (autoplay) {
                    clearTimeout(showtime);
                    showtime = setTimeout(nextStep, step_config.time);
                }
                //show the new tooltip
                $tooltip.css(properties).show();
            });
    }
    else
    //show the new tooltip
        $tooltip.css(properties).show();

修復。 經過多次嘗試和錯誤后,我發現我可以在b_t變量上添加和抵消。

var b_t = parseFloat(properties.top, 10) - '136';

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM