Skip to content

Commit

Permalink
- 添加图片加载状态
Browse files Browse the repository at this point in the history
- 游戏王 2 期添加字体参数
  • Loading branch information
kooriookami committed Aug 26, 2023
1 parent 7e1d3ac commit 1127b81
Show file tree
Hide file tree
Showing 14 changed files with 1,291 additions and 861 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

### 1.1.0

_2023-08-xx_
_2023-08-25_

- 添加图片加载状态
- 游戏王 2 期添加字体参数
Expand Down
1 change: 1 addition & 0 deletions docs/assets/image-af29dd04.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
186 changes: 186 additions & 0 deletions docs/assets/index-10e4cbfd.js

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion docs/assets/index-122d4d45.css

This file was deleted.

1 change: 1 addition & 0 deletions docs/assets/index-c12785d9.css

Large diffs are not rendered by default.

193 changes: 0 additions & 193 deletions docs/assets/index-f6a4247d.js

This file was deleted.

1 change: 1 addition & 0 deletions docs/assets/loader-6cd4fccd.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
<link rel="icon" type="image/svg+xml" href="./vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Yugioh Card</title>
<script type="module" crossorigin src="./assets/index-f6a4247d.js"></script>
<link rel="stylesheet" href="./assets/index-122d4d45.css">
<script type="module" crossorigin src="./assets/index-10e4cbfd.js"></script>
<link rel="stylesheet" href="./assets/index-c12785d9.css">
</head>
<body>
<div id="app"></div>
Expand Down
1,720 changes: 1,079 additions & 641 deletions package-lock.json

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,23 @@
"license": "ISC",
"dependencies": {
"@element-plus/icons-vue": "^2.1.0",
"element-plus": "^2.3.9",
"element-plus": "^2.3.10",
"json-editor-vue": "^0.10.6",
"lodash": "^4.17.21",
"normalize.css": "^8.0.1",
"vanilla-jsoneditor": "^0.17.8",
"vanilla-jsoneditor": "^0.18.2",
"vue": "^3.3.4",
"yugioh-card": "workspace:*"
},
"devDependencies": {
"@iconify/vue": "^4.1.1",
"@vitejs/plugin-vue": "^4.2.3",
"eslint": "^8.46.0",
"@vitejs/plugin-vue": "^4.3.3",
"eslint": "^8.47.0",
"eslint-define-config": "^1.23.0",
"eslint-plugin-vue": "^9.17.0",
"jsonfile": "^6.1.0",
"rollup-plugin-copy": "^3.4.0",
"sass": "^1.65.1",
"sass": "^1.66.1",
"vite": "^4.4.9"
}
}
6 changes: 3 additions & 3 deletions packages/yugioh-card/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "yugioh-card",
"version": "1.0.6",
"version": "1.1.0",
"main": "src/index.js",
"module": "src/index.js",
"repository": {
Expand All @@ -18,8 +18,8 @@
"author": "kooriookami",
"license": "ISC",
"dependencies": {
"leafer-compress-text": "^1.0.17",
"leafer-ui": "^1.0.0-beta.9",
"leafer-compress-text": "^1.0.18",
"leafer-ui": "^1.0.0-beta.10",
"lodash": "^4.17.21"
}
}
11 changes: 6 additions & 5 deletions packages/yugioh-card/src/card/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ export class Card {
}

listenImageStatus(imageLeaf) {
// todo 监听loading
imageLeaf.on(ImageEvent.LOAD, () => {
this.drawImageStatus(imageLeaf, ImageEvent.LOAD);
});
imageLeaf.on(ImageEvent.LOADED, () => {
this.drawImageStatus(imageLeaf, ImageEvent.LOADED);
});
Expand All @@ -89,7 +91,7 @@ export class Card {
}

let statusUrl = '';
if (status === 'loading') {
if (status === ImageEvent.LOAD) {
statusUrl = loaderIcon;
} else if (status === ImageEvent.ERROR) {
statusUrl = imageIcon;
Expand All @@ -101,19 +103,18 @@ export class Card {
height: 120,
x: x + width / 2 - 60,
y: y + height / 2 - 60,
visible: ['loading', ImageEvent.ERROR].includes(status) && url,
visible: [ImageEvent.LOAD, ImageEvent.ERROR].includes(status) && url,
zIndex: zIndex + 1,
});

if (status === 'loading') {
if (status === ImageEvent.LOAD) {
this.imageStatusEvent = this.leafer.on_(AnimateEvent.FRAME, () => {
this.imageStatusLeaf.rotateOf({ x: 60, y: 60 }, 3);
});
} else {
this.imageStatusLeaf.rotateOf({ x: 60, y: 60 }, 0 - this.imageStatusLeaf.rotation);
this.leafer.off_(this.imageStatusEvent);
}
console.log(status);
}

updateScale() {
Expand Down
8 changes: 3 additions & 5 deletions packages/yugioh-card/src/yugioh-card/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,9 @@ export class YugiohCard extends Card {
drawCopyright() {
if (!this.copyrightLeaf) {
this.copyrightLeaf = new Image();
this.copyrightLeaf.on(ImageEvent.LOADED, () => {
this.copyrightLeaf.x = this.cardWidth - 141 - this.copyrightLeaf.width;
});
this.leafer.add(this.copyrightLeaf);
}

Expand All @@ -670,11 +673,6 @@ export class YugiohCard extends Card {
visible: this.data.copyright,
zIndex: 30,
});

this.copyrightLeaf.x = this.cardWidth - 141 - this.copyrightLeaf.width;
this.copyrightLeaf.once(ImageEvent.LOADED, () => {
this.copyrightLeaf.x = this.cardWidth - 141 - this.copyrightLeaf.width;
});
}

drawLaser() {
Expand Down
8 changes: 3 additions & 5 deletions packages/yugioh-card/src/yugioh-series-2-card/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,9 @@ export class YugiohSeries2Card extends Card {
drawCopyright() {
if (!this.copyrightLeaf) {
this.copyrightLeaf = new Image();
this.copyrightLeaf.on(ImageEvent.LOADED, () => {
this.copyrightLeaf.x = this.cardWidth - 161 - this.copyrightLeaf.width;
});
this.leafer.add(this.copyrightLeaf);
}

Expand All @@ -438,11 +441,6 @@ export class YugiohSeries2Card extends Card {
visible: this.data.copyright,
zIndex: 30,
});

this.copyrightLeaf.x = this.cardWidth - 161 - this.copyrightLeaf.width;
this.copyrightLeaf.once(ImageEvent.LOADED, () => {
this.copyrightLeaf.x = this.cardWidth - 161 - this.copyrightLeaf.width;
});
}

drawLaser() {
Expand Down

0 comments on commit 1127b81

Please sign in to comment.