Skip to content

Latest commit

 

History

History
19 lines (12 loc) · 2.03 KB

board-ui-methods.md

File metadata and controls

19 lines (12 loc) · 2.03 KB

« Return

Board Ui methods

Note: the board UI methods will automatically start working when isepic-chess-ui.js is present, otherwise nothing will happen when they are called.

Boards created by Ic.initBoard() have the following available UI methods:

  • board.refreshUi()

Table board.<UImethods>(...):

Function Parameters Return UI refresh? Description
refreshUi(
animationType,
playSounds
)
  • ✴️animationType (Number)
  • ✴️playSounds (Boolean)

✴️Optional Parameter
- Yes This method will:
  • Refresh the HTML of all the components (if any) to reflect the internal state of the board.
  • Finish ongoing piece animations.
  • Cancel ongoing piece dragging.
  • Unselect and unhighlight squares.
  • Start the current animation (if any).
  • Highlight squares (if any).
If animationType is a falsy-value, no animation will happen.

If animationType is a positive number, the board will be refreshed with an animation as if the last move was played.

If animationType is a negative number, the board will be refreshed with an animation as if the next move was reverted.

If playSounds is a truthy-value, a sound might be played depending on multiple factors (if sound effects are not disabled in the configuration or by the browser). The sounds might get supressed by browers if the method was not fired from a click or keypress.
Examples:
  • board.refreshUi()
  • board.refreshUi(0)
  • board.refreshUi(1)
  • board.refreshUi(-1)
  • board.refreshUi(1, true)
  • board.refreshUi(-1, false)

« Return