Page 1 of 1

Stock Item with div instead of images.

Posted: 03 July 2020, 00:19
by RicardoRix
Hi.

I am looking for the functionality of the stock item, like the animation effects of adding, removing items, etc. but I want to do this with div's rather than images.
I have a container div with lots of things inside it, including an image, some tokens and 2 other stock items.
And players each have a list of these container types on their player boards.

I would like the ability to move the whole container around as one object between players, the same as cards normally move around in other games.

I know I can move it around with slideTo... but I'm also looking for removing/inserting to DOM and the nice animation effects.

Re: Stock Item with div instead of images.

Posted: 03 July 2020, 02:35
by paramesis
It sounds like your best option would be a Zone.
The placeInZone method includes an animation like slideTo..., and I've used it for a case similar to what you're describing.

If you really need to use the selection capability of a stock, you could inject html into the stock items after adding them. I did this for the cart selection/change speed palette in Off the Rails, but the stock items never move after the interface is loaded, so this probably wouldn't work in your case.

Re: Stock Item with div instead of images.

Posted: 03 July 2020, 07:56
by Brainchild
Absolutely, use Stock component with the onItemCreate callback to insert your div. I wrote an example in this thread about resizing stock items.