Update React-scroll, getting rid of the need to manually set the url hash

This commit is contained in:
Fabio Berger
2018-08-01 17:33:28 +02:00
parent 9b24459108
commit 11869122b4
7 changed files with 12 additions and 22 deletions

View File

@@ -41,7 +41,7 @@
"@types/node": "^8.0.53",
"@types/react": "*",
"@types/react-dom": "*",
"@types/react-scroll": "0.0.31",
"@types/react-scroll": "1.5.3",
"basscss": "^8.0.3",
"compare-versions": "^3.0.1",
"lodash": "^4.17.4",
@@ -49,7 +49,7 @@
"react": "15.6.1",
"react-dom": "15.6.1",
"react-markdown": "^3.2.2",
"react-scroll": "^1.5.2",
"react-scroll": "^1.7.10",
"react-tooltip": "^3.2.7",
"semver": "5.5.0"
},

View File

@@ -27,7 +27,7 @@ const defaultProps = {
};
export const Signature: React.SFC<SignatureProps> = (props: SignatureProps) => {
const sectionName = constants.TYPES_SECTION_NAME;
const sectionName = props.sectionName;
const parameters = renderParameters(props.parameters, props.docsInfo, sectionName, props.typeDefinitionByName);
const paramStringArray: any[] = [];
// HACK: For now we don't put params on newlines if there are less then 2 of them.

View File

@@ -182,6 +182,7 @@ export function Type(props: TypeProps): any {
<ScrollLink
to={typeDefinitionAnchorId}
offset={0}
hashSpy={true}
duration={sharedConstants.DOCS_SCROLL_DURATION_MS}
containerId={sharedConstants.DOCS_CONTAINER_ID}
>

View File

@@ -39,7 +39,7 @@
"@types/node": "^8.0.53",
"@types/react": "*",
"@types/react-dom": "*",
"@types/react-scroll": "0.0.31",
"@types/react-scroll": "1.5.3",
"basscss": "^8.0.3",
"is-mobile": "^0.2.2",
"lodash": "^4.17.4",
@@ -48,7 +48,7 @@
"react-dom": "15.6.1",
"react-highlight": "0xproject/react-highlight",
"react-markdown": "^3.2.2",
"react-scroll": "^1.5.2",
"react-scroll": "^1.7.10",
"react-tap-event-plugin": "^2.0.1"
},
"publishConfig": {

View File

@@ -69,13 +69,13 @@ export class AnchorTitle extends React.Component<AnchorTitleProps, AnchorTitleSt
</div>
<ScrollLink
to={this.props.id}
hashSpy={true}
offset={headerSizeToScrollOffset[this.props.headerSize]}
duration={constants.DOCS_SCROLL_DURATION_MS}
containerId={constants.DOCS_CONTAINER_ID}
>
<i
className="zmdi zmdi-link"
onClick={utils.setUrlHash.bind(utils, this.props.id)}
style={{ ...styles.anchor, opacity }}
onMouseOver={this._setHoverState.bind(this, true)}
onMouseOut={this._setHoverState.bind(this, false)}

View File

@@ -94,14 +94,11 @@ export class NestedSidebarMenu extends React.Component<NestedSidebarMenuProps, N
key={`menuItem-${menuItemName}`}
to={id}
offset={-10}
hashSpy={true}
duration={constants.DOCS_SCROLL_DURATION_MS}
containerId={constants.DOCS_CONTAINER_ID}
>
<MenuItem
onTouchTap={this._onMenuItemClick.bind(this, finalMenuItemName)}
style={menuItemStyles}
innerDivStyle={menuItemInnerDivStyles}
>
<MenuItem style={menuItemStyles} innerDivStyle={menuItemInnerDivStyles}>
<span style={{ textTransform: 'capitalize' }}>{finalMenuItemName}</span>
</MenuItem>
</ScrollLink>
@@ -128,12 +125,11 @@ export class NestedSidebarMenu extends React.Component<NestedSidebarMenuProps, N
<ScrollLink
to={id}
offset={0}
hashSpy={true}
duration={constants.DOCS_SCROLL_DURATION_MS}
containerId={constants.DOCS_CONTAINER_ID}
onTouchTap={this._onMenuItemClick.bind(this, name)}
>
<MenuItem
onTouchTap={this._onMenuItemClick.bind(this, name)}
style={{ minHeight: 35 }}
innerDivStyle={{
paddingLeft: 16,
@@ -150,11 +146,4 @@ export class NestedSidebarMenu extends React.Component<NestedSidebarMenuProps, N
</ul>
);
}
private _onMenuItemClick(name: string): void {
const id = utils.getIdFromName(name);
utils.setUrlHash(id);
if (!_.isUndefined(this.props.onMenuItemClick)) {
this.props.onMenuItemClick();
}
}
}

View File

@@ -49,7 +49,7 @@
"react-popper": "^1.0.0-beta.6",
"react-redux": "^5.0.3",
"react-router-dom": "^4.1.1",
"react-scroll": "^1.5.2",
"react-scroll": "^1.7.10",
"react-tap-event-plugin": "^2.0.1",
"react-tooltip": "^3.2.7",
"redux": "^3.6.0",
@@ -77,7 +77,7 @@
"@types/react-dom": "^16.0.3",
"@types/react-redux": "^4.4.37",
"@types/react-router-dom": "^4.0.4",
"@types/react-scroll": "0.0.31",
"@types/react-scroll": "1.5.3",
"@types/react-tap-event-plugin": "0.0.30",
"@types/redux": "^3.6.0",
"awesome-typescript-loader": "^3.1.3",