npmtest-react-native-web (v0.0.1)

Code coverage report for node-npmtest-react-native-web/node_modules/react-native-web/dist/components/ScrollView/index.js

Statements: 37.08% (33 / 89)      Branches: 10% (5 / 50)      Functions: 6.25% (1 / 16)      Lines: 31.58% (18 / 57)      Ignored: none     

All files » node-npmtest-react-native-web/node_modules/react-native-web/dist/components/ScrollView/ » index.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 2481               1 1 1 1 1 1 1 1 1 1 1 1 12   1     1                                                                                                                                                                                                                                                                                                                                                                                                               1                                         1  
var _extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};
 
 
 
 
 
 
 
var _createReactClass=require('create-react-class');var _createReactClass2=_interopRequireDefault(_createReactClass);
var _dismissKeyboard=require('../../modules/dismissKeyboard');var _dismissKeyboard2=_interopRequireDefault(_dismissKeyboard);
var _findNodeHandle=require('../../modules/findNodeHandle');var _findNodeHandle2=_interopRequireDefault(_findNodeHandle);
var _invariant=require('fbjs/lib/invariant');var _invariant2=_interopRequireDefault(_invariant);
var _ScrollResponder=require('../../modules/ScrollResponder');var _ScrollResponder2=_interopRequireDefault(_ScrollResponder);
var _ScrollViewBase=require('./ScrollViewBase');var _ScrollViewBase2=_interopRequireDefault(_ScrollViewBase);
var _StyleSheet=require('../../apis/StyleSheet');var _StyleSheet2=_interopRequireDefault(_StyleSheet);
var _StyleSheetPropType=require('../../propTypes/StyleSheetPropType');var _StyleSheetPropType2=_interopRequireDefault(_StyleSheetPropType);
var _View=require('../View');var _View2=_interopRequireDefault(_View);
var _ViewPropTypes=require('../View/ViewPropTypes');var _ViewPropTypes2=_interopRequireDefault(_ViewPropTypes);
var _ViewStylePropTypes=require('../View/ViewStylePropTypes');var _ViewStylePropTypes2=_interopRequireDefault(_ViewStylePropTypes);
var _react=require('react');var _react2=_interopRequireDefault(_react);
var _propTypes=require('prop-types');function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};}function _objectWithoutProperties(obj,keys){var target={};for(var i in obj){if(keys.indexOf(i)>=0)continue;if(!Object.prototype.hasOwnProperty.call(obj,i))continue;target[i]=obj[i];}return target;}
 
