Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[g] Image 支持获知何时图片加载完成 #1577

Closed
xiaoiver opened this issue Nov 3, 2023 · 1 comment
Closed

[g] Image 支持获知何时图片加载完成 #1577

xiaoiver opened this issue Nov 3, 2023 · 1 comment
Assignees

Comments

@xiaoiver
Copy link
Contributor

xiaoiver commented Nov 3, 2023

支持以下两种方式:

await image.ready;
image.addEventListener('ready', () => {});

可以在 imagePool 加载完成后触发 image 上的事件来实现。

@xiaoiver xiaoiver self-assigned this Nov 3, 2023
@xiaoiver
Copy link
Contributor Author

xiaoiver commented Nov 15, 2023

另外可以将原始宽高比存在 parsedStyle 中:

image.parsedStyle.aspect;

最后在创建图片时,可以指定宽高任意一项 + 保持原始图片宽高比:

new Image({
  style: {
    width: 100,
    keepAspectRatio: true
  }
});

xiaoiver added a commit that referenced this issue Nov 16, 2023
* fix: avoid generating redundant dom structure for document element #1578 (#1580)

* chore: commit changeset

* fix: isBillboard should work on Path

* chore: commit changeset

* feat: add keep aspect ratio in image #1577

* chore: commit changeset
xiaoiver added a commit that referenced this issue Nov 16, 2023
* Fix 1458 (#1583)

* fix: avoid generating redundant dom structure for document element #1578 (#1580)

* chore: commit changeset

* fix: isBillboard should work on Path

* chore: commit changeset

* feat: add keep aspect ratio in image #1577

* chore: commit changeset

* chore(release): bump version (#1584)

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant