-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Stores the width and height values before any adjustments are made, Solves #6581 #6588
Changes from 1 commit
bd23a1e
4591002
fc90900
5b8914b
affe0be
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3254,6 +3254,8 @@ p5.Element.prototype.size = function (w, h) { | |
let aW = w; | ||
let aH = h; | ||
const AUTO = p5.prototype.AUTO; | ||
let originalWidth = aW; | ||
let originalHeight = aH; | ||
if (aW !== AUTO || aH !== AUTO) { | ||
if (aW === AUTO) { | ||
aW = h * this.width / this.height; | ||
|
@@ -3283,14 +3285,14 @@ p5.Element.prototype.size = function (w, h) { | |
this.elt.height = aH; | ||
} | ||
|
||
this.width = this.elt.offsetWidth; | ||
this.height = this.elt.offsetHeight; | ||
originalWidth = aW; | ||
originalHeight = aH; | ||
|
||
if (this._pInst && this._pInst._curElement) { | ||
// main canvas associated with p5 instance | ||
if (this._pInst._curElement.elt === this.elt) { | ||
this._pInst._setProperty('width', this.elt.offsetWidth); | ||
this._pInst._setProperty('height', this.elt.offsetHeight); | ||
this._pInst._setProperty('width', originalWidth); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a reason for having There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah yes! I realised it later that |
||
this._pInst._setProperty('height', originalHeight); | ||
} | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like we don't set
this.width
orthis.height
any more here, was that on purpose?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I looked into my approach again and tried changing it to:
this.elt.width = aW;
this.elt.height = aH;
this._pInst._setProperty('width', aW);
this._pInst._setProperty('height', aH);
still doesn't work though, I'm kind of stuck now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you need to also set
this.width = aW
andthis.height = aH
?