cm-chessboard 4.1.6 → 4.1.8

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/README.md CHANGED
@@ -34,7 +34,7 @@ aspects of chess games.
34
34
 
35
35
  **Option 2:** Download the code from [GitHub](https://github.com/shaack/cm-chessboard).
36
36
 
37
- **Option 3:** Use it via CDN https://cdn.jsdelivr.net/npm/cm-chessboard@4/src/cm-chessboard/Chessboard.js
37
+ **Option 3:** Use it via CDN https://cdn.jsdelivr.net/npm/cm-chessboard@4.1/src/cm-chessboard/Chessboard.js
38
38
 
39
39
  After installation, copy the sprite in `cm-chessboard/assets/images/` to your projects `assets/images/`
40
40
  folder. If you put the sprite somewhere else you have to configure the location
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cm-chessboard",
3
- "version": "4.1.6",
3
+ "version": "4.1.8",
4
4
  "description": "A JavaScript chessboard which is lightweight, ES6 module based, responsive, SVG rendered and without dependencies.",
5
5
  "keywords": [
6
6
  "chess",
@@ -226,22 +226,26 @@ export class PositionAnimationsQueue extends PromiseQueue {
226
226
  }
227
227
 
228
228
  async enqueuePositionChange(positionFrom, positionTo, animated) {
229
- return super.enqueue(() => new Promise((resolve) => {
230
- let duration = animated ? this.chessboard.props.animationDuration : 0
231
- if(this.queue.length > 0) {
232
- duration = duration / (1 + Math.pow(this.queue.length / 5, 2))
233
- }
234
- // console.log("duration", duration, animated, "this.chessboard.props.animationDuration", this.chessboard.props.animationDuration)
235
- new PositionsAnimation(this.chessboard.view,
236
- positionFrom, positionTo, animated ? duration : 0,
237
- () => {
238
- if(this.chessboard.view) { // if destroyed, no view anymore
239
- this.chessboard.view.redrawPieces(positionTo.squares)
240
- }
241
- resolve()
229
+ if(positionFrom.getFen() === positionTo.getFen()) {
230
+ return Promise.resolve()
231
+ } else {
232
+ return super.enqueue(() => new Promise((resolve) => {
233
+ let duration = animated ? this.chessboard.props.animationDuration : 0
234
+ if (this.queue.length > 0) {
235
+ duration = duration / (1 + Math.pow(this.queue.length / 5, 2))
242
236
  }
243
- )
244
- }))
237
+ // console.log("duration", duration, animated, "this.chessboard.props.animationDuration", this.chessboard.props.animationDuration)
238
+ new PositionsAnimation(this.chessboard.view,
239
+ positionFrom, positionTo, animated ? duration : 0,
240
+ () => {
241
+ if (this.chessboard.view) { // if destroyed, no view anymore
242
+ this.chessboard.view.redrawPieces(positionTo.squares)
243
+ }
244
+ resolve()
245
+ }
246
+ )
247
+ }))
248
+ }
245
249
  }
246
250
 
247
251
  async enqueueTurnBoard(position, color, animated) {
@@ -1,11 +0,0 @@
1
- # Positions Queue
2
-
3
- - Extra Class
4
- - Holds the Queue
5
- - API
6
- - `isRunning(): boolean`
7
- - `pushPosition(position, animated)`
8
- - `run(): Promise` // starts the animation, callback when finished, if running : Promis
9
- - `skip(callback): Promise` // skips all running steps, displays the last position and returns to callback
10
- - Positions are set immediately in the Model
11
- - Then they are pushed into an Animations queue and run (if not running)
package/docs/PreMoves.md DELETED
@@ -1,3 +0,0 @@
1
- # Pre Moves
2
-
3
- - TODO