Welcome Guest! To enable all features, please Login or Register.

Notification

Icon
Error

Options
View
Last Go to last post Unread Go to first unread post
#1 Posted : Friday, June 28, 2019 4:20:26 PM(UTC)
Pawel L.

Groups: Registered, Manager, Tech Support, Administrators
Posts: 14


How to cancel loading in an image using the LEADTOOLS ImageViewer.

When loading an image into your imageviewer, there are certain instances where you will want to stop
loading an image in, and load a different image into the viewer.
While LEADTOOLS has a method for stopping the loading of an image into an imageviewer,
The abort Method- cancels the ImageLoader which is used to load image files with support for callbacks on
success and failure.

If the user is prevented from being able to use the ImageLoader, that in turn prevents them from using
the https://www.leadtools.co.../imageloaderurlmode.html
method. Which means that once you abort
you will no longer be able to add new images into the viewer in this way.

So here, we will instead change the images source by using the mutation observer.
I am attaching an example project below that loads in 2 separate images using the setTimeout method.
While we wait for setTimeout, we will switch the source of the URL which will in turn change the image being
loaded in.You can alternatively remove the setTimeout method and instead use the mutation observer to listen to a change in the imageViewer.imageUrl to then set to the imageElement.src in turn modifying the subtree of an image element which causes the DOM to fire a callback without regard to whether or not the content's of the previous image are fully loaded.

Gif Demonstrating working result after setting your filepaths accordingly and adding dependencies
File Attachment(s):
imgcancelload.gif (441kb) downloaded 53 time(s).

Project Demonstrating Functionality Download
File Attachment(s):
CancelLoadingInImage.zip (840kb) downloaded 57 time(s).

Edited by user Tuesday, July 16, 2019 10:41:34 AM(UTC)  | Reason: Not specified

Pawel Lyko
Developer Support Engineer
LEAD Technologies, Inc.

 

Try the latest version of LEADTOOLS for free for 60 days by downloading the evaluation: https://www.leadtools.com/downloads

Wanna join the discussion? Login to your LEADTOOLS Support accountor Register a new forum account.

You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Powered by YAF.NET | YAF.NET © 2003-2024, Yet Another Forum.NET
This page was generated in 0.092 seconds.