crn-cli
Version:
The Ctrip React Native CLI Tools
1 lines • 5.15 kB
JavaScript
__d(function(g,r,i,a,m,e,d){'use strict';var t=r(d[0]),n=r(d[1]),o=r(d[2]),l=r(d[3]),c=r(d[4]),s=r(d[5]),u=(r(d[6]),r(d[7])),h=r(d[8]),p=h.ScrollView,f=h.StyleSheet,E=h.Text,y=h.TouchableOpacity,b=h.View,w=h.Image;e.displayName='ScrollViewExample',e.title='<ScrollView>',e.description='Component that enables scrolling through child components',e.examples=[{title:'<ScrollView>\n',description:'To make content scrollable, wrap it within a <ScrollView> component',render:function(){var t;return u.createElement(b,null,u.createElement(p,{ref:function(n){t=n},automaticallyAdjustContentInsets:!1,onScroll:function(){},scrollEventThrottle:200,style:T.scrollView},V.map(v)),u.createElement(P,{label:"Scroll to top",onPress:function(){t.scrollTo({y:0})}}),u.createElement(P,{label:"Scroll to bottom",onPress:function(){t.scrollToEnd({animated:!0})}}),u.createElement(P,{label:"Flash scroll indicators",onPress:function(){t.flashScrollIndicators()}}))}},{title:'<ScrollView> (horizontal = true)\n',description:"You can display <ScrollView>'s child components horizontally rather than vertically",render:function(){function t(t,n){var o;return u.createElement(b,{style:n},u.createElement(E,{style:T.text},t),u.createElement(p,{ref:function(t){o=t},automaticallyAdjustContentInsets:!1,horizontal:!0,style:[T.scrollView,T.horizontalScrollView]},V.map(v)),u.createElement(P,{label:"Scroll to start",onPress:function(){o.scrollTo({x:0})}}),u.createElement(P,{label:"Scroll to end",onPress:function(){o.scrollToEnd({animated:!0})}}),u.createElement(P,{label:"Flash scroll indicators",onPress:function(){o.flashScrollIndicators()}}))}return u.createElement(b,null,t('LTR layout',{direction:'ltr'}),t('RTL layout',{direction:'rtl'}))}}],e.examples.push({title:'<ScrollView> smooth bi-directional content loading\n',description:"The `maintainVisibleContentPosition` prop allows insertions to either end of the content without causing the visible content to jump. Re-ordering is not supported.",render:function(){var h=6,f=(function(f){function E(){var o,s;n(this,E);for(var p=arguments.length,f=new Array(p),y=0;y<p;y++)f[y]=arguments[y];return(s=l(this,(o=c(E)).call.apply(o,[this].concat(f)))).state={items:t(Array(h)).map(function(t,n){return u.createElement(S,{msg:"Item "+n})})},s}return s(E,f),o(E,[{key:"render",value:function(){var t=this;return u.createElement(b,null,u.createElement(p,{automaticallyAdjustContentInsets:!1,maintainVisibleContentPosition:{minIndexForVisible:1,autoscrollToTopThreshold:10},style:T.scrollView},this.state.items.map(function(t){return u.cloneElement(t,{key:t.props.msg})})),u.createElement(p,{horizontal:!0,automaticallyAdjustContentInsets:!1,maintainVisibleContentPosition:{minIndexForVisible:1,autoscrollToTopThreshold:10},style:[T.scrollView,T.horizontalScrollView]},this.state.items.map(function(t){return u.cloneElement(t,{key:t.props.msg,style:null})})),u.createElement(b,{style:T.row},u.createElement(P,{label:"Add to top",onPress:function(){t.setState(function(t){var n=h++;return{items:[u.createElement(S,{style:{paddingTop:5*n},msg:"Item "+n})].concat(t.items)}})}}),u.createElement(P,{label:"Remove top",onPress:function(){t.setState(function(t){return{items:t.items.slice(1)}})}}),u.createElement(P,{label:"Change height top",onPress:function(){t.setState(function(t){return{items:[u.cloneElement(t.items[0],{style:{paddingBottom:40*Math.random()}})].concat(t.items.slice(1))}})}})),u.createElement(b,{style:T.row},u.createElement(P,{label:"Add to end",onPress:function(){t.setState(function(t){return{items:t.items.concat(u.createElement(S,{msg:"Item "+h++}))}})}}),u.createElement(P,{label:"Remove end",onPress:function(){t.setState(function(t){return{items:t.items.slice(0,-1)}})}}),u.createElement(P,{label:"Change height end",onPress:function(){t.setState(function(t){return{items:t.items.slice(0,-1).concat(u.cloneElement(t.items[t.items.length-1],{style:{paddingBottom:40*Math.random()}}))}})}})))}}]),E})(u.Component);return u.createElement(f,null)}});var S=(function(t){function h(){return n(this,h),l(this,c(h).apply(this,arguments))}return s(h,t),o(h,[{key:"render",value:function(){var t=this.props.source;return u.createElement(b,{style:[T.thumb,this.props.style]},u.createElement(w,{style:T.img,source:null==t?V[6]:t}),u.createElement(E,null,this.props.msg))}}]),h})(u.PureComponent),V=[r(d[9]),r(d[10]),r(d[11]),r(d[12]),r(d[13]),r(d[14]),r(d[15]),r(d[16]),r(d[17]),r(d[18]),r(d[19]),r(d[20])];V=V.concat(V);var v=function(t,n){return u.createElement(S,{key:n,source:t})},P=function(t){var n=t.label,o=t.onPress;return u.createElement(y,{style:T.button,onPress:o},u.createElement(E,null,n))},T=f.create({scrollView:{backgroundColor:'#eeeeee',height:300},horizontalScrollView:{height:106},text:{fontSize:16,fontWeight:'bold',margin:5},button:{margin:5,padding:5,alignItems:'center',backgroundColor:'#cccccc',borderRadius:3},row:{flexDirection:'row',justifyContent:'space-around'},thumb:{margin:5,padding:5,backgroundColor:'#cccccc',borderRadius:3,minWidth:96},img:{width:64,height:64}})},666727,[30,3,4,5,8,9,53,11,15,666691,666692,666693,666694,666695,666696,666697,666698,666699,666700,666701,666702]);