MCPcopy Create free account
hub / github.com/ElemeFE/element-react / render

Method render

src/scrollbar/Scrollbar.jsx:76–137  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

74 }
75
76 render() {
77
78 /* eslint-disable */
79 let {
80 native, viewStyle, wrapStyle, viewClass, children, viewComponent, wrapClass, noresize,
81 className, ...others} = this.props;
82 let {moveX, moveY, sizeWidth, sizeHeight} = this.state;
83 /* eslint-enable */
84
85 let style = wrapStyle;
86 const gutter = getScrollBarWidth();
87 if (gutter) {
88 const gutterWith = `-${gutter}px`;
89 if (Array.isArray(wrapStyle)){
90 style = Object.assign.apply(null, [...wrapStyle, {marginRight: gutterWith, marginBottom: gutterWith}])
91 } else {
92 style = Object.assign({}, wrapStyle, {marginRight: gutterWith, marginBottom: gutterWith})
93 }
94 }
95
96 const view = React.createElement(viewComponent, {
97 className: this.classNames('el-scrollbar__view', viewClass),
98 style: viewStyle,
99 ref: 'resize'
100 }, children);
101
102 let nodes;
103 if (!native){
104 const wrap = (
105 <div
106 {...others}
107 ref="wrap"
108 key={0}
109 style={style}
110 onScroll={this.handleScroll.bind(this)}
111 className={this.classNames(wrapClass, 'el-scrollbar__wrap', gutter ? '' : 'el-scrollbar__wrap--hidden-default')}
112 >
113 {view}
114 </div>
115 )
116 nodes = [
117 wrap,
118 <Bar key={1} move={moveX} size={sizeWidth} getParentWrap={()=>this.wrap}></Bar>,
119 <Bar key={2} move={moveY} size={sizeHeight} getParentWrap={()=>this.wrap} vertical={true}></Bar>,
120 ]
121 }else {
122 nodes = [
123 (
124 <div
125 {...others}
126 key={0}
127 ref="wrap"
128 className={this.classNames(wrapClass, 'el-scrollbar__wrap')}
129 style={style}>
130 {view}
131 </div>
132 )
133 ]

Callers

nothing calls this directly

Calls 2

getScrollBarWidthFunction · 0.90
classNamesMethod · 0.80

Tested by

no test coverage detected