React-native-gesture-handler: 子で覆われたBaseButtonリップル `<image/> `

作成日 2019年04月01日  ·  3コメント  ·  ソース: software-mansion/react-native-gesture-handler

問題:

BaseButtonリップルは、子としてのテキストでは正常に機能しますが、画像では機能しません。

再現するには:

<BaseButton style={{height: 150, width: 100}}>
   <Image source={...} style={{width: 100, height: 100}}/>
</BaseButton>

"react-native-gesture-handler": "^ 1.0.16"、
"react": "16.8.3"、
"react-native": "0.59.1"、

テスト済みデバイス:Samsung Galaxy S6、Android 7.0

Android Bug

最も参考になるコメント

これが、RNのTouchableNativeFeedbackコンポーネントにuseForeground小道具がある理由です。 RNGHの3つのボタンコンポーネントは、この動作を模倣する必要があります。

ところで、「絶対充填」の回避策は私にはうまくいきません。

全てのコメント3件

絶対塗りつぶしを回避策として使用し、絶対塗りつぶしを使用してビューとスタイルボタンでボタンと画像を折り返すことができます。ところで、rippleColorも指定する必要があります。そうしないと、奇妙な動作が発生します。

これが、RNのTouchableNativeFeedbackコンポーネントにuseForeground小道具がある理由です。 RNGHの3つのボタンコンポーネントは、この動作を模倣する必要があります。

ところで、「絶対充填」の回避策は私にはうまくいきません。

Ripple.jsをラップします

import React from 'react';
import { View, StyleSheet } from 'react-native';
import { RectButton } from 'react-native-gesture-handler';

const styles = StyleSheet.create({
  box: {
    position: 'relative',
  },
  ripple: {
    position: 'absolute',
    left: 0,
    top: 0,
    width: '100%',
    height: '100%',
    zIndex: 1,
  },
});

export default ({ style, children, ...props }) => {
  return (
    <View style={[style, styles.box]}>
      {children}
      <RectButton rippleColor="#888" style={styles.ripple} {...props} />
    </View>
  );
};
このページは役に立ちましたか?
0 / 5 - 0 評価

関連する問題

nguyenhose picture nguyenhose  ·  4コメント

brentvatne picture brentvatne  ·  4コメント

brunolemos picture brunolemos  ·  3コメント

TerrerSandman picture TerrerSandman  ·  3コメント

rgangopadhya picture rgangopadhya  ·  4コメント