Skip to content
This repository was archived by the owner on Mar 17, 2020. It is now read-only.

Commit 1c0b4a1

Browse files
author
Jeffrey Li
committed
put scrollLeft scrollTop outside the bbox function, so user can have a full size scrollLeft/Top value, instead of the scaled ones
1 parent be99e94 commit 1c0b4a1

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

index.js

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,18 @@
4343
dir = direction.apply(this, args),
4444
nodel = d3.select(node),
4545
i = directions.length,
46-
coords
46+
coords,
47+
scrollTop = document.documentElement.scrollTop || document.body.scrollTop,
48+
scrollLeft = document.documentElement.scrollLeft || document.body.scrollLeft
4749

4850
nodel.html(content)
4951
.style({ opacity: 1, 'pointer-events': 'all' })
5052

5153
while(i--) nodel.classed(directions[i], false)
5254
coords = direction_callbacks.get(dir).apply(this)
5355
nodel.classed(dir, true).style({
54-
top: (coords.top + poffset[0]) + 'px',
55-
left: (coords.left + poffset[1]) + 'px'
56+
top: (coords.top + poffset[0]) + scrollTop + 'px',
57+
left: (coords.left + poffset[1]) + scrollLeft + 'px'
5658
})
5759

5860
return tip
@@ -261,14 +263,10 @@
261263
width = tbbox.width,
262264
height = tbbox.height,
263265
x = tbbox.x,
264-
y = tbbox.y,
265-
scrollEl = document.documentElement? document.documentElement : document.body,
266-
scrollTop = scrollEl.scrollTop,
267-
scrollLeft = scrollEl.scrollLeft
266+
y = tbbox.y
268267

269-
270-
point.x = x + scrollLeft
271-
point.y = y + scrollTop
268+
point.x = x
269+
point.y = y
272270
bbox.nw = point.matrixTransform(matrix)
273271
point.x += width
274272
bbox.ne = point.matrixTransform(matrix)

0 commit comments

Comments
 (0)