remove mixin on Libraries/Components/ScrollResponder.js (#21589)
Summary: Related to #21485. Removed Subscribable.Mixin from the Libraries/Components/ScrollResponder.js - [x] npm run prettier - [x] npm run flow-check-ios - [x] npm run flow-check-android [GENERAL] [ENHANCEMENT] [Libraries/Components/ScrollResponder.js] - remove Subscribable.Mixin dependency Pull Request resolved: https://github.com/facebook/react-native/pull/21589 Differential Revision: D10275517 Pulled By: RSNara fbshipit-source-id: 28af7f0944e978609a1b3be05b8a51557e67bc1b
This commit is contained in:
parent
780ced4d07
commit
9965ea5a2e
|
@ -14,7 +14,6 @@ const Dimensions = require('Dimensions');
|
|||
const FrameRateLogger = require('FrameRateLogger');
|
||||
const Keyboard = require('Keyboard');
|
||||
const ReactNative = require('ReactNative');
|
||||
const Subscribable = require('Subscribable');
|
||||
const TextInputState = require('TextInputState');
|
||||
const UIManager = require('UIManager');
|
||||
|
||||
|
@ -25,6 +24,8 @@ const warning = require('fbjs/lib/warning');
|
|||
|
||||
const {ScrollViewManager} = require('NativeModules');
|
||||
|
||||
import type EmitterSubscription from 'EmitterSubscription';
|
||||
|
||||
/**
|
||||
* Mixin that can be integrated in order to handle scrolling that plays well
|
||||
* with `ResponderEventPlugin`. Integrate with your platform specific scroll
|
||||
|
@ -115,7 +116,10 @@ type State = {
|
|||
type Event = Object;
|
||||
|
||||
const ScrollResponderMixin = {
|
||||
mixins: [Subscribable.Mixin],
|
||||
_subscriptionKeyboardWillShow: (null: ?EmitterSubscription),
|
||||
_subscriptionKeyboardWillHide: (null: ?EmitterSubscription),
|
||||
_subscriptionKeyboardDidShow: (null: ?EmitterSubscription),
|
||||
_subscriptionKeyboardDidHide: (null: ?EmitterSubscription),
|
||||
scrollResponderMixinGetInitialState: function(): State {
|
||||
return {
|
||||
isTouching: false,
|
||||
|
@ -602,28 +606,39 @@ const ScrollResponderMixin = {
|
|||
|
||||
this.keyboardWillOpenTo = null;
|
||||
this.additionalScrollOffset = 0;
|
||||
this.addListenerOn(
|
||||
Keyboard,
|
||||
this._subscriptionKeyboardWillShow = Keyboard.addListener(
|
||||
'keyboardWillShow',
|
||||
this.scrollResponderKeyboardWillShow,
|
||||
);
|
||||
this.addListenerOn(
|
||||
Keyboard,
|
||||
this._subscriptionKeyboardWillHide = Keyboard.addListener(
|
||||
'keyboardWillHide',
|
||||
this.scrollResponderKeyboardWillHide,
|
||||
);
|
||||
this.addListenerOn(
|
||||
Keyboard,
|
||||
this._subscriptionKeyboardDidShow = Keyboard.addListener(
|
||||
'keyboardDidShow',
|
||||
this.scrollResponderKeyboardDidShow,
|
||||
);
|
||||
this.addListenerOn(
|
||||
Keyboard,
|
||||
this._subscriptionKeyboardDidHide = Keyboard.addListener(
|
||||
'keyboardDidHide',
|
||||
this.scrollResponderKeyboardDidHide,
|
||||
);
|
||||
},
|
||||
|
||||
componentWillUnmount: function() {
|
||||
if (this._subscriptionKeyboardWillShow != null) {
|
||||
this._subscriptionKeyboardWillShow.remove();
|
||||
}
|
||||
if (this._subscriptionKeyboardWillHide != null) {
|
||||
this._subscriptionKeyboardWillHide.remove();
|
||||
}
|
||||
if (this._subscriptionKeyboardDidShow != null) {
|
||||
this._subscriptionKeyboardDidShow.remove();
|
||||
}
|
||||
if (this._subscriptionKeyboardDidHide != null) {
|
||||
this._subscriptionKeyboardDidHide.remove();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Warning, this may be called several times for a single keyboard opening.
|
||||
* It's best to store the information in this method and then take any action
|
||||
|
|
Loading…
Reference in New Issue