Fixed: Rogue scrollbar on large screens

pull/965/head
ta264 4 years ago
parent 2691cb3fce
commit 5a9d75857d

@ -7,7 +7,6 @@
.content { .content {
position: relative; position: relative;
display: flex; display: flex;
width: 300%;
height: 100%; height: 100%;
transition: var(--transition); transition: var(--transition);
transform: translateX(var(--translate)); transform: translateX(var(--translate));

@ -1,6 +1,7 @@
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import React, { Component } from 'react'; import React, { Component } from 'react';
import Measure from 'Components/Measure'; import Measure from 'Components/Measure';
import { isMobile as isMobileUtil } from 'Utilities/mobile';
import styles from './SwipeHeader.css'; import styles from './SwipeHeader.css';
function cursorPosition(event) { function cursorPosition(event) {
@ -15,6 +16,8 @@ class SwipeHeader extends Component {
constructor(props) { constructor(props) {
super(props); super(props);
this._isMobile = isMobileUtil();
this.state = { this.state = {
containerWidth: 0, containerWidth: 0,
touching: null, touching: null,
@ -32,7 +35,7 @@ class SwipeHeader extends Component {
// Listeners // Listeners
onMouseDown = (e) => { onMouseDown = (e) => {
if (!this.props.isSmallScreen || this.state.touching) { if (!this.props.isSmallScreen || !this._isMobile || this.state.touching) {
return; return;
} }
@ -177,7 +180,8 @@ class SwipeHeader extends Component {
children, children,
prevComponent, prevComponent,
currentComponent, currentComponent,
nextComponent nextComponent,
isSmallScreen
} = this.props; } = this.props;
const { const {
@ -187,13 +191,21 @@ class SwipeHeader extends Component {
stage stage
} = this.state; } = this.state;
const allowSwipe = isSmallScreen && this._isMobile;
const useTransition = !touching && stage !== 'navigated' && stage !== 'init'; const useTransition = !touching && stage !== 'navigated' && stage !== 'init';
const style = { const style = {
'--translate': `${translate - containerWidth}px`, width: '100%',
'--transition': useTransition ? `transform ${transitionDuration}ms ease-out` : undefined '--translate': 0
}; };
if (allowSwipe) {
style.width = '300%';
style['--translate'] = `${translate - containerWidth}px`;
style['--transition'] = useTransition ? `transform ${transitionDuration}ms ease-out` : undefined;
}
return ( return (
<Measure <Measure
className={className} className={className}
@ -208,9 +220,9 @@ class SwipeHeader extends Component {
onTouchStart={this.onMouseDown} onTouchStart={this.onMouseDown}
onTransitionEnd={this.onTransitionEnd} onTransitionEnd={this.onTransitionEnd}
> >
{prevComponent(containerWidth)} {allowSwipe ? prevComponent(containerWidth) : null}
{currentComponent(containerWidth)} {currentComponent(containerWidth)}
{nextComponent(containerWidth)} {allowSwipe ? nextComponent(containerWidth) : null}
</div> </div>
</Measure> </Measure>
); );

Loading…
Cancel
Save