Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit c1a6993

Browse files
jlo1gitim
authored andcommitted
Stretch row so child items fill container list (#67)
1 parent c3a1170 commit c1a6993

File tree

2 files changed

+14
-13
lines changed

2 files changed

+14
-13
lines changed

‎src/Row.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,12 +153,16 @@ export default class Row extends Component {
153153
}
154154

155155
render() {
156-
const {children, style} = this.props;
156+
const {children, style, horizontal} = this.props;
157+
const rowStyle = [
158+
style, styles.container, this._animatedLocation.getLayout(),
159+
horizontal ? styles.horizontalContainer : styles.verticalContainer,
160+
];
157161

158162
return (
159163
<Animated.View
160164
{...this._panResponder.panHandlers}
161-
style={[style,styles.container,this._animatedLocation.getLayout()]}
165+
style={rowStyle}
162166
onLayout={this._onLayout}>
163167
{children}
164168
</Animated.View>
@@ -231,4 +235,12 @@ const styles = StyleSheet.create({
231235
container: {
232236
position: 'absolute',
233237
},
238+
horizontalContainer: {
239+
top: 0,
240+
bottom: 0,
241+
},
242+
verticalContainer: {
243+
left: 0,
244+
right: 0,
245+
},
234246
});

‎src/SortableList.js

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -209,15 +209,6 @@ export default class SortableList extends Component {
209209
const {horizontal, rowActivationTime, sortingEnabled, renderRow} = this.props;
210210
const {animated, order, data, activeRowKey, releasedRowKey, rowsLayouts} = this.state;
211211

212-
let rowHeight = 0;
213-
let rowWidth = 0;
214-
215-
if (rowsLayouts) {
216-
Object.keys(rowsLayouts).forEach((key) => {
217-
rowHeight = Math.max(rowHeight, rowsLayouts[key].height);
218-
rowWidth = Math.max(rowWidth, rowsLayouts[key].width);
219-
});
220-
}
221212

222213
let nextX = 0;
223214
let nextY = 0;
@@ -228,11 +219,9 @@ export default class SortableList extends Component {
228219

229220
if (rowsLayouts) {
230221
if (horizontal) {
231-
style.height = rowHeight;
232222
location.x = nextX;
233223
nextX += rowsLayouts[key].width;
234224
} else {
235-
style.width = rowWidth;
236225
location.y = nextY;
237226
nextY += rowsLayouts[key].height;
238227
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /