You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using this library and so far this is the most simple, and nice resizer for my project !
but I'm trying to programatically resize the section from other component, but nothing happen..
I'm using Resizer.resizeSection as documented, but I got no luck..
first I pass the Resizer instance as state, so I could pass it to other component.
/App/Container<ContainerbeforeApplyResizer={resizer=>{this.setState({ resizer })// set resizer}}>{section.grids.map((grid,i)=>{letcomp=[<GridLayoutkey={i}gridIndex={i}grid={grid}resizer={this.state.resizer||null}// then pass it to this component/>]if(section.grids[i+1]){comp.push(<Barkey={'bar_'+i}size={5}style={{background: '#888888',cursor: 'col-resize'}}/>)}returncomp})}</Container>
within the GridLayout component, then I use the resizer inside my custom handler:
/App/GridLayoutclassGridLayoutextendsComponent{// this is the handler for programatically resize this componenthandleResize=(newSize)=>{const{ gridIndex, resizer }=this.propsif(resizer){resizer.resizeSection(gridIndex,{toSize: newSize})// nothing happen ...}}render(){const{ grid }=this.propsreturn(<SectiondefaultSize={grid.width||null}className={classes.layout}><IconButtononClick={this.handleDelete}><Delete/></IconButton><IconButtononClick={this.handleDuplicate}><ViewAgenda/></IconButton><IconButtononClick={()=>this.handleResize(grid.width+=15)}> // triggered in here but nothing happen
<Add/></IconButton><IconButtononClick={()=>this.handleResize(grid.width-=15)}> // triggered in here but nothing happen
<Remove/></IconButton></Section>)}}
Please do explain to me if I get it wrong or there are other approaches..
nice library by the way, really helpful, keep the good work !
The text was updated successfully, but these errors were encountered:
Happy weekend, friend. Sorry for the delayed response. It is quite strange that Github didn't send email to me about this issue.
According to the code you provided, seems the Resizer has been misused. It may be a little confusing about how the Resizer works.
You could check this demo to see how to apply Resizer to the Container. The onBarClick method demonstrates how to get the latest Resizer and how to apply the Resizer.
We do not encourage to state the instance of Resizer, because each time the Resizer be created is for a temporary use case.
it works like a charm !
I followed the demo and tweak around my code..
<Containerref={this.containerRef}...// and then within the loop<GridLayoutprogramaticallyResize={(size)=>{constcontainer=this.containerRef.currentif(container){constresizer=container.getResizer()letconfig={toSize: size}resizer.resizeSection(i,config)container.applyResizer(resizer)// <-- do the magic}}}...// within GridLayout componenthandleResize=(size)=>{const{ programaticallyResize }=this.propsreturnprogramaticallyResize(size)// now it works !}
Now everything work, I could programatically change the Section size from anywhere..
Thank you my friend !
Good day sir !
I'm using this library and so far this is the most simple, and nice resizer for my project !
but I'm trying to programatically resize the section from other component, but nothing happen..
I'm using Resizer.resizeSection as documented, but I got no luck..
first I pass the Resizer instance as state, so I could pass it to other component.
within the GridLayout component, then I use the resizer inside my custom handler:
Please do explain to me if I get it wrong or there are other approaches..
nice library by the way, really helpful, keep the good work !
The text was updated successfully, but these errors were encountered: