-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Visibility): add fireOnMount (#2018)
* feat(Visibility): add fireOnMount * docs(Visibility): remove "once" from fireOnMount
- Loading branch information
1 parent
ef9faee
commit 578b957
Showing
6 changed files
with
147 additions
and
7 deletions.
There are no files selected for viewing
112 changes: 112 additions & 0 deletions
112
docs/app/Examples/behaviors/Visibility/Settings/VisibilityExampleFireOnMount.js
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,112 @@ | ||
import React, { Component } from 'react' | ||
import { Divider, Grid, Image, Table, Segment, Visibility } from 'semantic-ui-react' | ||
|
||
export default class VisibilityExampleFireOnMount extends Component { | ||
state = { | ||
calculations: { | ||
height: 0, | ||
width: 0, | ||
topPassed: false, | ||
bottomPassed: false, | ||
pixelsPassed: 0, | ||
percentagePassed: 0, | ||
topVisible: false, | ||
bottomVisible: false, | ||
fits: false, | ||
passing: false, | ||
onScreen: false, | ||
offScreen: false, | ||
}, | ||
} | ||
|
||
handleOnScreen = (e, { calculations }) => this.setState({ calculations }) | ||
|
||
handleOffScreen = (e, { calculations }) => this.setState({ calculations }) | ||
|
||
render() { | ||
const { calculations } = this.state | ||
|
||
return ( | ||
<Grid columns={2}> | ||
<Grid.Column> | ||
<Visibility | ||
fireOnMount | ||
onOnScreen={this.handleOnScreen} | ||
onOffScreen={this.handleOffScreen} | ||
> | ||
<Segment> | ||
<Image src='/assets/images/wireframe/centered-paragraph.png' /> | ||
<Divider /> | ||
<Image src='/assets/images/wireframe/short-paragraph.png' /> | ||
<Divider /> | ||
<Image src='/assets/images/wireframe/media-paragraph.png' /> | ||
<Divider /> | ||
<Image src='/assets/images/wireframe/paragraph.png' /> | ||
</Segment> | ||
</Visibility> | ||
</Grid.Column> | ||
|
||
<Grid.Column> | ||
<Table celled> | ||
<Table.Header> | ||
<Table.Row> | ||
<Table.HeaderCell>Calculation</Table.HeaderCell> | ||
<Table.HeaderCell>Value</Table.HeaderCell> | ||
</Table.Row> | ||
</Table.Header> | ||
<Table.Body> | ||
<Table.Row> | ||
<Table.Cell>pixelsPassed</Table.Cell> | ||
<Table.Cell>{calculations.pixelsPassed.toFixed()}px</Table.Cell> | ||
</Table.Row> | ||
<Table.Row> | ||
<Table.Cell>percentagePassed</Table.Cell> | ||
<Table.Cell>{(calculations.percentagePassed * 100).toFixed()}%</Table.Cell> | ||
</Table.Row> | ||
<Table.Row> | ||
<Table.Cell>fits</Table.Cell> | ||
<Table.Cell>{calculations.fits.toString()}</Table.Cell> | ||
</Table.Row> | ||
<Table.Row> | ||
<Table.Cell>width</Table.Cell> | ||
<Table.Cell>{calculations.width.toFixed()}px</Table.Cell> | ||
</Table.Row> | ||
<Table.Row> | ||
<Table.Cell>height</Table.Cell> | ||
<Table.Cell>{calculations.height.toFixed()}px</Table.Cell> | ||
</Table.Row> | ||
<Table.Row> | ||
<Table.Cell>onScreen</Table.Cell> | ||
<Table.Cell>{calculations.onScreen.toString()}</Table.Cell> | ||
</Table.Row> | ||
<Table.Row> | ||
<Table.Cell>offScreen</Table.Cell> | ||
<Table.Cell>{calculations.offScreen.toString()}</Table.Cell> | ||
</Table.Row> | ||
<Table.Row> | ||
<Table.Cell>passing</Table.Cell> | ||
<Table.Cell>{calculations.passing.toString()}</Table.Cell> | ||
</Table.Row> | ||
<Table.Row> | ||
<Table.Cell>topVisible</Table.Cell> | ||
<Table.Cell>{calculations.topVisible.toString()}</Table.Cell> | ||
</Table.Row> | ||
<Table.Row> | ||
<Table.Cell>bottomVisible</Table.Cell> | ||
<Table.Cell>{calculations.bottomVisible.toString()}</Table.Cell> | ||
</Table.Row> | ||
<Table.Row> | ||
<Table.Cell>topPassed</Table.Cell> | ||
<Table.Cell>{calculations.topPassed.toString()}</Table.Cell> | ||
</Table.Row> | ||
<Table.Row> | ||
<Table.Cell>bottomPassed</Table.Cell> | ||
<Table.Cell>{calculations.bottomPassed.toString()}</Table.Cell> | ||
</Table.Row> | ||
</Table.Body> | ||
</Table> | ||
</Grid.Column> | ||
</Grid> | ||
) | ||
} | ||
} |
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
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