mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-03 19:45:44 -05:00
Fix issue on IE occuring when nodes are removed from DOM.
This commit is contained in:
parent
7f6ac3d8af
commit
d87937dc03
1 changed files with 11 additions and 3 deletions
|
@ -140,11 +140,19 @@ var DomElement = new function() {
|
|||
},
|
||||
|
||||
getBounds: function(el, viewport) {
|
||||
var rect = el.getBoundingClientRect(),
|
||||
doc = el.ownerDocument,
|
||||
var doc = el.ownerDocument,
|
||||
body = doc.body,
|
||||
html = doc.documentElement,
|
||||
x = rect.left - (html.clientLeft || body.clientLeft || 0),
|
||||
rect;
|
||||
try {
|
||||
// On IE, for nodes that are not inside the DOM, this throws an
|
||||
// exception. Emulate the behavior of all other browsers, which
|
||||
// return a rectangle of 0 dimensions.
|
||||
rect = el.getBoundingClientRect();
|
||||
} catch(e) {
|
||||
rect = { left: 0, top: 0, width: 0, height: 0 };
|
||||
}
|
||||
var x = rect.left - (html.clientLeft || body.clientLeft || 0),
|
||||
y = rect.top - (html.clientTop || body.clientTop || 0);
|
||||
if (!viewport) {
|
||||
var view = doc.defaultView;
|
||||
|
|
Loading…
Reference in a new issue