mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-05 20:32:00 -05:00
Prevent issues with repeated PaperScript execution on same canvas and HiDPI related scaling.
This commit is contained in:
parent
da9e1f8de7
commit
02f46b7ac2
1 changed files with 7 additions and 6 deletions
|
@ -59,14 +59,15 @@ var View = Base.extend(Callback, /** @lends View# */{
|
||||||
};
|
};
|
||||||
DomEvent.add(window, this._windowHandlers);
|
DomEvent.add(window, this._windowHandlers);
|
||||||
} else {
|
} else {
|
||||||
|
// Try visible size first, since that will help handling previously
|
||||||
|
// scaled canvases (e.g. when dealing with ratio)
|
||||||
|
size = DomElement.getSize(element);
|
||||||
// If the element is invisible, we cannot directly access
|
// If the element is invisible, we cannot directly access
|
||||||
// element.width / height, because they would appear 0.
|
// element.width / height, because they would appear 0.
|
||||||
// Reading the attributes still works.
|
// Reading the attributes should still work.
|
||||||
size = new Size(parseInt(element.getAttribute('width'), 10),
|
if (size.isNaN() || size.isZero())
|
||||||
parseInt(element.getAttribute('height'), 10));
|
size = new Size(parseInt(element.getAttribute('width'), 10),
|
||||||
// If no size was specified on the canvas, read it from CSS
|
parseInt(element.getAttribute('height'), 10));
|
||||||
if (size.isNaN())
|
|
||||||
size = DomElement.getSize(element);
|
|
||||||
}
|
}
|
||||||
// Set canvas size even if we just deterined the size from it, since
|
// Set canvas size even if we just deterined the size from it, since
|
||||||
// it might have been set to a % size, in which case it would use some
|
// it might have been set to a % size, in which case it would use some
|
||||||
|
|
Loading…
Reference in a new issue