mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-13 17:56:25 +00:00
fix auto-scroll
This commit is contained in:
@@ -151,6 +151,7 @@ class NoteList extends React.Component {
|
|||||||
const { selectedNoteKeys } = this.state
|
const { selectedNoteKeys } = this.state
|
||||||
const visibleNoteKeys = this.notes && this.notes.map(note => note.key)
|
const visibleNoteKeys = this.notes && this.notes.map(note => note.key)
|
||||||
const note = this.notes && this.notes[0]
|
const note = this.notes && this.notes[0]
|
||||||
|
const key = location.search && queryString.parse(location.search).key
|
||||||
const prevKey = prevProps.location.search && queryString.parse(prevProps.location.search).key
|
const prevKey = prevProps.location.search && queryString.parse(prevProps.location.search).key
|
||||||
const noteKey = visibleNoteKeys.includes(prevKey) ? prevKey : note && note.key
|
const noteKey = visibleNoteKeys.includes(prevKey) ? prevKey : note && note.key
|
||||||
|
|
||||||
@@ -173,25 +174,25 @@ class NoteList extends React.Component {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Auto scroll //<<<<<<<<<<<<<< fix me later
|
// Auto scroll
|
||||||
// if (_.isString(location.query.key) && prevProps.location.query.key === location.query.key) {
|
if (_.isString(key) && prevKey === key) {
|
||||||
// const targetIndex = this.getTargetIndex()
|
const targetIndex = this.getTargetIndex()
|
||||||
// if (targetIndex > -1) {
|
if (targetIndex > -1) {
|
||||||
// const list = this.refs.list
|
const list = this.refs.list
|
||||||
// const item = list.childNodes[targetIndex]
|
const item = list.childNodes[targetIndex]
|
||||||
|
|
||||||
// if (item == null) return false
|
if (item == null) return false
|
||||||
|
|
||||||
// const overflowBelow = item.offsetTop + item.clientHeight - list.clientHeight - list.scrollTop > 0
|
const overflowBelow = item.offsetTop + item.clientHeight - list.clientHeight - list.scrollTop > 0
|
||||||
// if (overflowBelow) {
|
if (overflowBelow) {
|
||||||
// list.scrollTop = item.offsetTop + item.clientHeight - list.clientHeight
|
list.scrollTop = item.offsetTop + item.clientHeight - list.clientHeight
|
||||||
// }
|
}
|
||||||
// const overflowAbove = list.scrollTop > item.offsetTop
|
const overflowAbove = list.scrollTop > item.offsetTop
|
||||||
// if (overflowAbove) {
|
if (overflowAbove) {
|
||||||
// list.scrollTop = item.offsetTop
|
list.scrollTop = item.offsetTop
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
focusNote (selectedNoteKeys, noteKey, pathname) {
|
focusNote (selectedNoteKeys, noteKey, pathname) {
|
||||||
|
|||||||
Reference in New Issue
Block a user