diff options
author | Thibaut Girka <thib@sitedethib.com> | 2018-10-20 19:28:54 +0200 |
---|---|---|
committer | ThibG <thib@sitedethib.com> | 2018-10-21 16:09:07 +0200 |
commit | dfa5b0576f4f212153a3da7ef53d4c58b53ed4c2 (patch) | |
tree | afca4662dd969bad119275d7dce15794bdd31ebd /app/javascript | |
parent | e4c3ea1809cc81ee0c2617957f93d095bf174d19 (diff) |
Update mediaGallery component's width when opening CWs
Diffstat (limited to 'app/javascript')
-rw-r--r-- | app/javascript/flavours/glitch/components/media_gallery.js | 10 | ||||
-rw-r--r-- | app/javascript/flavours/glitch/components/status.js | 1 |
2 files changed, 11 insertions, 0 deletions
diff --git a/app/javascript/flavours/glitch/components/media_gallery.js b/app/javascript/flavours/glitch/components/media_gallery.js index 613318102..e8dfd6f8e 100644 --- a/app/javascript/flavours/glitch/components/media_gallery.js +++ b/app/javascript/flavours/glitch/components/media_gallery.js @@ -215,6 +215,7 @@ export default class MediaGallery extends React.PureComponent { standalone: PropTypes.bool, letterbox: PropTypes.bool, fullwidth: PropTypes.bool, + hidden: PropTypes.bool, media: ImmutablePropTypes.list.isRequired, size: PropTypes.object, onOpenMedia: PropTypes.func.isRequired, @@ -235,6 +236,14 @@ export default class MediaGallery extends React.PureComponent { } } + componentDidUpdate (prevProps) { + if (this.node && this.node.offsetWidth) { + this.setState({ + width: this.node.offsetWidth, + }); + } + } + handleOpen = () => { this.setState({ visible: !this.state.visible }); } @@ -244,6 +253,7 @@ export default class MediaGallery extends React.PureComponent { } handleRef = (node) => { + this.node = node; if (node /*&& this.isStandaloneEligible()*/) { // offsetWidth triggers a layout, so only calculate when we need to this.setState({ diff --git a/app/javascript/flavours/glitch/components/status.js b/app/javascript/flavours/glitch/components/status.js index 665aa457a..449532ea4 100644 --- a/app/javascript/flavours/glitch/components/status.js +++ b/app/javascript/flavours/glitch/components/status.js @@ -465,6 +465,7 @@ export default class Status extends ImmutablePureComponent { sensitive={status.get('sensitive')} letterbox={settings.getIn(['media', 'letterbox'])} fullwidth={settings.getIn(['media', 'fullwidth'])} + hidden={isCollapsed || !isExpanded} onOpenMedia={this.props.onOpenMedia} /> )} |