Search code examples
javascriptsidebarintel-xdkappframework

(XDK app framework java script) how to check if a animated sidebar is completely opened?


I am kinda new to XDK and java script (a C# coder), and I am having a hard time trying to figure out how I can check if an animated side bar is completely opened, I am using App framework in Intel XDK tool ( i think I am trying to find js/sidebar.js API reference ). here is how I call the sidebar to open, close or toggle :

uib_sb.open_sidebar($sb)

uib_sb.close_sidebar($sb)

uib_sb.toggle_sidebar($sb)

but what I need is to check is completely open so activate or deactivate buttons.

by the way can you call functions with timed delay (e.g. have a button to call a function after 2 seconds)

and finally (How) can you have a regular Java script update function in HTML 5 (yep Im giving away my intentions to program a game like app)


Solution

  • I don't know about how to tell when an AppFramework sidebar is completely opened, but if there is a way to tell that, it would likely be either through an event or callback function.

    Setting a delay is easy in javascirpt, simply use setTimeout. For example to throw an alert after 2 seconds you could do something like this:

    setTimeout(function () {alert('delayed response');}, 2000)
    

    As far as an "update function", there are at least two possibilities. To cause something to be run at regular intervals, you can use setInterval (see https://developer.mozilla.org/en-US/docs/Web/API/WindowTimers.setInterval for details). If you're primarily interested in updating the animation at each frame, then you'll probably want to use requestAnimationFrame, described here - http://blog.teamtreehouse.com/efficient-animations-with-requestanimationframe