mirror of
https://github.com/photonstorm/phaser
synced 2025-02-16 22:18:29 +00:00
Added Size.setCSS method
This commit is contained in:
parent
26bdff978c
commit
1830480fec
1 changed files with 18 additions and 0 deletions
|
@ -609,6 +609,24 @@ var Size = new Class({
|
|||
return '[{ Size (width=' + this._width + ' height=' + this._height + ' aspectRatio=' + this.aspectRatio + ' aspectMode=' + this.aspectMode + ') }]';
|
||||
},
|
||||
|
||||
/**
|
||||
* Sets the values of this Size component to the `element.style.width` and `height`
|
||||
* properties of the given DOM Element. The properties are set as `px` values.
|
||||
*
|
||||
* @method Phaser.Structs.Size#setCSS
|
||||
* @since 3.17.0
|
||||
*
|
||||
* @param {HTMLElement} element - The DOM Element to set the CSS style on.
|
||||
*/
|
||||
setCSS: function (element)
|
||||
{
|
||||
if (element && element.style)
|
||||
{
|
||||
element.style.width = this._width + 'px';
|
||||
element.style.height = this._height + 'px';
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Copies the aspect mode, aspect ratio, width and height from this Size component
|
||||
* to the given Size component. Note that the parent, if set, is not copied across.
|
||||
|
|
Loading…
Add table
Reference in a new issue