Page 1 of 1

[SOLVED] Difference placeOnObjectPos and slideToObjectPos

Posted: 07 May 2021, 19:29
by Badguizmo
Hello.
I am facing a strange behavior.

I have a card that receive a token damage.
When adding this token damage during "normal play" I am using this code in a function named "applydamage" :

Code: Select all

dojo.place(this.format_block('jstpl_damage_token', {
	damageValue: 3,
	cardId: cardId,
	tokenIndex: 1
}), 'card_'+cardId,'last');
this.placeOnObject('token_damage_' + cardId+'_1', 'overall_player_board_' + this.getActivePlayerId());
this.slideToObjectPos('token_damage_' + cardId+'_1', 'card_'+cardId,horizontalPosition,verticalPostion).play();
In CSS :

Code: Select all

.token-normal-card{
position: relative;
}
.card-elemental {
position: absolute;
}
The token damage is placed on "top" of the card and with an offset to the left ==> witch is GOOD.

But I have also coded a function for refreshing the page named "setupApplyDamage" :

Code: Select all

dojo.place(this.format_block('jstpl_damage_token', {
	damageValue: 3,
	cardId: cardId,
	tokenIndex: 1
}), 'card_' + cardId, 'last');
this.placeOnObjectPos('token_damage_' + cardId + '_1', 'card_' + cardId, horizontalPosition, verticalPostion);
But now the offsets are applyed from the center of the card.
I have to modify the style to have the token at the right place

Code: Select all

dojo.style('token_damage_' + cardId + '_1',topOrBottom, verticalPosition + 'px');
dojo.style('token_damage_' + cardId + '_1','left', horizontalPosition + 'px');
Is it normal behavior that these two function does not react the same or am I missing something ... again ? :D

NB there is also this topic viewtopic.php?f=12&t=14189&hilit=placeOnObjectPos but I did not linked both problems (for now).

Thank you all ^^

Re: Difference placeOnObjectPos and slideToObjectPos

Posted: 07 May 2021, 20:57
by Victoria_La
You sure horizontalPosition, etc is defined when you reload? Placing card in center is default behavior when these are undefined...

Re: Difference placeOnObjectPos and slideToObjectPos

Posted: 07 May 2021, 21:06
by tchobello
I've had the same behavior....

placeOnObject
slideToObject
SlideToObjectPos centers

placeOnObjectPos do not.

Re: Difference placeOnObjectPos and slideToObjectPos

Posted: 07 May 2021, 21:38
by Badguizmo
Victoria_La wrote: 07 May 2021, 20:57 You sure horizontalPosition, etc is defined when you reload? Placing card in center is default behavior when these are undefined...
Yes. Checked with "console.log" before calling methods.
tchobello wrote: 07 May 2021, 21:06 I've had the same behavior....

placeOnObject
slideToObject
SlideToObjectPos centers

placeOnObjectPos do not.

Mouarf ...

What I can do is maybe re-use the place and slidetoobjectpos(.....).play() even if it is for the page refresh ?

Re: Difference placeOnObjectPos and slideToObjectPos

Posted: 08 May 2021, 21:13
by Victoria_La
By reading the code placeOnObject centers it and the other one does not (i.e x,y offset of the center)
But you can do slideToObject even during reload, it actually smart enought to reduce the animation to 1ms in this case.

Re: [SOLVED] Difference placeOnObjectPos and slideToObjectPos

Posted: 08 May 2021, 23:26
by Badguizmo
Thank you.
Will do that ;)