Hi ,
Can someone please help me out to get transition information from XD file in Javascript.(custom plugin).
Thanks in advance !!!
Hi ,
Can someone please help me out to get transition information from XD file in Javascript.(custom plugin).
Thanks in advance !!!
Hi @Ashish,
Since XD 19, you can use the interactions
module for retrieving all transition data for a document (see interactions ¡ Adobe XD Plugin Reference). Also, since that release, you can get per-node data by using SceneNode.triggeredInteractions
, see scenegraph ¡ Adobe XD Plugin Reference.
With this, you can, e.g., retrieve such info like this:
const interactions = require('interactions');
function main(selection, root) {
console.log('Selection node transition data:');
const selectionInteractions = selection.items[0].trigerredInteractions;
console.log(JSON.stringify(selectionInteractions));
console.log('All interactions:');
console.log(JSON.stringify(interactions.allInteractions));
}
module.exports.commands = { main }
I hope this helps , and, by the way: Welcome to the forums
Hi @pklaschka ,
Thanks for your help. i used Interactions module and got the below JSON
âinteractionsâ: [
{
âtriggerâ: {
âtypeâ: âtapâ
},
âactionâ: {
âtypeâ: âgoToArtboardâ,
âdestinationâ: {
â_childrenListâ: {}
},
âpreserveScrollPositionâ: false,
âtransitionâ: {
âtypeâ: âpushâ,
âfromSideâ: âLâ,
âeasingâ: âease-outâ,
âdurationâ: 0.3
}
}
}
]
in the above JSON, Destination Artboard node info not exists. May you please sugggest me how to get these information.
Thanks,
Ashish
destination
field should give you that information. Try console.log
ing that property only (drill down to it). Ref: https://adobexdplatform.com/plugin-docs/reference/interactions.html?h=interactions
Can I create an interaction to a new element??
I mean, if I create for example a new Text(element) and I want with a click in that Text, it goes to some Artboard, is that already possible??
@victor_puentes
No. Unfortunately, interaction data still is read-only. Cf. interactions ¡ Adobe XD Plugin Reference
APIs provide read only information about the documentâs interactive prototype mode
(as of April the 2nd, 2020).
According to the discussion in Ability to move interactions from node to node - #4 by kwiksher, a writing API, however, at least seems to be in the works:
Thank you for answering so quickly
Hello, I am having trouble getting the whole interactions thing to work.
let interactions = require(âinteractionsâ);
let allInteractions = interactions.allInteractions;
trace(allInteractions.length
);
trace(${allInteractions.length}
); //returns 0 even though I do have interactions in my artboard.
trace(incomingInteractions ${xdNode.incomingInteractions}
); //incomingInteractions is null
trace(triggeredInteractions ${JSON.stringify(xdNode.triggeredInteractions)}
); // triggeredInteractions is null also.
All these return null or 0 (in case it is a list) I canât seem to find a way to get those interactions from an SceneNode, and I am sure they do have them bc of two things:
Your help will be greatly appreciated.