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
How to Hide Error Messages #2494
Comments
It doesn't look like there's a public API for this (yet), but you could use the private API In terms of a "loading" spinner, you could always position an SVG or GIF or something over the viewer on creation, and remove/hide it once the image loads or fails by listening to those events. Of course, if you come up with a nice implementation you could always open a PR for that as well. There may be more complexity than it first seems, though, if you want to support multi-image mode or other more advanced features. |
@MWhiteFearless After the failure, how do you add the second image? Looking at the code, it seems like it should be automatically hiding the message whenever you call |
@iangilman I was wondering if it was intended. The code I'm using for the screenshot in my post is
I think the issue might be that the error message does not display until after the |
@MWhiteFearless That looks like exactly it! Looks like it's happening here: Line 250 in 9b7fc46
Probably it could just be fixed by bumping up the priority for that handler (by adding Meanwhile if you want to work around it, rounding your |
I haven't dived fully into the code here, but it seems like the order in which the |
Yeah you're right! I just tried it with open-failed instead and it works that way. That feels much better than destroying and creating a new viewer, thank you! I'm not sure if there's a code change that would make sense here, but maybe it would be helpful to add that to the documentation at least so the user understands the chain of events that happens better |
Oh, good point! I hadn't noticed the fact that they were different events. Thank you @pearcetm for pointing that out! And yes, just a little note on both events' documentation would be good. I'll tag this as a documentation issue now. |
Hello, thanks for such a great library!
I'm curious what the best way to hide or close an error message is? My use case involves one image per viewer. Sometimes the initial IIIF image api url we pass in fails, in which case we want to use a simple image instead. Currently I have this working with a handler on
add-item-failed
that uses destroy() and then creates a new viewer with the simple image.When I try to use open() or addSimpleImage() instead I get this issue where the error message displays behind the new simple image:
I've been able to hide the message here with
I'm wondering if there's a better way? Sometimes we have 10s of viewers loading on a page, and destroying and recreating them seems potentially more costly than necessary.
A slight side note, but I think it would be great to implement some kind of loading message or spinner while the viewer is fetching the IIIF data, it can take a few seconds for this call to fail and I think this would be a great feature :)
Thank you!
The text was updated successfully, but these errors were encountered: