2017-02-11 76 views
0

我正在努力使fullcalendar调度程序滚动到人员点击的区域,并且此代码有点作用,但取决于屏幕大小,它应该放大的实际区域通常滚动过去,并且在窗口内不可见。滚动以使div可见

有没有办法确保表格标题单元的左边框与窗口的左边界对齐?

在视图中,有一个div $('.fc-time-area.fc-widget-header .fc-scroller')内的水平滚动表,我想看到的电池可以用的东西可以找到这样的:$(".fc-time-area.fc-widget-header .fc-content th[data-date='2017-2-11T10:00:00']")

var centerTime = function (day) { 
    $('.fc-time-area.fc-widget-header .fc-scroller').animate({ 
     scrollLeft: $(".fc-time-area.fc-widget-header .fc-content").find("th[data-date='" + day + "']").offset().left 
    }, 750); 
}; 

回答

0

我想通了。显然,使用offset()position()是有区别的。通过改变这个简单的东西,它现在效果很好。

var centerTime = function (day) { 
    $('.fc-time-area.fc-widget-header .fc-scroller').animate({ 
     scrollLeft: $(".fc-time-area.fc-widget-header .fc-content").find("th[data-date='" + day + "']").offset().left 
    }, 750); 
};