Author Topic: Scrollview and scrollbar blues  (Read 2199 times)

wallabie

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 200
    • View Profile
Scrollview and scrollbar blues
« on: March 12, 2014, 12:54:49 AM »
As your suggestion, I created a background and foreground sprite instead of using the slider. 

As you can see from the movie, the problem is that scrollbar is not behaving as it should.
1. Not updating the percentage correctly.
2. Disappears even when there is content to be scrolled.

Movie:  https://dl.dropboxusercontent.com/u/48378123/ScrollViewProblem.mp4

This is the code is on the Left/Right Thumb Sprites: 

  1.         void OnDrag (Vector2 delta)
  2.         {
  3.                 Debug.Log ("targetWidth=" + target.width);
  4.                 var targetW = target.width;
  5.  
  6.                 //Auto Stretch Slider
  7.                 //If max border of slider is reached, then stretch.
  8.                 var rightPos = targetW - 3f;
  9.  
  10.                 if(thumbRight.cachedTransform == this.transform){
  11.  
  12.                         thumbRight.cachedTransform.parent = thumb.cachedTransform;
  13.  
  14.                         thumbRight.cachedTransform.localPosition = new Vector3(rightPos,0f,0f);
  15.                         var thumbPos = thumbRight.cachedTransform.localPosition + thumb.cachedTransform.localPosition ;
  16.  
  17.                         slider.width = (int)thumbPos.x;
  18.                         scrollView.UpdateScrollbars(true);
  19. }


ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Scrollview and scrollbar blues
« Reply #1 on: March 12, 2014, 09:59:55 PM »
Hiding of scroll bars is an option on the scroll view.

The scroll bar updates as expected for me. As you resize the content of the scroll view you aren't resetting the position of the scrolling itself, so the content becomes smaller while the position of the scroll view remains in one place, therefore the scroll bar shrinks accordingly. Your scroll view's position becomes outside the scroll view's area.

wallabie

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 200
    • View Profile
Re: Scrollview and scrollbar blues
« Reply #2 on: March 12, 2014, 11:30:31 PM »
Thanks,

I added UpdatePosition after the updateScrollbars and it works.

scrollView.UpdateScrollbars(true);
scrollView.UpdatePosition();