Skip to main content
Solved

How can i use `figma.viewport.scrollAndZoomIntoView()` with "BaseNode"?


Lovefield1
1const allNode = figma.root.findAll();
2const target = figma.getNodeById(key);
3let pageNode = target[0].parent;
4
5if (pageNode.type == "SECTION") {
6 pageNode = pageNode.parent;
7}
8
9figma.currentPage = pageNode;
10figma.viewport.scrollAndZoomIntoView(target);
11

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?

Best answer by tank666

figma.viewport.scrollAndZoomIntoView([BaseNode])

View original
This topic has been closed for replies.

tank666

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


Lovefield1

Yes scrollAndZoomIntoView() function argument is Array. But use this is Error [...target].
Error : “TypeError: value is not iterable”


tank666

Why are you using the spread syntax?


Lovefield1

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?


tank666

Just remove the spread syntax.


Lovefield1

Well, “BaseNode” object is can’t use to scrollAndZoomIntoView() function argument.
Is there really no way?


tank666

figma.viewport.scrollAndZoomIntoView([BaseNode])


Lovefield1

Oh, Thanks so mush.


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