Skip to content

Commit

Permalink
Fix edit media modal on small screens, touch events (mastodon#11573)
Browse files Browse the repository at this point in the history
  • Loading branch information
Gargron authored and hiyuki2578 committed Oct 2, 2019
1 parent 9336228 commit 1159d44
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,14 @@ class FocalPointModal extends ImmutablePureComponent {
this.setState({ dragging: true });
}

handleTouchStart = e => {
document.addEventListener('touchmove', this.handleMouseMove);
document.addEventListener('touchend', this.handleTouchEnd);

this.updatePosition(e);
this.setState({ dragging: true });
}

handleMouseMove = e => {
this.updatePosition(e);
}
Expand All @@ -95,6 +103,13 @@ class FocalPointModal extends ImmutablePureComponent {
this.setState({ dragging: false });
}

handleTouchEnd = () => {
document.removeEventListener('touchmove', this.handleMouseMove);
document.removeEventListener('touchend', this.handleTouchEnd);

this.setState({ dragging: false });
}

updatePosition = e => {
const { x, y } = getPointerPosition(this.node, e);
const focusX = (x - .5) * 2;
Expand Down Expand Up @@ -225,7 +240,7 @@ class FocalPointModal extends ImmutablePureComponent {
</div>

<div className='focal-point__reticle' style={{ top: `${y * 100}%`, left: `${x * 100}%` }} />
<div className='focal-point__overlay' onMouseDown={this.handleMouseDown} />
<div className='focal-point__overlay' onMouseDown={this.handleMouseDown} onTouchStart={this.handleTouchStart} />
</div>
)}

Expand Down
2 changes: 1 addition & 1 deletion app/javascript/styles/mastodon/basics.scss
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ button {
.layout-single-column .app-holder {
&,
& > div {
min-height: 100%;
min-height: 100vh;
}
}

Expand Down
16 changes: 16 additions & 0 deletions app/javascript/styles/mastodon/components.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5757,6 +5757,11 @@ noscript {
position: relative;
cursor: move;
overflow: hidden;
height: 100%;
display: flex;
justify-content: center;
align-items: center;
background: $base-shadow-color;

img,
video {
Expand Down Expand Up @@ -5807,6 +5812,17 @@ noscript {
box-shadow: 0 0 14px rgba($base-shadow-color, 0.2);
}
}

@media screen and (max-width: 480px) {
img,
video {
max-height: 100%;
}

&__preview {
display: none;
}
}
}

.account__header__content {
Expand Down

0 comments on commit 1159d44

Please sign in to comment.