Skip to main content
Question

How to find the child element quickly?

  • December 3, 2021
  • 3 replies
  • 2781 views

Nikita_Bryuzgin

Hi!

In my plugin, there is a list of elements. Where the user clicks on any element, the element should be focused on.

Right now I’m saving the ids of nodes, and then calling the node.findOne function:

// id is known
let node = figma.currentPage.findOne(n => n.id === id);
figma.currentPage.selection = [node];
figma.viewport.scrollAndZoomIntoView([node]);

But as it said in the docs, the search with node.findOne can be slow when used on large Figma projects.

How can I speed up this process? Should I save the node objects when forming the list, or there is a better way?

I’d really appreciate it if you would help!

3 replies

lepdev
  • 57 replies
  • December 5, 2021

by caching or by searching asychronously (this is more for not blocking user)


Nikita_Bryuzgin

Thank you for your reply 🙂


Gleb
  • Power Member
  • 4708 replies
  • December 12, 2021

Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings