Browse Source

Performance for smooth-scrollbar

master
Loëck Vézien 7 years ago
parent
commit
1f79ea2bcb
No known key found for this signature in database GPG Key ID: CBCDCE384E853AC4
  1. 8
      src/components/base/GrowScroll/index.js
  2. 6
      src/components/base/GrowScroll/stories.js

8
src/components/base/GrowScroll/index.js

@ -34,11 +34,15 @@ class GrowScroll extends PureComponent<Props> {
const minY = offsetLimit.y.min
if (offset.y > maxY) {
this.scrollTo(offset.x, maxY)
this.setPosition(offset.x, maxY, {
withoutCallbacks: true,
})
}
if (offset.y < minY) {
this.scrollTo(offset.x, minY)
this.setPosition(offset.x, minY, {
withoutCallbacks: true,
})
}
}
})

6
src/components/base/GrowScroll/stories.js

@ -7,7 +7,9 @@ import GrowScroll from 'components/base/GrowScroll'
const stories = storiesOf('GrowScroll', module)
stories.add('basic', () => (
<Box style={{ height: 400, border: '1px solid black' }}>
<GrowScroll>{[...Array(1000).keys()].map(v => <div key={v}>{v}</div>)}</GrowScroll>
<Box style={{ border: '1px solid black' }}>
<GrowScroll maxHeight={400}>
{[...Array(1000).keys()].map(v => <div key={v}>{v}</div>)}
</GrowScroll>
</Box>
))

Loading…
Cancel
Save