我正在使用这个网站浏览插件,它工作得很好,除了我需要为它添加一个偏移量以在它向上滚动页面时清除我的网站的固定标题。目前它将工具提示放置在视口的最顶部,由于固定的标题,它会部分遮盖突出显示的元素。我尝试了一些方法,包括对“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();