Page 1 of 1

completesetup updates stock height based on item height

Posted: 03 July 2022, 09:47
by qinsoon
Hi All. I am using the Stock component.

The stock is created with an item height, like this

Code: Select all

this.myStock.create( this, $('my_stock'), ..., itemHeight );
In some cases, I may need to stack items in this Stock. So I need to conditionally change its height in setup()

Code: Select all

dojo.style('my_stock', 'height', newHeight+'px');
This works fine. But at some point in the game setup, the 'completesetup()' method is called, and it will resize the stock based on 'itemHeight' that the Stock is created with, and the resizing overwrites the later update of 'newHeight'.

I am wondering how I should deal with this.
Is there a callback I can use after completesetup so I can update the height?
Is there a way to disable resizing stock in completesetup?

Re: completesetup updates stock height based on item height

Posted: 14 July 2022, 14:34
by AmadanNaBriona
It's not documented on the wiki, but Stock has a resizeItems method.

Code: Select all

resizeItems(width, height, <background-width>, <background-height>)
(Last two arguments are optional).

Re: completesetup updates stock height based on item height

Posted: 14 July 2022, 15:18
by RicardoRix
I added this to the wiki, but would be nice if it had some explanation....
https://en.doc.boardgamearena.com/index ... &section=8