Skip to content

Commit 1159d44

Browse files
Gargronhiyuki2578
authored andcommitted
Fix edit media modal on small screens, touch events (mastodon#11573)
1 parent 9336228 commit 1159d44

3 files changed

Lines changed: 33 additions & 2 deletions

File tree

app/javascript/mastodon/features/ui/components/focal_point_modal.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,14 @@ class FocalPointModal extends ImmutablePureComponent {
8484
this.setState({ dragging: true });
8585
}
8686

87+
handleTouchStart = e => {
88+
document.addEventListener('touchmove', this.handleMouseMove);
89+
document.addEventListener('touchend', this.handleTouchEnd);
90+
91+
this.updatePosition(e);
92+
this.setState({ dragging: true });
93+
}
94+
8795
handleMouseMove = e => {
8896
this.updatePosition(e);
8997
}
@@ -95,6 +103,13 @@ class FocalPointModal extends ImmutablePureComponent {
95103
this.setState({ dragging: false });
96104
}
97105

106+
handleTouchEnd = () => {
107+
document.removeEventListener('touchmove', this.handleMouseMove);
108+
document.removeEventListener('touchend', this.handleTouchEnd);
109+
110+
this.setState({ dragging: false });
111+
}
112+
98113
updatePosition = e => {
99114
const { x, y } = getPointerPosition(this.node, e);
100115
const focusX = (x - .5) * 2;
@@ -225,7 +240,7 @@ class FocalPointModal extends ImmutablePureComponent {
225240
</div>
226241

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

app/javascript/styles/mastodon/basics.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ button {
150150
.layout-single-column .app-holder {
151151
&,
152152
& > div {
153-
min-height: 100%;
153+
min-height: 100vh;
154154
}
155155
}
156156

app/javascript/styles/mastodon/components.scss

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5757,6 +5757,11 @@ noscript {
57575757
position: relative;
57585758
cursor: move;
57595759
overflow: hidden;
5760+
height: 100%;
5761+
display: flex;
5762+
justify-content: center;
5763+
align-items: center;
5764+
background: $base-shadow-color;
57605765

57615766
img,
57625767
video {
@@ -5807,6 +5812,17 @@ noscript {
58075812
box-shadow: 0 0 14px rgba($base-shadow-color, 0.2);
58085813
}
58095814
}
5815+
5816+
@media screen and (max-width: 480px) {
5817+
img,
5818+
video {
5819+
max-height: 100%;
5820+
}
5821+
5822+
&__preview {
5823+
display: none;
5824+
}
5825+
}
58105826
}
58115827

58125828
.account__header__content {

0 commit comments

Comments
 (0)