var emptyObject={};
 
 
var ScrollView=(0,_createReactClass2.default)({
propTypes:_extends({},_ViewPropTypes2.default,{
 
contentContainerStyle:(0,_StyleSheetPropType2.default)(_ViewStylePropTypes2.default),
horizontal:_propTypes.bool,
keyboardDismissMode:(0,_propTypes.oneOf)(['none','interactive','on-drag']),
onContentSizeChange:_propTypes.func,
onScroll:_propTypes.func,
pagingEnabled:_propTypes.bool,
refreshControl:_propTypes.element,
scrollEnabled:_propTypes.bool,
scrollEventThrottle:_propTypes.number,
style:(0,_StyleSheetPropType2.default)(_ViewStylePropTypes2.default)}),
 
 
mixins:[_ScrollResponder2.default.Mixin],
 
getInitialState:function getInitialState(){
return this.scrollResponderMixinGetInitialState();
},
 
setNativeProps:function setNativeProps(props){
this._scrollViewRef.setNativeProps(props);
},
 
 
 
 
 
 
 
getScrollResponder:function getScrollResponder(){
return this;
},
 
getScrollableNode:function getScrollableNode(){
return(0,_findNodeHandle2.default)(this._scrollViewRef);
},
 
getInnerViewNode:function getInnerViewNode(){
return(0,_findNodeHandle2.default)(this._innerViewRef);
},
 
 
 
 
 
 
 
 
 
 
 
scrollTo:function scrollTo(
y,
x,
animated)
{
if(typeof y==='number'){
console.warn(
'`scrollTo(y, x, animated)` is deprecated. Use `scrollTo({x: 5, y: 5, animated: true})` instead.');
 
}else{var _ref=
y||emptyObject;x=_ref.x;y=_ref.y;animated=_ref.animated;
}
 
this.getScrollResponder().scrollResponderScrollTo({
x:x||0,
y:y||0,
animated:animated!==false});
 
},
 
 
 
 
scrollWithoutAnimationTo:function scrollWithoutAnimationTo(){var y=arguments.length>0&&arguments[0]!==undefined?arguments[0]:0;var x=arguments.length>1&&arguments[1]!==undefined?arguments[1]:0;
console.warn('`scrollWithoutAnimationTo` is deprecated. Use `scrollTo` instead');
this.scrollTo({x:x,y:y,animated:false});
},
 
render:function render(){var _props=
 
 
 
 
 
 
 
 
 
 
 
this.props,contentContainerStyle=_props.contentContainerStyle,horizontal=_props.horizontal,onContentSizeChange=_props.onContentSizeChange,refreshControl=_props.refreshControl,keyboardDismissMode=_props.keyboardDismissMode,onScroll=_props.onScroll,pagingEnabled=_props.pagingEnabled,other=_objectWithoutProperties(_props,['contentContainerStyle','horizontal','onContentSizeChange','refreshControl','keyboardDismissMode','onScroll','pagingEnabled']);
 
if(process.env.NODE_ENV!=='production'&&this.props.style){
var style=_StyleSheet2.default.flatten(this.props.style);
var childLayoutProps=['alignItems','justifyContent'].filter(
function(prop){return style&&style[prop]!==undefined;});
 
(0,_invariant2.default)(
childLayoutProps.length===0,
'ScrollView child layout ('+JSON.stringify(childLayoutProps)+') '+
'must be applied through the contentContainerStyle prop.');
 
}
 
var contentSizeChangeProps={};
if(onContentSizeChange){
contentSizeChangeProps={
onLayout:this._handleContentOnLayout};
 
}
 
var contentContainer=
_react2.default.createElement(_View2.default,_extends({},
contentSizeChangeProps,{
children:this.props.children,
collapsable:false,
ref:this._setInnerViewRef,
style:[horizontal&&styles.contentContainerHorizontal,contentContainerStyle]}));
 
 
 
var props=_extends({},
other,{
style:[styles.base,horizontal&&styles.baseHorizontal,this.props.style],
onTouchStart:this.scrollResponderHandleTouchStart,
onTouchMove:this.scrollResponderHandleTouchMove,
onTouchEnd:this.scrollResponderHandleTouchEnd,
onScrollBeginDrag:this.scrollResponderHandleScrollBeginDrag,
onScrollEndDrag:this.scrollResponderHandleScrollEndDrag,
onMomentumScrollBegin:this.scrollResponderHandleMomentumScrollBegin,
onMomentumScrollEnd:this.scrollResponderHandleMomentumScrollEnd,
onStartShouldSetResponder:this.scrollResponderHandleStartShouldSetResponder,
onStartShouldSetResponderCapture:this.scrollResponderHandleStartShouldSetResponderCapture,
onScrollShouldSetResponder:this.scrollResponderHandleScrollShouldSetResponder,
onScroll:this._handleScroll,
onResponderGrant:this.scrollResponderHandleResponderGrant,
onResponderTerminationRequest:this.scrollResponderHandleTerminationRequest,
onResponderTerminate:this.scrollResponderHandleTerminate,
onResponderRelease:this.scrollResponderHandleResponderRelease,
onResponderReject:this.scrollResponderHandleResponderReject});
 
 
var ScrollViewClass=_ScrollViewBase2.default;
 
(0,_invariant2.default)(ScrollViewClass!==undefined,'ScrollViewClass must not be undefined');
 
if(refreshControl){
return _react2.default.cloneElement(
refreshControl,
{style:props.style},
_react2.default.createElement(ScrollViewClass,_extends({},props,{ref:this._setScrollViewRef,style:styles.base}),
contentContainer));
 
 
}
 
return(
_react2.default.createElement(ScrollViewClass,_extends({},props,{ref:this._setScrollViewRef,style:props.style}),
contentContainer));
 
 
},
 
_handleContentOnLayout:function _handleContentOnLayout(e){var _e$nativeEvent$layout=
e.nativeEvent.layout,width=_e$nativeEvent$layout.width,height=_e$nativeEvent$layout.height;
this.props.onContentSizeChange(width,height);
},
 
_handleScroll:function _handleScroll(e){
if(process.env.NODE_ENV!=='production'){
if(this.props.onScroll&&!this.props.scrollEventThrottle){
console.log(
'You specified `onScroll` on a <ScrollView> but not '+
'`scrollEventThrottle`. You will only receive one event. '+
'Using `16` you get all the events but be aware that it may '+
"cause frame drops, use a bigger number if you don't need as "+
'much precision.');
 
}
}
 
if(this.props.keyboardDismissMode==='on-drag'){
(0,_dismissKeyboard2.default)();
}
 
this.scrollResponderHandleScroll(e);
},
 
_setInnerViewRef:function _setInnerViewRef(component){
this._innerViewRef=component;
},
 
_setScrollViewRef:function _setScrollViewRef(component){
this._scrollViewRef=component;
}});
 
 
var styles=_StyleSheet2.default.create({
base:{
flex:1,
overflowX:'hidden',
overflowY:'auto',
WebkitOverflowScrolling:'touch',
 
 
 
transform:[{translateZ:0}]},
 
baseHorizontal:{
flexDirection:'row',
overflowX:'auto',
overflowY:'hidden'},
 
contentContainerHorizontal:{
flexDirection:'row'}});
 
 
 
module.exports=ScrollView;