UprootLabs / poly-flif

:camera: A poly-fill for the FLIF image format.
https://uprootlabs.github.io/poly-flif/
Other
244 stars 11 forks source link

Methods to handle runtime-created elements #50

Open pjc0247 opened 5 years ago

pjc0247 commented 5 years ago

I read your docs and assumed that there is no API provided to handle lazy-loaded element. It would be great to give a chance to handle it like below:

var c = document.getElementById("SOME_CANVAAS");
flifify_or_something (c);

Thanks.

hrj commented 5 years ago

The low level API allows this, but you will have to fetch the data yourself. Example:

var c = document.getElementById("...");    // get canvas element somehow
var buffer = ...                           // get data in Uint8Array; via XHR, for example.

var pf = new PolyFlif({
  canvas: c,
  buf:    buffer
});

pf.beginPercent(true, 0, 0, 0);
pjc0247 commented 5 years ago

@hrj Yeah, maybe that would be an answer. but what I want to say is the conviences.

hrj commented 5 years ago

@pjc0247 Sure, but which part is inconvenient? I want to support maximum flexibility with minimum API. Given that the above example is just a couple of lines of code, I think it is a good tradeoff between flexibility and minimalism.

pjc0247 commented 5 years ago

@hrj Because, I have to fill out the buffer myself and params (x, 0, 0, 0) is not intuitive.

You've already implemented everything such as DOM controlling, fetching, initializing(beginPercent). but you didn't expose it. So I need to make a wrapper even if there is a full implementation somewhere.

At least, additional url or src option in current API would be great.

Thanks