Stock: Display glitches when adding cards to stock. How to animate transitions?

Game development with Board Game Arena Studio
Post Reply
User avatar
salty-horse
Posts: 78
Joined: 14 June 2012, 23:08

Stock: Display glitches when adding cards to stock. How to animate transitions?

Post by salty-horse »

I have encountered several issues using the Stock object.

1) Graphical glitch when adding two items to the stock.

I have a loop where I call addToStockWithId() several times.
If I call it twice, the second element is added to the containing div without the "top" and "left" property, so it's not positioned correctly.
I managed to fix this by calling updateDisplay() at the end of the loop, but I'm not sure if that's the correct solution.

2) Stock elements don't "wrap" correctly to the next line.

When I have too many items on the screen, the last few elements are hidden behind the BGA sidebar.
The only wrap when they reach the edge of the browser window.
I wish for them to wrap when they reach the edge of the containing div.

3) How to animate a card moving between two stocks?
This thread from 2014 suggests that to animate a card moving from one stock to another, I just need to call removeFromStockById() followed by addToStockWithId() with a parameter of the previous canvas.

However, this doesn't always work. Sometimes the old card "fades out" from the old div, and a new card appears somewhere near it, and slides to the new stock. In other cases, the old card only disappears from the old stock after the slide animation to the new stock is done.

What am I doing wrong?
User avatar
RicardoRix
Posts: 2548
Joined: 29 April 2012, 23:43

Re: Stock: Display glitches when adding cards to stock. How to animate transitions?

Post by RicardoRix »

http://en.doc.boardgamearena.com/Stock
See the 'Situation B' at the bottom
I think you're missing the 'from' parameter in addToStockWithId()


For the display wrap issue, that sounds like it might be a CSS style thing (could be wrong). Do you need to use the setOverlap() ??


There is this 'noupdate' , which I don't know if it's relevant:
removeFromStockById( id, to, noupdate )

Remove an item with a specific ID from the stock.

"to" is an optional parameter. If "to" contains the ID of an HTML element, the item removed from the stock is slided to this HTML element before it disappear.

"noupdate" is an optional parameter. If set to "true" it will prevent the stock display from changing. This is useful when multiple (but not all) items are removed at the same time, to avoid ghost items appearing briefly. Be sure to call updateDisplay after all items are removed.
User avatar
salty-horse
Posts: 78
Joined: 14 June 2012, 23:08

Re: Stock: Display glitches when adding cards to stock. How to animate transitions?

Post by salty-horse »

RicardoRix wrote: 17 October 2020, 15:56 http://en.doc.boardgamearena.com/Stock
See the 'Situation B' at the bottom
I think you're missing the 'from' parameter in addToStockWithId()
The thing I was missing from Situation B is that I should addToStockWithId BEFORE calling removeFromStockById.
However, I'm still seeing some of the glitches I mentioned.
RicardoRix wrote: 17 October 2020, 15:56 For the display wrap issue, that sounds like it might be a CSS style thing (could be wrong). Do you need to use the setOverlap() ??
Nope. Every card is fully visible.
RicardoRix wrote: 17 October 2020, 15:56 There is this 'noupdate' , which I don't know if it's relevant:
I'm already using noupdate in another situation. Not sure how it's applicable here.
User avatar
paramesis
Posts: 398
Joined: 28 April 2020, 05:00

Re: Stock: Display glitches when adding cards to stock. How to animate transitions?

Post by paramesis »

It sounds like you might have ID collisions. Does another item anywhere on the page have the same ID as the element you are adding to the stock? Most of the issues I’ve had with stocks and zones have involved accidentally creating duplicate ID’s, resulting in the symptoms you describe.
User avatar
salty-horse
Posts: 78
Joined: 14 June 2012, 23:08

Re: Stock: Display glitches when adding cards to stock. How to animate transitions?

Post by salty-horse »

All card ID's are unique and can only exist in one place at a time.

Anyway, this was a temporary interface to help implement the game logic. Now I need to rework everything, so this may be less of an issue soon.
I'll report back if I still have problems.
Post Reply

Return to “Developers”