Page 1 of 1

Slide icon from ActionButton to Player Board

Posted: 20 August 2021, 11:38
by Fabian Viking
Wanted to animate a token grabbed when pressing an action button.
Couldn't find any example, so here is my solution:

Code: Select all

let tokenId = `slidingToken_${this.uniqueId++}`;
dojo.place( this.format_block( 'jstpl_token', 
    {
        id: tokenId,
    } ) , "left-side");
    
this.placeOnObject( tokenId, 'pick_branchtoken');
let playerBoardLocation = "playerboard_icon_p" + notif.args.player_id;
let slide = this.slideToObject(tokenId, playerBoardLocation, 700);
var parent = this;        

dojo.connect( slide, 'onEnd', 
    function() 
    {
        dojo.destroy(tokenId);
        parent.visualRefreshPlayerBoards();                
    }
);

slide.play();
My template

Code: Select all

var jstpl_token='<div id="${id}" class="branchicon" style="position: absolute; z-index: 5;"></div>';

Re: Slide icon from ActionButton to Player Board

Posted: 20 August 2021, 23:33
by Tisaac
Not sure what your example is about exactly? Doing stuff at the end of an animation is already documented in the wiki.
And by the way, using 'parent = this' is no longer needed since ECMA 5 and arrow functions, just do "dojo.connect(slide, 'onEnd', () => { ... })".'