setPanorama() inside panorama-loaded event callback, gives error "PSVError: Loading already in progress"
See original GitHub issuePhoto Sphere Viewer 3.4.1
Hello, i am trying to reduce loading speed by loading a low quality pano image first, and then gradually loading the higher quality panorama image, below is what i tried,
panorama.on('panorama-loaded', function () {
console.log('panorama-loaded');
console.log(panorama.config.panorama);
console.log(element_id);
if(panorama.config.panorama.indexOf('/thumbs') !== -1){
panorama.setPanorama(panorama.config.panorama.replace('/thumbs', '/1024s'));
}
else if(panorama.config.panorama.indexOf('/1024s') !== -1){
panorama.setPanorama(panorama.config.panorama.replace('/1024s', '/2048s'));
}
else if(panorama.config.panorama.indexOf('/2048s') !== -1){
panorama.setPanorama(panorama.config.panorama.replace('/2048s', '/4096s'));
}
else if(panorama.config.panorama.indexOf('/4096s') !== -1){
panorama.setPanorama(panorama.config.panorama.replace('/4096s', ''));
}
});
panorama-loaded
is triggered when the pano completes loading. so after the loading completes, i try to load a higher resolution. but i am getting the error PSVError: Loading already in progress
if i call setPanorama()
after an interval of 500 ms inside this callback, then it works. which is not a good solution.
another thing is, loading new pano in this way, shows the loader icon, so is their any way i can load the new panorama without showing the loader icon ?
there is a function preloadPanorama()
but calling this function with panorama path, does not loads the image in browser.
can you please suggest me a solution ? or is there a better way to serve the purpose i am trying to reach ?
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (3 by maintainers)
In version 4 I moved all transition options to the “setPanorama” method, allowing full control of the behavior. https://github.com/mistic100/Photo-Sphere-Viewer/commit/6755d8277e3cf2fb6f8082d5283956a4b2579515
Hello again, i think there might be some improvement needed in the condition of showing loader inside
setPanorama()
function. however for now i have solved this issue by adding ahidden
class to thepsv-loader-container
explicitly. like this,$(panorama.loader.container).addClass('hidden');
so in my css file,so this overrides the dynamically changing
display
property ofpsv-loader-container
from inside thesetPanorama()
method. so it always staysdisplay: none;
untill i remove the hidden class.Note: after i loaded my max resolution panorama, i removed the
hidden
class form the loader container. so i dont mess up with any other process related to this for futher operations.so now this solves my issue, but if there is a better way to manage things, let me know please.
Thanks for your time and suggestions so far.