UNPKG

phaser4-rex-plugins

Version:
34 lines (28 loc) 978 B
import Anchor from '../anchor/Anchor.js'; var SetAnchor = function (config) { if (config === undefined) { config = {}; } // Assign default onResizeCallback if not given var hasMinWidth = config.hasOwnProperty('width'); var hasMinHeight = config.hasOwnProperty('height'); var hasOnResizeCallback = config.hasOwnProperty('onResizeCallback'); if ((hasMinWidth || hasMinHeight) && !hasOnResizeCallback) { config.onResizeCallback = function (width, height, sizer) { if (width !== undefined) { sizer.setMinWidth(width); } if (height !== undefined) { sizer.setMinHeight(height); } sizer.layout(); } } if (this._anchor === undefined) { this._anchor = new Anchor(this, config); } else { this._anchor.resetFromJSON(config) } return this; } export default SetAnchor;