added getStyle, fixed setPosition

This commit is contained in:
mourner 2010-09-14 14:57:45 +03:00
parent 391e57c144
commit ad46474275
3 changed files with 26 additions and 11 deletions

View File

@ -18,19 +18,20 @@
<script type="text/javascript" src="../src/core/Util.js"></script>
<script type="text/javascript" src="../src/core/Class.js"></script>
<script type="text/javascript" src="../src/core/Events.js"></script>
<script type="text/javascript" src="../src/core/Browser.js"></script>
<!-- /geometry -->
<script type="text/javascript" src="../src/geometry/Point.js"></script>
<script type="text/javascript" src="../src/geometry/Bounds.js"></script>
<script type="text/javascript" src="../src/geometry/Transformation.js"></script>
<!-- /dom -->
<script type="text/javascript" src="../src/dom/DomEvent.js"></script>
<script type="text/javascript" src="../src/dom/DomUtil.js"></script>
<!-- /geo -->
<script type="text/javascript" src="../src/geo/LatLng.js"></script>
<script type="text/javascript" src="../src/geo/Projection.js"></script>
<!-- /dom -->
<script type="text/javascript" src="../src/dom/DomEvent.js"></script>
<script type="text/javascript" src="../src/dom/DomUtil.js"></script>
<!-- /geometry -->
<script type="text/javascript" src="../src/geometry/Point.js"></script>
<script type="text/javascript" src="../src/geometry/Bounds.js"></script>
<script type="text/javascript" src="../src/geometry/Transformation.js"></script>
<!-- spec files -->

View File

@ -24,4 +24,6 @@ describe('DomUtil', function() {
});
describe('#setPosition', noSpecs);
describe('#getStyle', noSpecs);
});

View File

@ -7,6 +7,18 @@ L.DomUtil = {
return (typeof id == 'string' ? document.getElementById(id) : id);
},
getStyle: function(el, style) {
var value = el.style[style];
if ((typeof value == 'undefined') && el.currentStyle) {
value = el.currentStyle[style];
}
if (typeof value == 'undefined') {
var css = document.defaultView.getComputedStyle(el, null);
value = css ? css[style] : null;
}
return (value == 'auto' ? null : value);
},
getCumulativeOffset: function(el) {
var top = 0,
left = 0;
@ -23,8 +35,8 @@ L.DomUtil = {
if (L.Browser.webkit) {
el.style.webkitTransform = 'translate(' + point.x + 'px,' + point.y + 'px)';
} else {
el.style.left = point.x;
el.style.top = point.y;
el.style.left = point.x + 'px';
el.style.top = point.y + 'px';
}
},
getPosition: function(el) {