2017-02-11 113 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); 
};