schovi/react-iscroll

horizontal scroll: no autosize

Closed this issue · 3 comments

scrollerStyle={{width: '200%'}} will give me a horizonal scrollbar (see issue #4). But how to auto-size the width? What if my content is wider/smaller than 200%?

I have same problem.
I have workaround for init scroll. I use the componentDidMount, where i get my scroll content scrollWidth and set this value to state. This state go to scrollerStyle. For example scrollerStyle={{width: this.state.width}}

But if content dinamic (f.e. list of elements) need use componentDidUpdate and forceUpdate methods of the scroll component. But this point i didn't check.

So, i added detect scroll content scrollWidth in to componentDidUpdate method. And this work for me, even for any dinamic data. But React write warnings to console '%ComponentName% is accessing getDOMNode or findDOMNode inside its render(). render() should be a pure function of props and state. It should never access something that requires stale data from the previous render, such as refs. Move this logic to componentDidMount and componentDidUpdate instead.'

But another soutions this problem i don't see at this moment.
Do you have any ideas?

Hi guys (and sorry for ignoring for long time).

With update to react-iscroll@1.0.0+ I remove styling of content wrapper. That means you dont style content via IScroll component properties, but directly on child elements ecd75bb

Is this something that will help you? Give me echo if not and I will think about better solution.