jigsawpuzzlegame 1.0.8 → 1.0.10
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/jigsaw-puzzle-game.js +17 -0
- package/package.json +1 -1
package/jigsaw-puzzle-game.js
CHANGED
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
*
|
|
5
5
|
* Stripped of all UI code, providing a clean interface for integration.
|
|
6
6
|
*
|
|
7
|
+
* @version 1.0.8
|
|
8
|
+
*
|
|
7
9
|
* @example
|
|
8
10
|
* const puzzle = new JigsawPuzzle('my-container-id', {
|
|
9
11
|
* image: 'https://example.com/image.jpg',
|
|
@@ -1881,8 +1883,23 @@ export class JigsawPuzzle {
|
|
|
1881
1883
|
break;
|
|
1882
1884
|
|
|
1883
1885
|
case 160:
|
|
1886
|
+
// Create tmpImage if it doesn't exist (needed when loading from savedData)
|
|
1887
|
+
if (!this.tmpImage) {
|
|
1888
|
+
this.puzzle.container.innerHTML = "";
|
|
1889
|
+
this.tmpImage = document.createElement("img");
|
|
1890
|
+
}
|
|
1884
1891
|
this.tmpImage.src = this.puzzle.srcImage.src;
|
|
1892
|
+
this.puzzle.getContainerSize();
|
|
1885
1893
|
fitImage(this.tmpImage, this.puzzle.contWidth * 0.95, this.puzzle.contHeight * 0.95);
|
|
1894
|
+
this.tmpImage.style.boxShadow = "-4px 4px 4px rgba(0, 0, 0, 0.5)";
|
|
1895
|
+
if (!this.tmpImage.parentNode) {
|
|
1896
|
+
this.puzzle.container.appendChild(this.tmpImage);
|
|
1897
|
+
}
|
|
1898
|
+
// Call onReady callback when puzzle is ready (image loaded and displayed)
|
|
1899
|
+
// This is needed when loading from savedData since we skip state 10
|
|
1900
|
+
if (this.options.onReady) {
|
|
1901
|
+
this.options.onReady();
|
|
1902
|
+
}
|
|
1886
1903
|
this.state = 20;
|
|
1887
1904
|
break;
|
|
1888
1905
|
}
|