locked
Is it possible to monitor the scroll position of panning content from JS? RRS feed

  • Question

  • I've set up some panning content based on the HTML scrolling, panning and zooming sample: http://code.msdn.microsoft.com/windowsapps/Scrolling-panning-and-47d70d4c . I'd like an event listener for when the scroll position of my scrolling content changes. However, since the scrolling functionality is added using CSS properties rather than specifying a data-win-control, it's hard to figure out if there's an object whose properties I can monitor to get updates when the scroll position changes. The documentation at http://msdn.microsoft.com/en-us/library/windows/apps/hh465310.aspx seems to imply that there is no such object exposed  to JS:

    The scroll control provides assistance to users for panning or scrolling a view. It is exposed to Windows Store app using JavaScript developers at design time through Cascading Style Sheets (CSS) only

    I've been trying to listen for the DOMAttrModified event on the div which contains the scroll content (with -ms-scroll-snap-type: mandatory & overflow-x: auto; set), but it doesn't seem to fire when the scroll position changes.

    Is there an event listener I can set up for notification when the scroll offset of panning content set up via CSS changes?

    • Edited by prehensile Monday, December 10, 2012 2:11 PM HTML formatting
    Monday, December 10, 2012 2:10 PM

Answers

  • Question was answered over at Stack Overflow: http://stackoverflow.com/questions/13805745

    Turns out there's a standard scroll event dispatched by the container div when content scrolls. No WinJS-specific stuff needed.

    • Marked as answer by Song Tian Friday, December 14, 2012 9:24 AM
    Monday, December 10, 2012 6:38 PM