How to move Widget's X,Y coordinate via Web SDK

  • 20 January 2024
  • 1 reply
  • 32 views

Badge

How to move it?

 

async function addSticky() {

myItem = await miro.board.createStickyNote({

content: 'Web SDK test!',

});
}

 

async function moveRight() {

myItem.x += 10;

}

is it possible to move throught WEB SDK?


1 reply

Userlevel 6
Badge +4

Hey @Junhyeok Choi,

Good question! You can update an item’s position (x, y) using the Web SDK’s sync() method.

First, you’ll set the new values of the x, y coordinates, and then you’ll call sync() to make the updated position effective on the board.

Here is an example for creating a sticky note and then updating it’s position:

const stickyNote = await miro.board.createStickyNote({
content: 'Hello'
});

// First, you change the values of the properties you want to update.
stickyNote.content = 'Updated sticky note';
stickyNote.style.fillColor = 'light_blue';
stickyNote.x = 200;
stickyNote.y = -100;

// Second, you sync the item to make the changes effective.
await stickyNote.sync();

You can even test this out with our built in sandbox here:
https://developers.miro.com/docs/task-2-update-an-items-properties-with-sync

Hope it helps!
Will

Reply