Commit Graph

78 Commits

Author SHA1 Message Date
Samuel Susla c5f8c31435 Implement View.removeClippedSubviews prop
Summary:
Changelog: [internal]

Fabric didn't have prop [removeClippedSubviews](https://reactnative.dev/docs/view#removeclippedsubviews) implemented. This diff adds it. It is

Reviewed By: JoshuaGross

Differential Revision: D29906458

fbshipit-source-id: 5851fa41d7facea9aab73ca131b4a0d23a2411ea
2021-07-27 03:04:15 -07:00
Samuel Susla 7b1e6f5077 Remove gating for on demand view mounting
Summary:
Changelog: [internal]

This feature has shipped. I remove gating here.

Reviewed By: mdvacca

Differential Revision: D29906460

fbshipit-source-id: 23433cfd4d618633b135d8c858ce6cf90cfe9fa1
2021-07-26 14:23:05 -07:00
Justin Huntington bc1e602e0c Add ScrollView.automaticallyAdjustsScrollIndicatorInsets prop (on iOS) (#29809)
Summary:
iOS 13 added a new property to `UIScrollView`: `automaticallyAdjustsScrollIndicatorInsets`, which is `YES` by default.  The property changes the meaning of the `scrollIndicatorInsets` property.  When `YES`, any such insets are **in addition to** whatever insets would be applied by the device's safe area.  When `NO`, the iOS <13 behavior is restored, which is for such insets to not account for safe area.

In other words, this effects ScrollViews that underlay the device's safe area (i.e. under the notch).  When `YES`, the OS "automatically" insets the scroll indicators, when `NO` it does not.

There are two problems with the default `YES` setting:

1. It means applying `scrollIndicatorInsets` to a `ScrollView` has a different effect on iOS 13 versus iOS 12.
2. It limits developers' control over `scrollIndicatorInsets`.  Since negative insets are not supported, if the insets the OS chooses are too large for your app, you cannot fix it.

Further explanation & sample code is available in issue https://github.com/facebook/react-native/issues/28140 .

This change sets the default for this property to `NO`, making the behavior consistent across iOS versions, and allowing developers full control.

## Changelog

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://github.com/facebook/react-native/wiki/Changelog
-->

[iOS] [Changed] - ScrollView scrollIndicatorInsets to not automatically add safe area on iOS13+

Pull Request resolved: https://github.com/facebook/react-native/pull/29809

Test Plan:
Updated the RNTester example to explain what to expect. Also removed the `pageScreen` modal example for now as mentioned in my Github comment.

{F628636466}

Here are screenshots of the demo app (from the original bug) before (with safe area applied to insets) & after (without safe area applied to insets):

![before](https://user-images.githubusercontent.com/428831/91644197-ea03a700-ea07-11ea-9489-be27820930eb.png)

![after](https://user-images.githubusercontent.com/428831/91644200-eff98800-ea07-11ea-8788-daf1e783639d.png)

Reviewed By: p-sun

Differential Revision: D28229603

Pulled By: lunaleaps

fbshipit-source-id: 2e774ae150b1dc41680b8b7886c7ceac8808136a
2021-07-07 20:23:36 -07:00
Samuel Susla 3bce393766 Clean up enable_state_scroll_data_race_ios experiment
Summary:
Changelog: [internal]

Clean up the experiment.

Reviewed By: JoshuaGross

Differential Revision: D29547129

fbshipit-source-id: 08ecbf5d362385b9d287348c7a4a508ca24a42bf
2021-07-05 14:14:47 -07:00
Samuel Susla fa3697bd9e Back out "Add option to disable sending scroll events to Paper"
Summary:
Changelog: [internal]

Original commit changeset: fa4d8944ad6b

Not sending onScroll events events to Paper has no effect.

Reviewed By: mdvacca

Differential Revision: D29229662

fbshipit-source-id: b84a2614bfd42c64ca67ca6a1cd9d0a815c11ad0
2021-06-23 02:02:03 -07:00
Samuel Susla 9ca460f064 Take RTL into account in scrollTo view command
Summary:
Changelog: [internal]

ScrollView's `scrollTo` command doesn't work in RTL. It sets the offset from left of the screen instead of right. This diff fixes this for Fabric only.

Reviewed By: JoshuaGross

Differential Revision: D29164056

fbshipit-source-id: f685d3e013f474f9b445112333d8f5ad7ed36ea7
2021-06-16 11:04:13 -07:00
Samuel Susla 0ee8e292a4 Fix for ScrollView race condition between C++ state update and onScroll
Summary:
Changelog: [internal]

There is a possibility of race between updating scrollview's state and virtualised list asking for layout of individual cells.
To make sure the race doesn't happen, state must be updated before dispatching onScroll event.

Android has implemented a different mechanism to tackle this issue in D28558380 (https://github.com/facebook/react-native/commit/b161241db2ef74d2e4bff36d4972f5f0312dcc44).

Reviewed By: JoshuaGross

Differential Revision: D28642737

fbshipit-source-id: 33874beac69fc5a66eeb7f459fd89cd0b00dafcf
2021-05-26 03:32:03 -07:00
Samuel Susla 4bec099f7e Add option to disable sending scroll events to Paper
Summary:
Changelog: [internal]

Originally added in D17814260 (https://github.com/facebook/react-native/commit/ffc7ec992c66417039b0fa14f1afd54a9cd2f882) to make parallax effect work in Dating.

This diff hides it behind a flag so we can properly evaluate what's the cost of sending scroll events to Paper.

Reviewed By: JoshuaGross

Differential Revision: D28608283

fbshipit-source-id: fa4d8944ad6b5e767363e231942f13fec9d18cb5
2021-05-22 12:19:05 -07:00
Samuel Susla e173bbe3bb Fix on demand mounting in RTL
Summary:
Changelog: [internal]

When calculating on demand views, RTL layout needs to be considered.

Reviewed By: JoshuaGross

Differential Revision: D28510293

fbshipit-source-id: 5e7b08fcc5c55fa1a978024a9bfedda705ce1702
2021-05-18 10:02:19 -07:00
Samuel Susla e5921f7f38 Fix horizontal scrolling in RTL scripts
Summary:
Changelog: [internal]

Fabric's scrollView now supports horizontal scroll view.

Reviewed By: JoshuaGross

Differential Revision: D26608231

fbshipit-source-id: 176a7802fa580247d12657e08780805daacd8357
2021-02-24 06:29:51 -08:00
Valentin Shergin fc24bb4af0 Fabric: Support for setIsJSResponder, all the native changes
Summary:
This is a Fabric-compliant implementation of `JSResponder` feature. To make it work e2e we also need to update FabricRenderer in React repository. But before we can do this, we need to ship the native changes.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: mdvacca

Differential Revision: D24630027

fbshipit-source-id: 70c30e1250b554d83862956b536714704093072f
2021-02-04 13:16:29 -08:00
Valentin Shergin 92da2c1779 Fabric: Fixed <ScrollView> jumps during overscroll gesture
Summary:
Normally, UIScrollView adjust `contentOffset` inside `setContentSize` to prevent over-scroll. In most cases, it works fine but in a case when the ScrollView is in the middle of user interaction the over-scroll is perfectly acceptable. So, to work around this issue we disable `setContentOffset` when we update `contentSize` and the gesture interaction is in progress.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D26001133

fbshipit-source-id: 19b67289b2c142facd4f516a740180c87f90bc2d
2021-01-22 08:53:45 -08:00
Samuel Susla 768ecc2906 Implement ScrollView.indicatorStyle
Summary: Changelog: [internal]

Differential Revision: D25996218

fbshipit-source-id: 38b521b0ac52635a2c6341450592e6dd27be00f4
2021-01-21 09:59:40 -08:00
Samuel Susla fa728b27e6 Implement ScrollView.scrollIndicatorInsets
Summary: Changelog: [internal]

Reviewed By: shergin

Differential Revision: D25996025

fbshipit-source-id: 3528914af278dcbe522e247660b8afc19628eb6e
2021-01-21 09:59:40 -08:00
Valentin Shergin f379b1e583 Fabric: Shipping updateStateWithAutorepeat as the only way to update a state
Summary:
This replaces the internal core implementation of `setState` with the new `updateStateWithAutorepeat` which is now the only option.
In short, `updateStateWithAutorepeat` works as `setState` with the following features:
* The state update might be performed several times until it succeeds.
* The callback is being called on every retry with actual previous data provided (can be different on every call).
* In case of a static value is provided (simple case, not lambda, the only case on Android for now), the same *new*/provided value will be used for all state updates. In this case, the state update cannot fail.
* If a callback is provided, the update operation can be canceled via returning `nullptr` from the callback.

This diff removes all mentions of the previous state update approach from the core; some other leftovers will be removed separatly.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D25695600

fbshipit-source-id: 14b3d4bad7ee69e024a9b0b9fc018f7d58bf060c
2020-12-23 21:49:44 -08:00
Valentin Shergin 016905333a Back out "Use ConcreteStateTeller in RCTScrollViewComponentView"
Summary:
ConcreteStateTeller is being replaced with a new built-in state autorepeat mechanism.

Original commit changeset: 8c777ae1264c

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D25687695

fbshipit-source-id: 334cb6c7497270c040e4aec262a30441bc7529ce
2020-12-23 10:09:24 -08:00
Samuel Susla 19d4cc2d49 Implement ScrollView.zoomToRect
Summary: Changelog: [internal]

Reviewed By: JoshuaGross

Differential Revision: D24991008

fbshipit-source-id: 6048246a784b94a321281547d966379badd8f6fd
2020-11-18 15:32:30 -08:00
Samuel Susla 3a0ed2e551 Implement zoom in ScrollView
Summary: changelog: [internal]

Reviewed By: JoshuaGross

Differential Revision: D24991161

fbshipit-source-id: 6f36cc21b89554006a744da8d32349ff21ccd68f
2020-11-17 11:16:42 -08:00
Valentin Shergin 97d6f2e6a9 Fabric: touchesShouldCancelInContentView now always returns YES
Summary:
Historically, `UIScrollView`s in React Native do not cancel touches started on `UIControl`-based views (as normal iOS `UIScrollView`s do).
This diff implements this behavior.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: JoshuaGross

Differential Revision: D24661106

fbshipit-source-id: 1fb98d62f9e1528f11e7699d460aaefcec534e97
2020-10-31 16:23:29 -07:00
Samuel Susla 0217c14a11 Implement ScrollView.keyboardDismissMode
Summary: Changelog: [internal]

Reviewed By: shergin

Differential Revision: D24648120

fbshipit-source-id: 718be95dc87217fa6745535a3760ec23cc390444
2020-10-30 08:51:33 -07:00
Samuel Susla 07d090dbc6 Implement ScrollView.scrollToOverflowEnabled
Summary:
Changelog: [internal]

Add missing implementation of [scrollToOverflowEnabled](https://reactnative.dev/docs/scrollview#scrolltooverflowenabled).

Reviewed By: JoshuaGross

Differential Revision: D24536893

fbshipit-source-id: a540b9b5b302404cc0a431f666bba269da849c50
2020-10-28 06:44:38 -07:00
Samuel Susla e75a0dc265 Force scroll event inside scrollViewDidEndScrollingAnimation and scrollTo
Summary:
Changelog: [internal]

`onScroll` event needs to be fired when scroll view ends the scrolling animation and when scrollTo is called.
This is how Paper does it and client code might depend on it.

Reviewed By: JoshuaGross

Differential Revision: D24527189

fbshipit-source-id: bdec099f16b3d8c97686975a1f769db4d2c0d832
2020-10-24 12:02:08 -07:00
Samuel Susla 1d1cbc93c2 Prevent ScrollTo view command from scrolling outside of content view
Summary:
Changelog: [internal]

ScrollTo command needs to clamp the value in order to not scroll out of content view of scroll view. Paper does the same thing.

Reviewed By: JoshuaGross

Differential Revision: D24526992

fbshipit-source-id: 47c48ecb01f4ae40791306016dd7847079263128
2020-10-24 12:02:07 -07:00
Valentin Shergin c42183817d Fixed incorrect assert in RCTScrollViewComponentView
Summary:
This diff removes an incorrect assert and replaces it with a debug-only verification phase that compares "what we want" with "what we get".

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: PeteTheHeat

Differential Revision: D23983123

fbshipit-source-id: 03a628b4f8baa1f5fe4b55354b7c943e38b5e537
2020-09-30 19:24:18 -07:00
Samuel Susla ca091b009a Use ConcreteStateTeller in RCTScrollViewComponentView
Summary: Changelog: [Internal]

Reviewed By: JoshuaGross

Differential Revision: D23238812

fbshipit-source-id: 8c777ae1264cfade507bfd336eefbe86ffb94b8f
2020-08-24 06:43:18 -07:00
Samuel Susla c429ee9974 Implement ScrollView.contentInsetAdjustmentBehavior
Summary:
Changelog: [internal]

Fabric's ScrollView was ignoring value of `ScrollView.contentInsetAdjustmentBehavior`, this diff fixes that.

Reviewed By: shergin

Differential Revision: D23102235

fbshipit-source-id: 8cf42e730b560a21d56d7e007059109ccd01154e
2020-08-13 10:11:46 -07:00
Valentin Shergin b2570bd74d Removing dispatch_async-delayed TTRC reporting for Fabric TTRC tracker (gated)
Summary:
This diff introduces a new experiment touching performance measuring infra.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: JoshuaGross

Differential Revision: D23071089

fbshipit-source-id: 22e6f34754956311bd6a0140fe2accd5758d87c7
2020-08-12 12:12:47 -07:00
Samuel Susla c452b826df Implement ScrollView.snapToOffsets and associated props
Summary:
Changelog: [Internal]
Implementation is copied from Paper.

Reviewed By: shergin

Differential Revision: D22820677

fbshipit-source-id: 8eed7ecd4dc766e8579a89707849e041adb073eb
2020-08-03 07:08:29 -07:00
Samuel Susla 94d0078653 Implement ScrollView.snapToInterval and associated props
Summary:
Changelog: [Internal]

Implementation is copied from Paper.

Reviewed By: shergin

Differential Revision: D22794554

fbshipit-source-id: ccfa777356932d81aa986349fba1685acf65d7f1
2020-08-03 07:08:29 -07:00
David Vacca 3093010ea5 move fabric to ReactCommon/react/renderer
Summary:
This diff moves fabric C++ code from ReactCommon/fabric to ReactCommon/react/renderer
As part of this diff I also refactored components, codegen and callsites on CatalystApp, FB4A and venice

Script: P137350694

changelog: [internal] internal refactor

Reviewed By: fkgozali

Differential Revision: D22852139

fbshipit-source-id: f85310ba858b6afd81abfd9cbe6d70b28eca7415
2020-07-31 13:34:29 -07:00
Valentin Shergin 4716d2282e Fabric: Fixes in computing visible frame in RCTScrollViewComponentView
Summary:
This refined algorithm now takes a zoom/scale into account and deals with `contentInset` properly.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D22382482

fbshipit-source-id: 7e9d34d3bababf68e624c045c308957e7e5c9d84
2020-07-04 15:25:43 -07:00
Samuel Susla 42c8dead62 Restore contentOffset from state if necesarry
Summary:
Changelog: [Internal]

When JS Inspector is activated, ScrollView is unmounted and then mounted again with same state.

 ScrollView's content offset was being set to 0 inside `[RCTScrollViewComponentView prepareForRecycle]` during unmount but when it is mounted again, we ignored value inside state.

Reviewed By: shergin

Differential Revision: D22333125

fbshipit-source-id: f232dc95b695605f4819f29d8e0bf14b2f3e9150
2020-07-03 11:15:26 -07:00
Valentin Shergin 8320ad37f2 Fabric: Using overflowInset in on-demain view mounting in <ScrollView>
Summary:
Now we can use `overflowInset` to check if the view's descendants overflow.

```
  ┌ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┐
   A cell w/o overflow content
  │                           │

  └ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┘
  ┌───────────────────────────┐                 ┌───────────────────────────┐
  │A cell w/ overflow content │                 │A cell w/ overflow content │
  │             ┌───────────┐ │   <━━━━━━━━━>   │             ┌───────────┐ │
  │             │A thing    │ │                 │             │A thing    │ │
  └─────────────┤that       ├─┘                 └─────────────┤that       ├─┘
  ┌ ─ ─ ─ ─ ─ ─ ┤overflows  ├ ┐                 Inset ********│overflows  │**
                │ended up   │                   Overflow******│ended up   │**
  │             │being      │ │                 **************│being      │**
                │visible.   │                   **************│visible.   │**
  └ ─ ─ ─ ─ ─ ─ ┤           ├ ┘                 **************│           │**
  ┌─────────────┤           ├─┐                 **************│           │**
  │             │           │ │                 **************│           │**
  │             │           │ │                 **************│           │**
╔═│             │           │ │═╗             ╔═**************│           │**═╗
║ └─────────────┤           ├─┘ ║             ║ **************│           │** ║
║ ┌─────────────┤           ├─┐ ║             ║ **************│           │** ║
║ │             │           │ │ ║             ║ **************│           │** ║
║ │             │           │ │ ║             ║ **************│           │** ║
║ │             └───────────┘ │ ║             ║ **************└───────────┘** ║
║ └───────────────────────────┘ ║             ║                               ║
║ ┌───────────────────────────┐ ║             ║                               ║
║ │                           │ ║             ║                               ║
║ │                           │ ║             ║                               ║
║ │                           │ ║             ║                               ║
║ └───────────────────────────┘ ║             ║                               ║
║ ┌───────────────────────────┐ ║             ║                               ║
║ │                           │ ║             ║                               ║
║ │                           │ ║             ║                               ║
║ │                           │ ║             ║                               ║
║ └───────────────────────────┘ ║             ║                               ║
║ ┌───────────────────────────┐ ║             ║                               ║
║ │                           │ ║             ║                               ║
║ │                           │ ║             ║                               ║
║ │                           │ ║             ║                               ║
║ └───────────────────────────┘ ║             ║                               ║
║ ┌───────────────────────────┐ ║             ║                               ║
║ │                           │ ║             ║                               ║
║ │                           │ ║             ║                               ║
╚═│                           │═╝             ╚═══════════════════════════════╝
  └───────────────────────────┘
  ┌ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┐

  │                           │

  └ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┘
  ┌ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┐

  │                           │

  └ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┘
```

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D22325808

fbshipit-source-id: e80ae196fc9158358a67c6706b0a2ddec6d47ee9
2020-07-01 18:25:14 -07:00
Valentin Shergin 9a72702b44 Fabric: On-demand view mounting for <ScrollView>
Summary:
This is the first implementation stage of on-demand child views mounting for <ScrollView> feature.

It works this way. When mounting layer requests mounting of a subview of <ScrollView>, the component does not mount it immediately. Instead, it stores it in an internal collection, and then after the transaction finishes use that to mount views that are in a visible area.
Then we re-evaluate which child views are should be mounted and unmounted on every significant onScroll event. We use some leeway to do it not so often to save CPU cycles on scrolling.

This feature already works fine but to make it shippable we need to integrate it with an `overflow inset` feature to make it 100% reliable in complex cases when some views have overflow content.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D22304012

fbshipit-source-id: be4ae21378d9d1c457cad2826da7d8c8d6395be5
2020-07-01 18:25:14 -07:00
Samuel Susla 060250dcb0 Add support for ScrollView.contentOffset
Summary:
Changelog: [Internal]

Fabric's scrollview didn't have `contentOffset` implemented.

Reviewed By: JoshuaGross

Differential Revision: D21573179

fbshipit-source-id: 258c1cfa3398336f74d7ab033d90edcec7095292
2020-05-14 11:52:05 -07:00
Samuel Susla cd0e4ecd7b Fix scrollView state contentOffset not being in sync with scrollView contentOffset
Summary:
Changelog: [Internal]

# Problem
`scrollView.state.contentOffset` was not in sync with actual `contentOffset` in case `contentOffset` is changed programatically.

# Solution
Add a flag `_isUserTriggeredScrolling` that indicates whether the current scroll is triggered by user or not. In case it isn't, update state.

Reviewed By: shergin

Differential Revision: D20098161

fbshipit-source-id: 021d916e7a45a24095a47bb8f84d1102226b672a
2020-03-10 12:47:20 -07:00
Valentin Shergin c89ead313c Fabric: Proper implementation of ScrollView::contentOffset-aware measure functions (iOS only for now)
Summary:
This diff re-enables propagation of ScrollView's content-offset value down to the ShadowTree layer and enables measure fucntions opt-in incorporating this info to result.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: zackargyle

Differential Revision: D18981891

fbshipit-source-id: a6c0f4e690703b0ee07d45efab161750cfcc4b60
2019-12-18 10:48:40 -08:00
Valentin Shergin 2e864c176c Fabric: Fixing a crash in UIScrollView on deallocation
Summary:
UIScrollView sometimes calls its delegate during its own deallocation and that causes a crash. This change introducing nil-ing the delegate before the deallocation to prevent this.

We already had this implemented in  D17924429 but D18752886 broke that. This diff fixes that one more time.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D18933934

fbshipit-source-id: 8da22ff4b1fefee712ced25cf0f1c239535554da
2019-12-11 09:56:00 -08:00
Samuel Susla 0bbe3205ca Use plugins for RCTScrollViewComponentView
Summary:
Use plugin architecture for `RCTScrollViewComponentView`

Changelog: [Internal]

Reviewed By: shergin

Differential Revision: D18743825

fbshipit-source-id: d25162252d2dc4ac6ee67d48394b4dfa9ad134cb
2019-12-06 10:51:17 -08:00
Valentin Shergin f697836cfa Fabric: Disabling ScrollView's contentOffset propagation to ShadowNode tree
Summary:
This diff disables the feature that propagates ScrollView's content offset to ShadowNode hierarchy making measuring content-offset-aware.
Seems that feature breaks FlatList because it does not expect measure calls to be content-offset-aware. We need to validate which legacy `measure*` calls should be content-offset-aware and which should not, and then verify that actual feature works (it's not clear why it worked with FlatList before) well before re-enabling this.

For now, the most safer choice is to disable this feature because I don't think some call sites actually rely on it now.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D18777939

fbshipit-source-id: 20d6c1081e7d2cc3b5a7a172ed947a9ae9cdfaab
2019-12-03 08:12:13 -08:00
Valentin Shergin a69c18cfbc Fabric: Moving ScrollView's delegate splitter to RCTEnhancedScrollView
Summary:
This diff moves the delegate splitter from RCTScrollViewComponentView class to RCTEnhancedScrollView. Now, it's a key feature of RCTEnhancedScrollView.
We need this to make `delegate` property of our UIScrollView subclass as resilient to any abuse as possible. E.g., if some other part of the app, unrelated to RN (e.g. BottomSheet component), nils the property, all dependent RN specific infra should continue to work. To make it possible, we make an exposed property to use the internal delegate splitter instead of providing direct access to the property of a superclass.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D18752886

fbshipit-source-id: 04ec4758afefb8e17481d69471d53c61ab396698
2019-11-30 12:31:42 -08:00
Valentin Shergin 59e8bd9560 Fabric: ScrollViewComponentView: Calling onScrollEndDrag in scrollViewDidEndDragging:
Summary:
* Previously we called `onScrollEndDrag` in `scrollViewWillEndDragging` which was not correct.
* Now we also call `_updateStateWithContentOffset` in the method to update the stored in state `contentOffset`. This fixes all `measure*` infra.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D18563050

fbshipit-source-id: ade696eda579642c22927c8a56ff122cd61a7534
2019-11-17 10:45:27 -08:00
Samuel Susla 8f607a7967 Fabric: add native commands support to ScrollView
Summary:
ScrollView isn't using codegen, therefore we need to manually write commands interface. I also typed commands so it uses `Double` instead of `number`.

Changelog: [Internal]

Reviewed By: TheSavior

Differential Revision: D18371887

fbshipit-source-id: 3bd11b9969b80ce6d2302e2f0da28884e9221b7e
2019-11-10 17:19:00 -08:00
Andres Suarez 3b31e69e28 Tidy up license headers [2/n]
Summary: Changelog: [General] [Fixed] - License header cleanup

Reviewed By: yungsters

Differential Revision: D17952694

fbshipit-source-id: 17c87de7ebb271fa2ac8d00af72a4d1addef8bd0
2019-10-16 10:06:34 -07:00
Valentin Shergin e7ef9921d3 Fabric: Fixing crash in RCTScrollViewComponentView (2nd attempt)
Summary:
Seems a ScrollView sometimes calls the delegate in own destructor; and seems that in some configurations the delegate is also already destroyed at this point. I am not sure if this a bug in UIKit or not, but seems the fix is easy, we just have to clear the ScrollView's delegate on the delegate's deallocation.
This issue is also looks similar:
https://stackoverflow.com/questions/18778691/crash-on-exc-breakpoint-scroll-view/19011871

Changelog: [iOS] [Fixed] - Fixed crash in RCTScrollViewComponentView

Reviewed By: sammy-SC

Differential Revision: D17924429

fbshipit-source-id: 5727bca9f028e28f76f60304c187ee39eb6e1856
2019-10-15 07:43:20 -07:00
Samuel Susla ffc7ec992c Add support for ScrollView.onScroll animations
Summary: To enable onScroll animations with Fabric's scrollView on iOS, we dispatch onScroll event to Paper's eventDispatcher as well as to Fabric's one. One we have a proper NativeAnimationDriver in place, we will get rid of this.

Reviewed By: shergin

Differential Revision: D17814260

fbshipit-source-id: f04faf59cdfd4ea5cede513388e30500b4cb2ad5
2019-10-11 06:55:21 -07:00
Samuel Susla 4159e20146 Fix throttling in scroll view
Summary:
Setting minimal throttle to 1/60 causes dropped updates.

Let's take following example

Each frame is 16.666 MS.

Frame1: [________didScroll is called towards end of the frame_]

Frame2: [_didScroll is called towards beginning of the frame_________]

update from Frame 2 doesn't propagate because we set throttle to 16MS thinking that `onScroll` is called for each frame.

If Javascript specified value below 1/60 it is basically asking for every update.

Reviewed By: shergin, mdvacca

Differential Revision: D17829926

fbshipit-source-id: e7b07fd09581cd5053aa27a62cf6f6ddb2193783
2019-10-11 05:44:49 -07:00
Samuel Susla 3f9af02bd5 Call _state.reset in prepareForRecycle
Summary: `_state` should be cleaned up in `prepareForRecycle` as this could potentially cause undesired initial render of the component.

Reviewed By: shergin

Differential Revision: D17628152

fbshipit-source-id: 0116954ab7a5b2f17099db6d9ec47c8568cae8b0
2019-09-30 04:47:25 -07:00
Valentin Shergin a35a3ec157 Fabric: Fixing a crash in ScrollView on deallocation
Summary:
Seems a ScrollView sometimes calls the delegate in own destructor; and seems that in some configurations the delegate is also already destroyed at this point. I am not sure if this a bug in UIKit or not, but seems the fix is easy, we just have to clear the ScrollView's delegate on the delegate's deallocation.
This issue is also looks similar:
https://stackoverflow.com/questions/18778691/crash-on-exc-breakpoint-scroll-view/19011871

Reviewed By: sammy-SC

Differential Revision: D17531071

fbshipit-source-id: 373ae5270199f3a9099bda8c34b06737446858f1
2019-09-28 15:10:26 -07:00
Valentin Shergin 59c3d05058 Fabric: Support for <ScrollView scrollEventThrottle={...}> on iOS
Summary: This diff adds support from `ScrollView::scrollEventThrottle` property on iOS.

Reviewed By: JoshuaGross

Differential Revision: D17000397

fbshipit-source-id: 93f23919a6a2588000c0eeca869171d1036348b6
2019-08-26 21:01:46 -07:00