Added Size.setCSS method

This commit is contained in:
Richard Davey 2019-04-09 23:28:05 +01:00
parent 26bdff978c
commit 1830480fec

View file

@ -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.