mirror of
https://github.com/yang991178/fluent-reader.git
synced 2025-04-16 11:17:20 +02:00
fix keyboard navigation for feeds
This commit is contained in:
parent
e0f1b4e6e5
commit
9cda9f48e6
@ -54,19 +54,36 @@ class CardsFeed extends React.Component<FeedProps> {
|
|||||||
showItem={this.props.showItem} />
|
showItem={this.props.showItem} />
|
||||||
) : (<div className="flex-fix" key={"f-"+index}></div>)
|
) : (<div className="flex-fix" key={"f-"+index}></div>)
|
||||||
|
|
||||||
|
canFocusChild = (el: HTMLElement) => {
|
||||||
|
if (el.id === "load-more") {
|
||||||
|
const container = document.getElementById("refocus")
|
||||||
|
const result = container.scrollTop > container.scrollHeight - 2 * container.offsetHeight
|
||||||
|
if (!result) container.scrollTop += 100
|
||||||
|
return result
|
||||||
|
} else {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return this.props.feed.loaded && (
|
return this.props.feed.loaded && (
|
||||||
<FocusZone as="div" id="refocus" className="cards-feed-container" data-is-scrollable>
|
<FocusZone as="div"
|
||||||
|
id="refocus"
|
||||||
|
className="cards-feed-container"
|
||||||
|
shouldReceiveFocus={this.canFocusChild}
|
||||||
|
data-is-scrollable>
|
||||||
<List
|
<List
|
||||||
className={AnimationClassNames.slideUpIn10}
|
className={AnimationClassNames.slideUpIn10}
|
||||||
items={this.flexFixItems()}
|
items={this.flexFixItems()}
|
||||||
onRenderCell={this.onRenderItem}
|
onRenderCell={this.onRenderItem}
|
||||||
getItemCountForPage={this.getItemCountForPage}
|
getItemCountForPage={this.getItemCountForPage}
|
||||||
getPageHeight={this.getPageHeight}
|
getPageHeight={this.getPageHeight}
|
||||||
|
ignoreScrollingState
|
||||||
usePageCache />
|
usePageCache />
|
||||||
{
|
{
|
||||||
(this.props.feed.loaded && !this.props.feed.allLoaded)
|
(this.props.feed.loaded && !this.props.feed.allLoaded)
|
||||||
? <div className="load-more-wrapper"><PrimaryButton
|
? <div className="load-more-wrapper"><PrimaryButton
|
||||||
|
id="load-more"
|
||||||
text={intl.get("loadMore")}
|
text={intl.get("loadMore")}
|
||||||
disabled={this.props.feed.loading}
|
disabled={this.props.feed.loading}
|
||||||
onClick={() => this.props.loadMore(this.props.feed)} /></div>
|
onClick={() => this.props.loadMore(this.props.feed)} /></div>
|
||||||
|
@ -38,21 +38,35 @@ class ListFeed extends React.Component<FeedProps> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
canFocusChild = (el: HTMLElement) => {
|
||||||
|
if (el.id === "load-more") {
|
||||||
|
const container = document.getElementById("refocus")
|
||||||
|
const result = container.scrollTop > container.scrollHeight - 2 * container.offsetHeight
|
||||||
|
if (!result) container.scrollTop += 100
|
||||||
|
return result
|
||||||
|
} else {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return this.props.feed.loaded && (
|
return this.props.feed.loaded && (
|
||||||
<FocusZone as="div"
|
<FocusZone as="div"
|
||||||
id="refocus"
|
id="refocus"
|
||||||
direction={FocusZoneDirection.vertical}
|
direction={FocusZoneDirection.vertical}
|
||||||
className={this.getClassName()}
|
className={this.getClassName()}
|
||||||
|
shouldReceiveFocus={this.canFocusChild}
|
||||||
data-is-scrollable>
|
data-is-scrollable>
|
||||||
<List
|
<List
|
||||||
className={AnimationClassNames.slideUpIn10}
|
className={AnimationClassNames.slideUpIn10}
|
||||||
items={this.props.items}
|
items={this.props.items}
|
||||||
onRenderCell={this.onRenderItem}
|
onRenderCell={this.onRenderItem}
|
||||||
|
ignoreScrollingState
|
||||||
usePageCache />
|
usePageCache />
|
||||||
{
|
{
|
||||||
(this.props.feed.loaded && !this.props.feed.allLoaded)
|
(this.props.feed.loaded && !this.props.feed.allLoaded)
|
||||||
? <div className="load-more-wrapper"><PrimaryButton
|
? <div className="load-more-wrapper"><PrimaryButton
|
||||||
|
id="load-more"
|
||||||
text={intl.get("loadMore")}
|
text={intl.get("loadMore")}
|
||||||
disabled={this.props.feed.loading}
|
disabled={this.props.feed.loading}
|
||||||
onClick={() => this.props.loadMore(this.props.feed)} /></div>
|
onClick={() => this.props.loadMore(this.props.feed)} /></div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user