cm-chessboard 5.5.6 → 5.5.7

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": "5.5.6",
3
+ "version": "5.5.7",
4
4
  "description": "A JavaScript chessboard which is lightweight, ES6 module based, responsive, SVG rendered and without dependencies.",
5
5
  "keywords": [
6
6
  "chess",
@@ -16,8 +16,9 @@ export class RenderVideo extends Extension {
16
16
  Object.assign(this.props, props)
17
17
  this.images = []
18
18
  this.makeSpriteInline()
19
- this.registerExtensionPoint(EXTENSION_POINT.animation, () => {
20
- if(this.recorder && this.recorder.state === "recording") {
19
+ this.registerExtensionPoint(EXTENSION_POINT.animation, (event) => {
20
+ console.log(event)
21
+ if (this.recorder && this.recorder.state === "recording") {
21
22
  setTimeout(() => {
22
23
  this.cloneImageAndRender()
23
24
  })
@@ -37,6 +38,7 @@ export class RenderVideo extends Extension {
37
38
  this.canvas.style.display = "none"
38
39
  this.canvas.width = dimensions.width
39
40
  this.canvas.height = dimensions.height
41
+ this.contect = this.canvas.getContext('2d')
40
42
  document.body.append(this.canvas)
41
43
  this.stream = this.canvas.captureStream()
42
44
  this.recorder = new MediaRecorder(this.stream, {mimeType: this.props.mediaType})
@@ -68,14 +70,12 @@ export class RenderVideo extends Extension {
68
70
  }
69
71
 
70
72
  cloneImageAndRender() {
71
- let clonedSvgElement = this.chessboard.view.svg.cloneNode(true)
72
- let serialized = new XMLSerializer().serializeToString(clonedSvgElement)
73
+ let serialized = new XMLSerializer().serializeToString(this.chessboard.view.svg)
73
74
  const blob = new Blob([serialized], {type: "image/svg+xml"})
74
75
  const blobURL = URL.createObjectURL(blob)
75
76
  const image = new Image()
76
77
  image.onload = () => {
77
- let context = this.canvas.getContext('2d')
78
- context.drawImage(image, 0, 0, this.canvas.width, this.canvas.height)
78
+ this.contect.drawImage(image, 0, 0, this.canvas.width, this.canvas.height)
79
79
  this.recorder.requestData()
80
80
  }
81
81
  image.src = blobURL
@@ -193,7 +193,7 @@ export class PositionsAnimation {
193
193
  }
194
194
  const t = Math.min(1, timeDiff / this.duration)
195
195
  let progress = t < .5 ? 2 * t * t : -1 + (4 - 2 * t) * t // easeInOut
196
- if (isNaN(progress)) {
196
+ if (isNaN(progress) || progress > 0.99) {
197
197
  progress = 1
198
198
  }
199
199
  this.animatedElements.forEach((animatedItem) => {