locked
Context sensitive Appbar for specific areas on a page RRS feed

  • Question

  • hello.

    I have a page that has specific areas/sections defined in a grid spanning across the page (like the weather and finance app). I want to display (and hide) appbar commands when the user is looking at one of those sections however, the user won't necessarily click/swipe anything in that section that could initiate a call to the extraClass property. So how can I "listen" for this navigation to viewing this section and activate the new commands?

    Thanks!

    Christine

    Wednesday, October 3, 2012 10:09 AM

Answers

  • This may not work for you, but what we've done is check for the position of a known element of your section and show/hide based on that.  You can attach a listener to scroll events and check there.

    var knownObject = page.querySelector(".weatherHeader");
    
    if(WinJS.Utilities.getPosition(knownObject).left > 0 ) {
         // show your appbar command
     }
     else
     {
         // hide it
     }
    

    Monday, October 22, 2012 4:41 PM

All replies

  • This may not work for you, but what we've done is check for the position of a known element of your section and show/hide based on that.  You can attach a listener to scroll events and check there.

    var knownObject = page.querySelector(".weatherHeader");
    
    if(WinJS.Utilities.getPosition(knownObject).left > 0 ) {
         // show your appbar command
     }
     else
     {
         // hide it
     }
    

    Monday, October 22, 2012 4:41 PM
  • Hmmmm... Interesting idea there. I will try it out and report back.  Thank you very much for the suggestion and for the reply.

    Christine

    Tuesday, October 23, 2012 12:06 AM