ptmt / react-native-macos

[deprecated in favor of https://microsoft.github.io/react-native-windows/] React Native for macOS is an experimental fork for writing desktop apps using Cocoa
MIT License
11.25k stars 429 forks source link

UIExplorer: transforms not working with position #232

Open smallnewer opened 5 years ago

smallnewer commented 5 years ago

Is this a bug report?

yes

Have you read the Contributing Guidelines?

yes

Environment

OS: macOS Sierra 10.13.6 (I only have this version) UIExplorer: downloaded in v0.5.0 tag and here

and i can reproduce this question with : react-native-macos-cli: 2.0.1 react-native-macos: 0.19.2

Steps to Reproduce

gif

Some Prerequisites

  1. position:absolute with right
  2. any transform
  3. resize the window
aleclarson commented 5 years ago

This will be fixed when #234 is merged.

smallnewer commented 5 years ago

Thanks^_^ It's also not working with #234 . Maybe I did something wrong?

My steps

  1. download code from https://github.com/ptmt/react-native-macos/tree/fa28701469188d2b757af84934e13014dacbed9d, which is last commit in #234
  2. delete node_modules/react-native-macos/React in my demo project,and copy React(downloaded) to my demo project
  3. build and run ,transform also not working after resize the window。

I'm sure it's #234 code.

key codes:

    render() {
        return (
            <TouchableOpacity 
                style={{position:"absolute", right:100,width:200,height:200,transform:[{translateY:101}],backgroundColor:"red"}}>     
            </TouchableOpacity>
        )
    }
smallnewer commented 5 years ago

After I delete some code at RCTView.m,It working right:

//  if (!CGSizeEqualToSize(self.bounds.size, oldSize)) {
    [self.layer setNeedsDisplay];
//  }

I don't know if it's appropriate to make such a change.

aleclarson commented 5 years ago

Nice find!

When the frame is updated (eg: by resizing the window), the transform needs to be reapplied.

I've added a new commit to #234, which you should try and let me know if it works. https://github.com/ptmt/react-native-macos/pull/234/commits/572a27491206a1bdc62fd108fccefc4b8a7b4b37

If it doesn't work, we can call [self.layer setNeedsDisplay] when _transform is not an identity transform.

smallnewer commented 5 years ago

It works right . Thanks @aleclarson ! 👍