Skip to content

added events and images back in for complete example#1

Open
dioptre wants to merge 2 commits into9am:mainfrom
dioptre:main
Open

added events and images back in for complete example#1
dioptre wants to merge 2 commits into9am:mainfrom
dioptre:main

Conversation

@dioptre
Copy link

@dioptre dioptre commented Feb 9, 2025

No description provided.

Copy link
Owner

@9am 9am left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution, let's discuss in the PR : )

try {
this.shadowRoot!.host.classList.add('loading');
this.dispatchEvent(new CustomEvent('loading', {
bubbles: true,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm all good with events, but it's better to declare them in const somewhere, what do you think~

const source = <HTMLImageElement>this.img.cloneNode();
const pixels = source.width * source.height;
source.crossOrigin = 'anonymous'; // Ensure we can read the pixel data
const pixels = this.img.width * this.img.height;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any reason to use this.img instead of source for the pixels?

source.width = Math.ceil(source.width * scale);
source.height = Math.ceil(source.height * scale);
source.width = Math.ceil(this.img.width * scale);
source.height = Math.ceil(this.img.height * scale);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above ☝️

}));

// limit max pixel
const source = <HTMLImageElement>this.img.cloneNode();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this the root cause of the 'img not ready' problem? Not sure how will it act, maybe cloneNode on a loaded img will trigger a reloading of the URL again?
Anyway, if that's the case, will it be better to resolve the issue here by adding a waiting promise like you did below? Thanks for finding this bug, though.

// limit max pixel
const source = <HTMLImageElement>this.img.cloneNode();
const pixels = source.width * source.height;
source.crossOrigin = 'anonymous'; // Ensure we can read the pixel data
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

source is cloned from img, i guess we already have the crossOrigin assigned in static loadImage : )

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you bring back the original avocado picture I removed?
That one helped me a lot during creating the component due to its simplicity, and..... it's kind of where the logo comes from : )

<div class="dot black"></div>
</div>
<img-halftone src="./img/friut.jpeg" shape="circle"></img-halftone>
<img-halftone src="./img/fruit.jpg" shape="circle"></img-halftone>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for catching this... 🤣

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

Successfully merging this pull request may close these issues.

2 participants