行ヘッダー(時間)と列ヘッダー(日)の計画に問題がありました。 私は両方を目にしたいと思っていました。 アプリケーションはIFrame内のコンテンツを表示するので、IFrameの外に水平DIVと垂直DIVを作成しました。スタイルは "overflow:hidden"です。 次に、スクロールをIFrameの「onscroll」イベントと同期させました。ここで
は、スクロールして、ヘッダーを同期するために私のコードです:私は、水平DIVと垂直DIVの高さの幅を「さらにonResize」で設定する必要がありましたので、
window.onscroll = function() {
try {
// - Scroll days header (on the top) horizontally
var offsetX = (document.documentElement && document.documentElement.scrollLeft) || document.body.scrollLeft; // Source: http://stackoverflow.com/questions/2717252/document-body-scrolltop-is-always-0-in-ie-even-when-scrolling
var header1Div = window.parent.document.getElementById("EntetesColonnes");
header1Div.scrollLeft = offsetX;
// - Scroll hours header (on the left) vertically
var offsetY = (document.documentElement && document.documentElement.scrollTop) || document.body.scrollTop; // Source: http://stackoverflow.com/questions/2717252/document-body-scrolltop-is-always-0-in-ie-even-when-scrolling
var header2Div = window.parent.document.getElementById("HeaderHoursLeft");
header2Div.scrollTop = offsetY;
}
catch (ex) {
alert("FrmPlanningChirurgien/window.onscroll: " + ex.message);
}
}
私のソリューションは、それほど単純ではありません。 これは、onResizeが1秒間に多くの時間を実行する可能性があるため、さらに複雑になります。このイベントは、スクロールが発生した場合でもIE8で発生します。 は、だから私は、あまりにも頻繁に再描画されるヘッダを防ぐためのsetTimeoutをやった:
var PREVIOUS_frameWidth = 0;
var PREVIOUS_frameHeight = 0;
var timerMakeHeaders = null;
window.onresize = function() {
try {
var frameWidth = CROSS.getWindowWidth();
var frameHeight = CROSS.getWindowHeight();
if (frameWidth != PREVIOUS_frameWidth || frameHeight != PREVIOUS_frameHeight) {
// - *** Launch headers creation method
// - If there is another query to redraw, the Timer is stopped and recreated.
// - The headers are only redrawn when Timer fires.
if (timerMakeHeaders != null) {
window.clearTimeout(timerMakeHeaders);
timerMakeHeaders = null;
}
timerMakeHeaders = window.setTimeout(makeHeaders, 50);
// - *** Store new values
PREVIOUS_frameWidth = frameWidth;
PREVIOUS_frameHeight = frameHeight;
}
} catch (e) { alert("Erreur window.onresize/FrmPlanningChirurgien.aspx : " + e.message); }
}
そして最後にmakeHeaders()
方法はdiv要素のサイズを変更する必要があります。
function makeHeaders() {
// (...)
var frame = window.parent.document.getElementById("CalendarFrame");
var iframeRect = frame.getBoundingClientRect();
headerDiv.style.width = iframeRect.right - iframeRect.left - 20; // The 20 pixels are here for the vertical scrollbar width
headerDiv.scrollLeft = frame.scrollLeft;
// (...)
var headerHourDiv = window.parent.document.getElementById("HeaderHoursLeft");
var newHeight = iframeRect.bottom - iframeRect.top - 20 - 7; // The VISIBLE width for the DIV must be equal to IFRAME Width minus the scroll width or height
headerHourDiv.style.height = newHeight;
headerHourDiv.scrollTop = frame.scrollTop;
}
catch (e) {
alert("makeHeaders: " + e.message);
} }
多分使用しないことも可能かもしれませんIFRAMEを使用し、3つのDIVSのみを使用します.1つは各ヘッダー用、もう1つはコンテンツ用です。しかし、メカニズムは同じでなければならないと思う:スクロール位置間の同期が必要だ。
敬具、
出典
2015-01-09 11:37:09
Elo
可能な重複:http://stackoverflow.com/q/983031/214773 –
@JúlioSantos:いいえ、**この**質問は全くjQueryの(あるいはJavaScriptが)言及していません。 –
ああ、OK、要点。私は答えを追加します。 –