requestAnimationFrame will only trigger if the browser window is visible. If the browser tab is put to the background, requestAnimationFrame will trigger when the tab returned to the foreground. When the Tabs Component is removed from the DOM when in the background, the requestAnimationFrame must be canceled to prevent attempting to use a unmounted Component. (#1604)

old
Robin Larson 2017-08-02 12:11:37 -04:00 committed by Javi Velasco
parent df175e7f0d
commit fb5d0e1ffc
1 changed files with 2 additions and 1 deletions

View File

@ -64,6 +64,7 @@ const factory = (Tab, TabContent, FontIcon) => {
componentWillUnmount() {
window.removeEventListener('resize', this.handleResize);
clearTimeout(this.resizeTimeout);
if (this.updatePointerAnimationFrame) cancelAnimationFrame(this.updatePointerAnimationFrame);
}
handleHeaderClick = (idx) => {
@ -82,7 +83,7 @@ const factory = (Tab, TabContent, FontIcon) => {
updatePointer = (idx) => {
if (this.navigationNode && this.navigationNode.children[idx]) {
requestAnimationFrame(() => {
this.updatePointerAnimationFrame = requestAnimationFrame(() => {
const nav = this.navigationNode.getBoundingClientRect();
const label = this.navigationNode.children[idx].getBoundingClientRect();
const scrollLeft = this.navigationNode.scrollLeft;