ascoders / react-native-image-viewer

🚀 tiny & fast lib for react native image viewer pan and zoom
MIT License
2.44k stars 581 forks source link

RTL support #66

Open Den368 opened 7 years ago

Den368 commented 7 years ago

Steps to produce:

  1. Change the phone language to Hebrew / Arabic
  2. Swipe the image
  3. The application is stuck
AlirezaAkbarix commented 6 years ago

Actually it's enough to call I18nManager.forceRTL(true); and face above problem! I see there is no comment since Aug 1 17!!! Doesn't this lib maintain anymore??

ascoders commented 6 years ago

Hello @AlirezaAkbarix , I am sorry to have been delayed for so long. I am not familiar with this question, can this problem be solved through add I18nManager.forceRTL(true) to project source?

It seems that this code should not be added to the library directly.

AlirezaAkbarix commented 6 years ago

Hi @ascoders! No, I mean for testing the bug, you're not suppose to do a lot! just at your test app use I18nManager.forceRTL(true) to make it RTL. then make sure you have more than 1 image to show.

The problem will appear! you can see you have 2(e.g.) images and the first one is been showing correctly, but you are not able to switch to next one (it's placed al the left of the first one).

ascoders commented 6 years ago

Thanks @AlirezaAkbarix ! I solved this problem in 2.2.1.

noambonnie commented 6 years ago

@ascoders - There is still one issue with RTL - if I set the index to anything that is not 0 it will not show the image.

To fix it, change jumpToCurrentImage() as follows:

  public jumpToCurrentImage() {
    // 跳到当前图的位置
    this.positionXNumber = this.width * (this.state.currentShowIndex || 0) * (I18nManager.isRTL? 1 : -1);
    this.standardPositionX = this.positionXNumber;
    this.positionX.setValue(this.positionXNumber);
  }

The first line changed. If it is RTL we don't make it negative. From what I tested this works for me.

Will you be able to make the change? If you prefer I can create a pull request.

ascoders commented 6 years ago

@noambonnie Look forward your pr!

noambonnie commented 6 years ago

@ascoders PR sent. Thank you. (Also sent another PR to remove a log message...)