-
Notifications
You must be signed in to change notification settings - Fork 131
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
108 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
86 changes: 86 additions & 0 deletions
86
example/javascripts/components/HorizontalLayoutWithEvents.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
/* eslint no-void: [0] */ | ||
import React from 'react'; | ||
import SplitterLayout from '../../../index'; | ||
|
||
export default class HorizontalLayoutWithEvents extends React.Component { | ||
constructor(props) { | ||
super(props); | ||
this.onDragStart = this.onDragStart.bind(this); | ||
this.onDragEnd = this.onDragEnd.bind(this); | ||
this.onSecondaryPaneSizeChange = this.onSecondaryPaneSizeChange.bind(this); | ||
this.state = { | ||
secondaryPaneSize: -1, | ||
dragging: false | ||
}; | ||
} | ||
|
||
componentDidUpdate(prevProps, prevState) { | ||
if (prevState.dragging !== this.state.dragging && this.draggingEl1 && this.draggingEl2) { | ||
this.draggingEl1.classList.add('highlight'); | ||
this.draggingEl2.classList.add('highlight'); | ||
void this.draggingEl1.offsetWidth; | ||
void this.draggingEl2.offsetWidth; | ||
this.draggingEl1.classList.remove('highlight'); | ||
this.draggingEl2.classList.remove('highlight'); | ||
} | ||
if (prevState.secondaryPaneSize !== this.state.secondaryPaneSize && this.sizeEl1 && this.sizeEl2) { | ||
this.sizeEl1.classList.add('highlight'); | ||
this.sizeEl2.classList.add('highlight'); | ||
void this.sizeEl1.offsetWidth; | ||
void this.sizeEl2.offsetWidth; | ||
this.sizeEl1.classList.remove('highlight'); | ||
this.sizeEl2.classList.remove('highlight'); | ||
} | ||
} | ||
|
||
onDragStart() { | ||
this.setState({ dragging: true }); | ||
} | ||
|
||
onDragEnd() { | ||
this.setState({ dragging: false }); | ||
} | ||
|
||
onSecondaryPaneSizeChange(secondaryPaneSize) { | ||
this.setState({ secondaryPaneSize }); | ||
} | ||
|
||
render() { | ||
return ( | ||
<SplitterLayout | ||
onDragStart={this.onDragStart} | ||
onDragEnd={this.onDragEnd} | ||
onSecondaryPaneSizeChange={this.onSecondaryPaneSizeChange} | ||
> | ||
<div className="my-pane"> | ||
<h2>1st Pane</h2> | ||
<p>This is the 1st pane, and this is the primary pane by default.</p> | ||
<p>Dragging: | ||
<span className="volatile" ref={(e) => { this.draggingEl1 = e; }}> | ||
{this.state.dragging ? 'Yes' : 'No'} | ||
</span> | ||
</p> | ||
<p>Size of the 2nd pane: | ||
<span className="volatile" ref={(e) => { this.sizeEl1 = e; }}> | ||
{this.state.secondaryPaneSize} | ||
</span> | ||
</p> | ||
</div> | ||
<div className="my-pane"> | ||
<h2>2nd Pane</h2> | ||
<p>This is the 2nd pane, and this is the secondary pane by default.</p> | ||
<p>Dragging: | ||
<span className="volatile" ref={(e) => { this.draggingEl2 = e; }}> | ||
{this.state.dragging ? 'Yes' : 'No'} | ||
</span> | ||
</p> | ||
<p>Size of this pane: | ||
<span className="volatile" ref={(e) => { this.sizeEl2 = e; }}> | ||
{this.state.secondaryPaneSize} | ||
</span> | ||
</p> | ||
</div> | ||
</SplitterLayout> | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
/* eslint import/no-extraneous-dependencies: [0] */ | ||
import React from 'react'; | ||
import { Link } from 'react-router-dom'; | ||
import { NavLink } from 'react-router-dom'; | ||
|
||
export default function(props) { | ||
return ( | ||
<Link {...props} activeClassName="active" /> | ||
<NavLink {...props} activeClassName="active" /> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters