mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-19 06:00:56 -05:00
parent
38476b9d21
commit
eb29e72195
1 changed files with 10 additions and 6 deletions
|
@ -78,12 +78,16 @@ var View = Base.extend(Callback, /** @lends View# */{
|
|||
// Try visible size first, since that will help handling previously
|
||||
// scaled canvases (e.g. when dealing with pixel-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 should still work.
|
||||
if (size.isNaN() || size.isZero())
|
||||
size = new Size(parseInt(element.getAttribute('width'), 10),
|
||||
parseInt(element.getAttribute('height'), 10));
|
||||
if (size.isNaN() || size.isZero()) {
|
||||
// If the element is invisible, we cannot directly access
|
||||
// element.width / height, because they would appear 0.
|
||||
// Reading the attributes should still work.
|
||||
var getSize = function(name) {
|
||||
return element[name]
|
||||
|| parseInt(element.getAttribute(name), 10);
|
||||
};
|
||||
size = new Size(getSize('width'), getSize('height'));
|
||||
}
|
||||
}
|
||||
// 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