Skip to content

Commit 08827df

Browse files
committed
Replace deprecated page{X,Y}Offset with scroll{X,Y}
Chartist itself is not IE11 compatible anymore, so there is no reason to stick with the legacy aliases here.
1 parent bc97987 commit 08827df

1 file changed

Lines changed: 6 additions & 10 deletions

File tree

src/scripts/chartist-plugin-tooltip.ts

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -203,11 +203,9 @@ export function ChartistPluginTooltip<T extends BaseChart<any>>(
203203
if (anchor) {
204204
const box = chartElem.getBoundingClientRect();
205205
const left =
206-
(event.target as any).x2.baseVal.value +
207-
box.left +
208-
window.pageXOffset;
206+
(event.target as any).x2.baseVal.value + box.left + window.scrollX;
209207
const top =
210-
(event.target as any).y2.baseVal.value + box.top + window.pageYOffset;
208+
(event.target as any).y2.baseVal.value + box.top + window.scrollY;
211209

212210
toolTip.style.left = left + offsetX + 'px';
213211
toolTip.style.top = top + offsetY + 'px';
@@ -217,17 +215,15 @@ export function ChartistPluginTooltip<T extends BaseChart<any>>(
217215
}
218216
} else {
219217
const offsetBox = tooltipOffsetParent.getBoundingClientRect();
220-
const allOffsetLeft = -offsetBox.left - window.pageXOffset + offsetX;
221-
const allOffsetTop = -offsetBox.top - window.pageYOffset + offsetY;
218+
const allOffsetLeft = -offsetBox.left - window.scrollX + offsetX;
219+
const allOffsetTop = -offsetBox.top - window.scrollY + offsetY;
222220

223221
if (anchor) {
224222
const box = chartElem.getBoundingClientRect();
225223
const left =
226-
(event.target as any).x2.baseVal.value +
227-
box.left +
228-
window.pageXOffset;
224+
(event.target as any).x2.baseVal.value + box.left + window.scrollX;
229225
const top =
230-
(event.target as any).y2.baseVal.value + box.top + window.pageYOffset;
226+
(event.target as any).y2.baseVal.value + box.top + window.scrollY;
231227

232228
toolTip.style.left = left + allOffsetLeft + 'px';
233229
toolTip.style.top = top + allOffsetTop + 'px';

0 commit comments

Comments
 (0)