1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-02 23:48:47 +00:00

Wiki bugs fix (#2311)

This commit is contained in:
shanshuirenjia
2018-08-29 12:25:22 +08:00
committed by Daniel Pan
parent 74cfd3cf74
commit 2ab330ab86
5 changed files with 246 additions and 52 deletions

View File

@@ -3,10 +3,10 @@ import React from 'react';
class WikiOutlineItem extends React.Component {
handleNavItemClick = () => {
var index = this.props.item.key;
this.props.handleNavItemClick(index)
var activeId = this.props.item.id;
this.props.handleNavItemClick(activeId)
}
render() {
let item = this.props.item;
let activeIndex = parseInt(this.props.activeIndex);
@@ -32,14 +32,6 @@ class WikiOutline extends React.Component {
}
}
handleNavItemClick = (index) => {
if (index !== this.state.activeIndex) {
this.setState({
activeIndex : index
})
}
}
componentWillReceiveProps(nextProps) {
let _this = this;
let activeId = nextProps.activeId;
@@ -49,14 +41,13 @@ class WikiOutline extends React.Component {
let flag = false;
let item = navItems[i];
if (item.id === activeId && item.key !== _this.state.activeIndex) {
let direction = item.key > _this.state.activeIndex ? "down" : "up";
let currentTop = parseInt(_this.state.scrollTop);
let scrollTop = 0;
if (item.key > 20 && direction === "down") {
scrollTop = currentTop - 27 + "px";
} else if (currentTop < 0 && direction === "up") {
scrollTop = currentTop + 27 + "px";
}
if (item.key > 20) {
scrollTop = - (item.key - 20)*27 + "px";
if (parseInt(scrollTop) > 0) { // handle scroll quickly;
scrollTop = 0;
}
}
_this.setState({
activeIndex : item.key,
scrollTop: scrollTop
@@ -79,7 +70,7 @@ class WikiOutline extends React.Component {
key={item.key}
item={item}
activeIndex={this.state.activeIndex}
handleNavItemClick={this.handleNavItemClick}
handleNavItemClick={this.props.handleNavItemClick}
/>
)
})}