Skip to content

Commit

Permalink
Fixed #726 - ScrollPanel: Cannot read property 'classList' of null
Browse files Browse the repository at this point in the history
  • Loading branch information
cagataycivici committed Jan 10, 2019
1 parent 9923d9d commit afc5915
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/components/scrollpanel/ScrollPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export class ScrollPanel extends Component {

this.scrollYRatio = ownHeight / totalHeight;

this.requestAnimationFrame(() => {
this.frame = this.requestAnimationFrame(() => {
if (this.scrollXRatio >= 1) {
DomHandler.addClass(this.xBar, 'p-scrollpanel-hidden');
}
Expand Down Expand Up @@ -117,7 +117,7 @@ export class ScrollPanel extends Component {
let deltaX = e.pageX - this.lastPageX;
this.lastPageX = e.pageX;

this.requestAnimationFrame(() => {
this.frame = this.requestAnimationFrame(() => {
this.content.scrollLeft += deltaX / this.scrollXRatio;
});
}
Expand All @@ -126,7 +126,7 @@ export class ScrollPanel extends Component {
let deltaY = e.pageY - this.lastPageY;
this.lastPageY = e.pageY;

this.requestAnimationFrame(() => {
this.frame = this.requestAnimationFrame(() => {
this.content.scrollTop += deltaY / this.scrollYRatio;
});
}
Expand All @@ -144,7 +144,7 @@ export class ScrollPanel extends Component {

requestAnimationFrame(f) {
let frame = window.requestAnimationFrame || this.timeoutFrame;
frame(f);
return frame(f);
}

refresh() {
Expand All @@ -165,6 +165,10 @@ export class ScrollPanel extends Component {
if (this.initialized) {
window.removeEventListener('resize', this.moveBar);
}

if (this.frame) {
window.cancelAnimationFrame(this.frame);
}
}

render() {
Expand Down

0 comments on commit afc5915

Please sign in to comment.