Atalasoft
Welcome to Atalasoft Community Sign in | Join | Help
in

Thumbnails selecting but scroll bar not positioning.

Last post 08 Jul 2009, 8:12 AM by loufranco. 1 replies.
Sort Posts: Previous Next
  •  30 Jun 2009, 1:53 AM 18754

    Thumbnails selecting but scroll bar not positioning.

    Hi,

    I have a web page where I am programatically selecting up and down the thumbnails with a Prev and Next button.

    This works fine but the thumbnails are being selected off the current viewable thumbnails list. So, if I open an image with 30 thumbnails I can click next and the next thumbnail is selected but when I keep selecting next the selection moves below the page without reseting the scroll bar of the thumbnails to keep the currently selected thumbnail in view. Is there a way to do this ?? Shouldn't it be automatic, I can't think of a reason where you would want to scroll off the page and not show the actual selected thumbnail ?

     My code to move is:

    function NextThumbnail() {

       if (WebThumbnailViewer1.getCount() > 0) {

          if (WebThumbnailViewer1.getSelectedIndex() < WebThumbnailViewer1.getCount()-1 ) {

             WebThumbnailViewer1.SelectThumb(WebThumbnailViewer1.getSelectedIndex() + 1)

          }

       }

       return false;

    }

    function PrevThumbnail() {

        if (WebThumbnailViewer1.getCount() > 0) {

           if (WebThumbnailViewer1.getSelectedIndex() > 0) {

               WebThumbnailViewer1.SelectThumb(WebThumbnailViewer1.getSelectedIndex() - 1)

           }

       }

       return false;

    }

     

    regards

    Filed under:
  •  08 Jul 2009, 8:12 AM 18796 in reply to 18754

    Re: Thumbnails selecting but scroll bar not positioning.

    You should calculate the pixel position that you want to scroll to and then use the WebThumbnailViewer's  ScrollPosition property to move the scroll bar (or use setScrollPosition in JavaScript).  To determine the position, you need to know the height of the thumbs, the index of the thumbnail and any padding.

    Here is some JavaScript to do that (assumes your control is named WebThumbnailViewer1)

    function EnsureVisible(i) { 
       var thumbHeight = WebThumbnailViewer1.getThumbSize().Height; 
       var padding = WebThumbnailViewer1.getThumbPadding(); 
       var spacing = WebThumbnailViewer1.getThumbSpacing(); 

       var posY = (thumbHeight + (padding + spacing) * 2) * i; 

       WebThumbnailViewer1.setScrollPosition(new atalaPoint(0, -posY)); 


    function OnSelectedIndexChanged(){ 
       EnsureVisible(WebThumbnailViewer1.getSelectedIndex()); 


    // call this somewhere in your code to hook up the event
    WebThumbnailViewer1.SelectedIndexChanged = OnSelectedIndexChanged; 


View as RSS news feed in XML