Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix line-height might be just NaN and still exists #147

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/js/ScrollArea.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -258,9 +258,11 @@ export default class ScrollArea extends React.Component {
* e.deltaMode === 1: The delta values are specified in lines
* https://developer.mozilla.org/en-US/docs/Web/API/WheelEvent/deltaMode
*/

const lineHeight = !isNaN(this.lineHeightPx) && this.lineHeightPx ? this.lineHeightPx : 10;
if (e.deltaMode === 1) {
deltaY = deltaY * this.lineHeightPx;
deltaX = deltaX * this.lineHeightPx;
deltaY = deltaY * lineHeight;
deltaX = deltaX * lineHeight;
}

deltaY = deltaY * this.props.speed;
Expand All @@ -284,7 +286,7 @@ export default class ScrollArea extends React.Component {
if (e.target.tagName.toLowerCase() !== 'input' && e.target.tagName.toLowerCase() !== 'textarea' && !e.target.isContentEditable) {
let deltaY = 0;
let deltaX = 0;
let lineHeight = this.lineHeightPx ? this.lineHeightPx : 10;
let lineHeight = !isNaN(this.lineHeightPx) && this.lineHeightPx ? this.lineHeightPx : 10;

switch (e.keyCode) {
case 33: // page up
Expand Down