Skip to main content
const allNode = figma.root.findAll();
const target = figma.getNodeById(key);
let pageNode = target[0].parent;

if (pageNode.type == "SECTION") {
pageNode = pageNode.parent;
}

figma.currentPage = pageNode;
figma.viewport.scrollAndZoomIntoView(target);

This is my code.

I have object key and figma.getNodeById(key) has return BaseNode.

So i want to change page and move screen to object location.

But scrollAndZoomIntoView() function is can’t use with BaseNode.

How can i do?

As an argument, this method requires an array of objects, not an object.


Yes scrollAndZoomIntoView() function argument is Array. But use this is Error [...target].

Error : “TypeError: value is not iterable”


Why are you using the spread syntax?


I want using scrollAndZoomIntoView() function, but this function argument is Array.

figma.getNodeById(key) is return “BaseNode”.

So how can i convert “BaseNode” to Array?


Just remove the spread syntax.


Well, “BaseNode” object is can’t use to scrollAndZoomIntoView() function argument.

Is there really no way?


figma.viewport.scrollAndZoomIntoView([BaseNode])


Oh, Thanks so mush.


Reply