Skip to content

Commit

Permalink
style refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
orkunkarakus committed May 7, 2022
1 parent 32de902 commit afecb5d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ const BasePreRenderer = forwardRef((props, ref) => {
ref={ref}
horizontal
>
<View
onStartShouldSetResponder={() => true}
>
<View onStartShouldSetResponder={() => true}>
<TDefaultRenderer
// eslint-disable-next-line react/jsx-props-no-spreading
{...defaultRendererProps}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ class PreRenderer extends React.Component {
if (!this.ref) {
return;
}
this.ref
.getScrollableNode()
this.ref.getScrollableNode()
.addEventListener('wheel', this.scrollNode);
}

Expand All @@ -24,6 +23,10 @@ class PreRenderer extends React.Component {
.removeEventListener('wheel', this.scrollNode);
}

/**
* Manually scrolls the code block if code block horizontal scrollable, then prevents the event from being passed up to the parent.
* @param {Object} event native event
*/
scrollNode(event) {
const node = this.ref.getScrollableNode();
const horizontalOverflow = node.scrollWidth > node.offsetWidth;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@ import htmlRendererPropTypes from '../htmlRendererPropTypes';
import BasePreRenderer from './BasePreRenderer';

const PreRenderer = props => (
<BasePreRenderer
// eslint-disable-next-line react/jsx-props-no-spreading
{...props}
/>
<BasePreRenderer {...props} />
);

PreRenderer.propTypes = htmlRendererPropTypes;
Expand Down

0 comments on commit afecb5d

Please sign in to comment.