| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- import React from 'react'
- import uiStores from 'stores/ui'
- import JengaExtra from '../extra/JengaExtra'
- import JengaItem from './JengaItem'
- const minWidth = 858 // 最小宽度
- export default class JengaPanel extends React.Component {
- constructor(props) {
- super(props)
- this.jengaContent = React.createRef()
- this.onUiChange = this.onUiChange.bind(this)
- this.setWidth = this.setWidth.bind(this)
- }
- componentDidMount() {
- this.setWidth(uiStores.jengaViewWidthDelta)
- this.unsubscribe = uiStores.listen(this.onUiChange)
- }
- componentWillUnmount() {
- this.unsubscribe()
- }
- onUiChange(status) {
- if (status && status.types) {
- if (status.types.includes('changeJengaViewWidthDelta')) {
- this.setWidth(status.data.jengaViewWidthDelta)
- }
- }
- }
- setWidth(delta) {
- if (this.jengaContent && this.jengaContent.current) {
- this.jengaContent.current.style.width = minWidth + delta + 'px'
- }
- }
- render() {
- return (
- <div className="jenga-panel scroll-hide-bar">
- {this.props.curEventNodeList ? undefined : <JengaExtra />}
- <div className="jenga-content" ref={this.jengaContent}>
- {this.props.curEventNodeList ? (
- this.props.curEventNodeList.map((nodeId, index) => {
- let visibleBlockIds = this.props.filterBlockIdsMap
- ? this.props.filterBlockIdsMap[nodeId] || []
- : undefined
- return (
- <JengaItem
- key={index}
- eventNodeId={nodeId}
- visibleBlockIds={visibleBlockIds}
- />
- )
- })
- ) : (
- <JengaItem />
- )}
- </div>
- </div>
- )
- }
- }
|