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

[tvOS] onPress animation with magnification #15455

Closed
wants to merge 18 commits into from

Conversation

JulienKode
Copy link
Contributor

@JulienKode JulienKode commented Aug 10, 2017

Related to: #15454

Motivation: Improve tvOS feeling for TouchableHighlight

This is a new behaviour proposal with animation based on tvParallaxProperties :

changewithaniamtion

  • When you select the button he is focus and the underlay is show
  • When you press the button, there is an animation, but after the animation, the focus is on the button and the underlay is show

Test Plan

Play with tvParallaxProperties on tvOS, test with and without patch just to see the actual behaviour

			<TouchableHighlight
						tvParallaxProperties={{
							enabled: true,
							shiftDistanceX: 0,
							shiftDistanceY: 0,
							tiltAngle: 0,
							magnification: 1.1,
                                                        pressMagnification: 1.0,
							pressDuration: 0.3,
						}}
						underlayColor="black"
						onShowUnderlay={() => (console.log("onShowUnderlay")}
						onHideUnderlay={() =>  (console.log("onHideUnderlay")}
						onPress={() =>  (console.log("onPress")}
					>
						<Image
							style={styles.image}
							source={ uri: 'https://www.facebook.com/images/fb_icon_325x325.png' }
						/>
					</TouchableHighlight>

@facebook-github-bot facebook-github-bot added GH Review: review-needed CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. labels Aug 10, 2017
@pull-bot
Copy link

pull-bot commented Aug 10, 2017

Warnings
⚠️

📋 Release Notes - This PR appears to be missing Release Notes.

@facebook-github-bot label Needs more information

Attention: @shergin

Generated by 🚫 dangerJS

@shergin
Copy link
Contributor

shergin commented Aug 10, 2017

cc @dlowder-salesforce

@douglowder
Copy link
Contributor

This is a nice idea. Two suggestions:

  1. Enable this on other touchables, e.g. TouchableOpacity
  2. Maybe have a separate magnification property for the press, like pressMagnification. The developer may not want magnification for the focus animation, but may want it for the press action.

@JulienKode
Copy link
Contributor Author

JulienKode commented Aug 11, 2017

@dlowder-salesforce Thanks for you answer 👍

I have added pressMagnification property
We can use it with TouchableOpacity

tvparallaxproperties

@douglowder
Copy link
Contributor

@JulienKode thanks very much, I'll take another look at this today or tomorrow. Be advised that there is another PR in flight (#15561) that affects the same files, so once that is committed, please merge from upstream.

@douglowder
Copy link
Contributor

Having a look now -- I made a branch from latest master that includes your changes, and trying this out to see how everything is working. https://github.com/dlowder-salesforce/react-native/tree/julien-kode-patch-3

@JulienKode
Copy link
Contributor Author

@dlowder-salesforce Sorry for the time, I've apply your changes to the branch and I've update the test plan,

The test plan looks good to you ?

@douglowder
Copy link
Contributor

Test plan is ok.

NSInteger headersContentLength = headers[@"Content-Length"] != nil ? [headers[@"Content-Length"] integerValue] : 0;
=======
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please back out the changes to this file -- it's not related to your new feature and I think the issue with this file has already been fixed separately by someone else.

@JulienKode
Copy link
Contributor Author

@dlowder-salesforce Sorry for my mistake, I have solve it

@douglowder
Copy link
Contributor

@JulienKode I'm working on a modal bugfix, then I will get back to looking at this 👍

@JulienKode
Copy link
Contributor Author

I should make the changes on TouchableNativeFeedback?

Because the fact that TouchableHighlight have a strange behavior on tvOS (for a Button), it does not make it pleasant to use

May be I'm wrong

@hramos
Copy link
Contributor

hramos commented Nov 15, 2017

If we fixed TouchableNativeFeedback, can we ask people to use it on tvOS instead of TouchableHighlight?

@douglowder
Copy link
Contributor

I'm looking at @JulienKode 's changes again.... the way it's implemented, these are just part of tvParallaxProperties object, so they should work for any Touchable. Yes it would probably make sense to enable TouchableNativeFeedback for Apple TV, and these properties should be added to all the Touchable components (including TouchableHighlight and TouchableOpacity).

@JulienKode
Copy link
Contributor Author

@dlowder-salesforce You're right 👍

@douglowder
Copy link
Contributor

@shergin or @hramos could you please go ahead and import this... I'll take an action item to work with @JulienKode on a separate PR to add the new properties to other Touchable components.

@shergin
Copy link
Contributor

shergin commented Nov 30, 2017

Can we start from fixing code style issues?

@JulienKode
Copy link
Contributor Author

@shergin What is the part that need for you to be fix ?

@pull-bot
Copy link

pull-bot commented Jan 4, 2018

Warnings
⚠️

📋 Release Notes - This PR appears to be missing Release Notes.

@facebook-github-bot label Needs more information

Attention: @shergin

Generated by 🚫 dangerJS

@JulienKode
Copy link
Contributor Author

Any update ?

@@ -39,6 +39,9 @@ var TVViewPropTypes = {
* shiftDistanceY: Defaults to 2.0.
* tiltAngle: Defaults to 0.05.
* magnification: Defaults to 1.0.
* pressMagnification: Defaults to 1.0.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's document these in https://github.com/facebook/react-native-website as well, since those are the docs that are displayed on the website itself.

Copy link
Contributor Author

@JulienKode JulienKode Feb 2, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the information @hramos I've created a pull request here facebook/react-native-website#176

@@ -174,6 +175,9 @@ const TouchableHighlight = createReactClass({
* shiftDistanceY: Defaults to 2.0.
* tiltAngle: Defaults to 0.05.
* magnification: Defaults to 1.0.
* pressMagnification: Defaults to 1.0.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto. These will need to be copied over to the react-native-website repo as well.

@facebook-github-bot facebook-github-bot added the Import Started This pull request has been imported. This does not imply the PR has been approved. label Feb 2, 2018
Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hramos is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@JulienKode
Copy link
Contributor Author

@hramos Thanks for the review I've added the new properties to the docs facebook/react-native-website#176

@facebook-github-bot facebook-github-bot added cla signed and removed Import Started This pull request has been imported. This does not imply the PR has been approved. labels Feb 3, 2018
@facebook-github-bot
Copy link
Contributor

I tried to merge this pull request into the Facebook internal repo but some checks failed. To unblock yourself please check the following: Does this pull request pass all open source tests on GitHub? If not please fix those. Does the code still apply cleanly on top of GitHub master? If not can please rebase. In all other cases this means some internal test failed, for example a part of a fb app won't work with this pull request. I've added the Import Failed label to this pull request so it is easy for someone at fb to find the pull request and check what failed. If you don't see anyone comment in a few days feel free to comment mentioning one of the core contributors to the project so they get a notification.

@hramos
Copy link
Contributor

hramos commented Feb 27, 2018

This PR should land soon. I had to rebase the PR internally. Once tests finish running, I'll merge it.

@JulienKode
Copy link
Contributor Author

@hramos Thank you

vincentriemer pushed a commit to vincentriemer/react-native-dom that referenced this pull request Mar 6, 2018
Summary:
Related to: #15454

Motivation: Improve tvOS feeling for TouchableHighlight

![changewithaniamtion](https://user-images.githubusercontent.com/7658664/29193477-b99b4a10-7e25-11e7-8b31-e0e4ca9d7720.gif)

- When you select the button he is focus and the underlay is show
- When you press the button, there is an animation, but after the animation, the focus is on the button and the underlay is show

Play with tvParallaxProperties on tvOS, test with and without patch just to see the actual behaviour
```
			<TouchableHighlight
						tvParallaxProperties={{
							enabled: true,
							shiftDistanceX: 0,
							shiftDistanceY: 0,
							tiltAngle: 0,
							magnification: 1.1,
                                                        pressMagnification: 1.0,
							pressDuration: 0.3,
						}}
						underlayColor="black"
						onShowUnderlay={() => (console.log("onShowUnderlay")}
						onHideUnderlay={() =>  (console.log("onHideUnderlay")}
						onPress={() =>  (console.log("onPress")}
					>
						<Image
							style={styles.image}
							source={ uri: 'https://www.facebook.com/images/fb_icon_325x325.png' }
						/>
					</TouchableHighlight>
```
Closes facebook/react-native#15455

Differential Revision: D6887437

Pulled By: hramos

fbshipit-source-id: e18b695068bc99643ba4006fb3f39215b38a74c1
@hramos hramos added the Merged This PR has been merged. label Mar 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Merged This PR has been merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants