mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-03 19:45:44 -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);
|
||||
} 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
|
||||
// element.width / height, because they would appear 0.
|
||||
// Reading the attributes still works.
|
||||
size = new Size(parseInt(element.getAttribute('width'), 10),
|
||||
parseInt(element.getAttribute('height'), 10));
|
||||
// If no size was specified on the canvas, read it from CSS
|
||||
if (size.isNaN())
|
||||
size = DomElement.getSize(element);
|
||||
// Reading the attributes should still work.
|
||||
if (size.isNaN() || size.isZero())
|
||||
size = new Size(parseInt(element.getAttribute('width'), 10),
|
||||
parseInt(element.getAttribute('height'), 10));
|
||||
}
|
||||
// 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
|
||||
|
|
Loading…
Reference in a new issue