facebook / fresco

An Android library for managing images and the memory they use.
https://frescolib.org/
MIT License
17.07k stars 3.75k forks source link

PagerView with Zoomed image in ZoomableDraweeView not scrolling to next image #1015

Closed rafaelekol closed 6 years ago

rafaelekol commented 8 years ago

I am using PagerView with images showed in ZoomableDraweeView. When image not zoomed it scrolls to next without problem, but when I zoom the image its not scrolling to the next image.

aagnes-zz commented 8 years ago

Can you tell which version of the fresco library are you using? The behavior you're describing is the default one. I need to know your version of use to suggest how you can overwrite the controller or the view to achieve you goal.

rafaelekol commented 8 years ago

Fresco version is latest, 0.9.0

aagnes-zz commented 8 years ago

In ZDV, you can see

  @Override
  public boolean onTouchEvent(MotionEvent event) {
    if (mZoomableController.onTouchEvent(event)) {
      if (mZoomableController.getScaleFactor() > 1.0f) {
        getParent().requestDisallowInterceptTouchEvent(true);
      }
      FLog.v(TAG, "onTouchEvent: view %x, handled by zoomable controller", this.hashCode());
      return true;
    }
    FLog.v(TAG, "onTouchEvent: view %x, handled by the super", this.hashCode());
    return super.onTouchEvent(event);
  }

which disallow you to scroll to the previous or next page if zoom happened. So to achieve your goal, you'll need to subclass ZDV and override the onTouchEvent.

rafaelekol commented 8 years ago

Thank you for help. It scrolls now zoomed image immediately. But I need scrolling only when image border reached. How can I accomplish this?

aagnes-zz commented 8 years ago

I actually don't understand what do you mean by "enable scroll only when image border reached". I suppose if you wanna enable scroll in limited occasions, you need to implement under onTouchEvent, and disallow scrolling by using getParent().requestDisallowInterceptTouchEvent(true); when in the occasions you define.

rafaelekol commented 8 years ago

For example I zoomed image, and now I am see middle of zoomed image. Then I try to drag zoomed image to left to see left side of the image, but instead of dragging, it scrolls to next image. Thus I need to enable scrolling to next image only in case when my zoomed image reached its left or right border(end of the image). How I can check this?

plamenko commented 8 years ago

Yeah, I understand what you mean. This is on our TODO list, but it is not the top-priority thing we have on our plate at the moment and therefore we can not promise when will this be implemented.

rafaelekol commented 8 years ago

OK, noted

plamenko commented 8 years ago

I actually found some time and sent a pull request. ZoomableDraweeView should work just fine in ViewPager.

oprisnik commented 6 years ago

This should have been fixed already, take a look at the sample app here: https://github.com/facebook/fresco/tree/master/samples/zoomableapp There's even a toggle now to select what behaviour you want: swipe to next image when zoomed or stay at current image.