Skip to content

Widget methods

refreshToken

You can force widget to call tokenCallback you passed and refresh JWT token. Realistically it should be used in following scenarios:

  • User has logged in on your page
  • User has relogged as another user on your page

Token regeneration

If token expires widget automatically calls refreshToken for you and you don't have to do anything. This method is meant for scenarios where initiative of token set/change was taken on your side of application. In other words this method can be used to inform the widget that you generated or changed token outside of widget scope.

ts
widget.refreshToken();

setColor

Adjust widget colors so they match your page. For possible color keys refer to the Embedding options page.

ts
widget.setColor('background', '#121212');

destroy

Remove widget from the page

ts
widget.destroy();

onDestroyed

Listen to when widget gets removed from the page

ts
const onDestroyed = () => {};
widget.onDestroyed(onDestroyed);

offDestroyed

Remove onDestroyed listener

ts
const onDestroyed = () => {};
widget.onDestroyed(onDestroyed);
// ...
widget.offDestroyed(onDestroyed);

setZIndex

Sets given zIndex

ts
widget.setZIndex(9999);

setContentPositioning (available only for static widget)

Set positioning of widget content. For possible values refer to the Embedding options page.

ts
widget.setContentPositioning('static');
ts
widget.setContentPositioning('absolute');

setPadding (available only for floating widget)

Sets given x and y px padding for floating widget

ts
widget.setPadding(80, 80);

runTogglerAnimation

Run toggler animations to ensure they fit your page. Some animations might increase the size of the toggler or reveal elements that extend beyond it.

Available animations:

If toggler view is set to narrow

  • NARROW_ON_LOAD
  • NARROW_NOTIFICATION

If toggler view is set to wide

  • WIDE_NOTIFICATION
ts
widget.runTogglerAnimation('NARROW_NOTIFICATION');