cm-chessboard 4.1.8 → 4.1.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cm-chessboard",
3
- "version": "4.1.8",
3
+ "version": "4.1.9",
4
4
  "description": "A JavaScript chessboard which is lightweight, ES6 module based, responsive, SVG rendered and without dependencies.",
5
5
  "keywords": [
6
6
  "chess",
@@ -171,18 +171,6 @@ export class Chessboard {
171
171
  this.view.drawMarkers()
172
172
  }
173
173
 
174
- destroy() {
175
- this.positionAnimationsQueue.destroy()
176
- this.view.destroy()
177
- this.view = undefined
178
- this.state = undefined
179
- if (this.squareSelectListener) {
180
- this.context.removeEventListener("contextmenu", this.squareSelectListener)
181
- this.context.removeEventListener("mouseup", this.squareSelectListener)
182
- this.context.removeEventListener("touchend", this.squareSelectListener)
183
- }
184
- }
185
-
186
174
  enableMoveInput(eventHandler, color = undefined) {
187
175
  this.view.enableMoveInput(eventHandler, color)
188
176
  }
@@ -225,4 +213,17 @@ export class Chessboard {
225
213
  this.view.visualizeInputState()
226
214
  }
227
215
 
216
+ destroy() {
217
+ this.positionAnimationsQueue.destroy()
218
+ this.view.destroy()
219
+ this.view = undefined
220
+ this.state = undefined
221
+ if (this.squareSelectListener) {
222
+ this.context.removeEventListener("contextmenu", this.squareSelectListener)
223
+ this.context.removeEventListener("mouseup", this.squareSelectListener)
224
+ this.context.removeEventListener("touchend", this.squareSelectListener)
225
+ }
226
+ this.destroyed = true
227
+ }
228
+
228
229
  }
@@ -113,12 +113,14 @@ export class ChessboardViewAccessible extends ChessboardView {
113
113
  redrawPieces(squares = this.chessboard.state.position.squares) {
114
114
  super.redrawPieces(squares)
115
115
  setTimeout(() => {
116
- this.redrawPositionInAltAttribute()
117
- if (this.chessboard.props.accessibility.boardAsTable) {
118
- this.redrawBoardAsTable()
119
- }
120
- if (this.chessboard.props.accessibility.piecesAsList) {
121
- this.redrawPiecesLists()
116
+ if(!this.chessboard.destroyed) {
117
+ this.redrawPositionInAltAttribute()
118
+ if (this.chessboard.props.accessibility.boardAsTable) {
119
+ this.redrawBoardAsTable()
120
+ }
121
+ if (this.chessboard.props.accessibility.piecesAsList) {
122
+ this.redrawPiecesLists()
123
+ }
122
124
  }
123
125
  })
124
126
  }