Problem with onviewchanged

  • Hi all. I want to make one ajax request a second after the view has been stopped. In app.js, I have a function:
    function getHotSpots() {
    console.log('============');
    console.log('run');
    clearTimeout(timer);
    timer = setTimeout(function(){
    $.ajax({
    url: 'get-hotspots',
    data: { atv: krpano.get('view.vlookat'), ath: krpano.get('view.vlookat'), limit: 3 },
    success: function(res){
    console.log('completed');
    }
    });
    }, 1000);
    }


    and a set it to onviewchanged event: <events name="hotspots_visibility" keep="true" onviewchanged="js(getHotSpots())"/>
    but it's worked incorrectly ( infinite loop ajax ).
    - If I replace ajax with anything (eg: console.log('111')) => it's work OK.

    - I tried add this function to input: <input type="text" onkeydown="getHotSpots()" />
    => It's work OK.
    Anyone help me resole this? Is this a bug of krpano?

    Edited 2 times, last by phidangmtv (July 30, 2018 at 12:35 PM).

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!