Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

onpress emit in error area when view use transform #235

Open
smallnewer opened this issue Mar 19, 2019 · 4 comments
Open

onpress emit in error area when view use transform #235

smallnewer opened this issue Mar 19, 2019 · 4 comments
Labels

Comments

@smallnewer
Copy link

smallnewer commented Mar 19, 2019

Is this a bug report?

yes

Have you read the Contributing Guidelines?

yes

Environment

Environment:
OS: macOS High Sierra 10.13.6
Node: 8.3.0
Yarn: 1.12.3
npm: 5.3.0
Watchman: 4.9.0
Xcode: Xcode 10.1 Build version 10B61
Android Studio: Not Found

Packages: (wanted => installed)
react: 16.2.0 => 16.2.0
react-native: Not Found

Target Platform: macos

Steps to Reproduce

  1. init a project use react-native-macos init xxx
  2. run js code below (click red area and move it to left 10px)
  3. click lower half of red area,not work.

ScreenFlow

Expected Behavior

emit click in [100,300] of y.

Actual Behavior

emit click in [0, 200] of y.

code

class Demo extends React.Component {
    constructor(props){
        super(props);

        this.state = {
            left: 100,
        };
    }
    render() {
        return (
            <TouchableOpacity 
                onPress={()=> this.setState({left: this.state.left+10})}
                style={{position:"absolute", right:this.state.left,width:200,height:200,transform:[{translateY:100}],backgroundColor:"red"}}>
            </TouchableOpacity>
        );
    }
}
@aleclarson
Copy link
Collaborator

#228 might fix this for you. You'll need to replace NSWindow usage with RCTWindow.

@aleclarson aleclarson added the bug label Mar 19, 2019
@smallnewer
Copy link
Author

228 dos't work.😒
I change the hitTest method of RCTView,It can work for my demo now, but I think it also has some bugs. -.-
hope for your help.

- (NSView *)hitTest:(CGPoint)point
{

  if ([self isHidden])
  {
    return nil;
  }

  NSPoint p = [self.layer convertPoint: point fromLayer: [self superview].layer];
  for (NSView *subView in [[self subviews] reverseObjectEnumerator]) {
    if (![subView isHidden]) {
      NSView *v = [subView hitTest:p];
      if (v) {
        return v;
      }
    }
  }
  
  if ([self mouse:point inRect:self.layer.frame]) {
    return self;
  }
  return nil;
}

@aleclarson
Copy link
Collaborator

There's definitely a bug in #228 that I'll be looking into sometime soon.

@aleclarson
Copy link
Collaborator

Just pushed some patches to #228. Lemme know if it works for you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants