question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

setPanorama() inside panorama-loaded event callback, gives error "PSVError: Loading already in progress"

See original GitHub issue

Photo 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:closed
  • Created 3 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
mistic100commented, Mar 29, 2020

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

0reactions
ashraful19commented, Mar 29, 2020

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 a hidden class to the psv-loader-container explicitly. like this, $(panorama.loader.container).addClass('hidden'); so in my css file,

.psv-container .psv-loader-container.hidden{
    display: none !important;
}

so this overrides the dynamically changing display property of psv-loader-container from inside the setPanorama() method. so it always stays display: 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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

photo-sphere-viewer
2, import { EventEmitter, Event } from 'uevent'; ... 44, PANORAMA_LOADED: 'panorama-loaded', ... 159, * @summary Gets the closest parent (can by itself)....
Read more >
Sign up
@summary Triggers an event on the viewer and returns the modified value. * @function change ... throw new PSVError('Loading already in progress');.
Read more >
PhotoSphereViewer
Triggered when the panorama image has been loaded and the viewer is ready to perform the first render. Throws. PSVError. when the configuration...
Read more >
How to create a JavaScript callback for knowing when an ...
The problem with checking complete is that starting with IE9 the OnLoad events is fired before all images are loaded and its hard...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found