|
|
|
@ -46,22 +46,28 @@ export default class StatusList extends ImmutablePureComponent { |
|
|
|
|
|
|
|
|
|
handleMoveUp = (id, featured) => { |
|
|
|
|
const elementIndex = this.getCurrentStatusIndex(id, featured) - 1; |
|
|
|
|
this._selectChild(elementIndex); |
|
|
|
|
this._selectChild(elementIndex, true); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
handleMoveDown = (id, featured) => { |
|
|
|
|
const elementIndex = this.getCurrentStatusIndex(id, featured) + 1; |
|
|
|
|
this._selectChild(elementIndex); |
|
|
|
|
this._selectChild(elementIndex, false); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
handleLoadOlder = debounce(() => { |
|
|
|
|
this.props.onLoadMore(this.props.statusIds.size > 0 ? this.props.statusIds.last() : undefined); |
|
|
|
|
}, 300, { leading: true }) |
|
|
|
|
|
|
|
|
|
_selectChild (index) { |
|
|
|
|
const element = this.node.node.querySelector(`article:nth-of-type(${index + 1}) .focusable`); |
|
|
|
|
_selectChild (index, align_top) { |
|
|
|
|
const container = this.node.node; |
|
|
|
|
const element = container.querySelector(`article:nth-of-type(${index + 1}) .focusable`); |
|
|
|
|
|
|
|
|
|
if (element) { |
|
|
|
|
if (align_top && container.scrollTop > element.offsetTop) { |
|
|
|
|
element.scrollIntoView(true); |
|
|
|
|
} else if (!align_top && container.scrollTop + container.clientHeight < element.offsetTop + element.offsetHeight) { |
|
|
|
|
element.scrollIntoView(false); |
|
|
|
|
} |
|
|
|
|
element.focus(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|