From d4c73d2b57de2460df50504749633faec777def6 Mon Sep 17 00:00:00 2001 From: chrillo Date: Thu, 28 Jul 2011 10:36:21 +0200 Subject: [PATCH] Scrolling Offset Bug Fix --- src/dom/DomEvent.js | 2 +- src/dom/DomUtil.js | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/dom/DomEvent.js b/src/dom/DomEvent.js index a4d49bbc..2ea784e4 100644 --- a/src/dom/DomEvent.js +++ b/src/dom/DomEvent.js @@ -117,7 +117,7 @@ L.DomEvent = { y = e.pageY ? e.pageY : e.clientY + document.body.scrollTop + document.documentElement.scrollTop, pos = new L.Point(x, y); - + pos=pos.add(L.DomUtil.getCumulativeScroll(container)) return (container ? pos.subtract(L.DomUtil.getCumulativeOffset(container)) : pos); }, diff --git a/src/dom/DomUtil.js b/src/dom/DomUtil.js index 09dd8338..ae19a6cb 100644 --- a/src/dom/DomUtil.js +++ b/src/dom/DomUtil.js @@ -28,7 +28,16 @@ L.DomUtil = { el = el.offsetParent; } while (el); return new L.Point(left, top); - }, + },getCumulativeScroll: function(el){ + var top=0, + left=0; + do { + top+=el.scrollTop || 0; + left+=el.scrollLeft || 0; + el=el.parentNode; + }while(el); + return new L.Point(left,top) + }, create: function(tagName, className, container) { var el = document.createElement(tagName);