mirror of
https://github.com/discourse/discourse.git
synced 2025-01-31 14:47:14 +08:00
FIX: disable reorder links on touch screens (#20769)
This feature causes troubles on touch screens like phones and tablets. Right now, we would like to limit it to mouse and touchpads. /t/94351
This commit is contained in:
parent
b06e31f8e7
commit
3eaf48aa37
|
@ -1,9 +1,7 @@
|
|||
{{#if this.displaySection}}
|
||||
<div
|
||||
class={{concat
|
||||
"sidebar-section-wrapper sidebar-section-"
|
||||
@sectionName
|
||||
" "
|
||||
class={{concat-class
|
||||
(concat "sidebar-section-wrapper sidebar-section-" @sectionName)
|
||||
@class
|
||||
}}
|
||||
>
|
||||
|
|
|
@ -17,11 +17,15 @@
|
|||
@prefixValue={{link.icon}}
|
||||
@href={{link.value}}
|
||||
@class={{link.linkDragCss}}
|
||||
{{draggable
|
||||
{{(if
|
||||
this.canReorder
|
||||
(modifier
|
||||
"draggable"
|
||||
didStartDrag=link.didStartDrag
|
||||
didEndDrag=link.didEndDrag
|
||||
dragMove=link.dragMove
|
||||
}}
|
||||
)
|
||||
)}}
|
||||
/>
|
||||
{{else}}
|
||||
<Sidebar::SectionLink
|
||||
|
@ -33,11 +37,15 @@
|
|||
@prefixType="icon"
|
||||
@prefixValue={{link.icon}}
|
||||
@class={{link.linkDragCss}}
|
||||
{{draggable
|
||||
{{(if
|
||||
this.canReorder
|
||||
(modifier
|
||||
"draggable"
|
||||
didStartDrag=link.didStartDrag
|
||||
didEndDrag=link.didEndDrag
|
||||
dragMove=link.dragMove
|
||||
}}
|
||||
)
|
||||
)}}
|
||||
/>
|
||||
{{/if}}
|
||||
{{/each}}
|
||||
|
|
|
@ -28,6 +28,12 @@ export default class SidebarUserCustomSections extends Component {
|
|||
});
|
||||
}
|
||||
|
||||
get canReorder() {
|
||||
return document
|
||||
.getElementsByTagName("html")[0]
|
||||
.classList.contains("no-touch");
|
||||
}
|
||||
|
||||
@bind
|
||||
_refresh() {
|
||||
return ajax("/sidebar_sections.json", {}).then((json) => {
|
||||
|
|
|
@ -23,7 +23,7 @@ export default class SectionLink {
|
|||
|
||||
@bind
|
||||
didStartDrag(e) {
|
||||
this.mouseY = e.targetTouches ? e.targetTouches[0].screenY : e.screenY;
|
||||
this.mouseY = e.screenY;
|
||||
}
|
||||
|
||||
@bind
|
||||
|
@ -36,9 +36,7 @@ export default class SectionLink {
|
|||
|
||||
@bind
|
||||
dragMove(e) {
|
||||
const currentMouseY = e.targetTouches
|
||||
? e.targetTouches[0].screenY
|
||||
: e.screenY;
|
||||
const currentMouseY = e.screenY;
|
||||
const distance = currentMouseY - this.mouseY;
|
||||
if (!this.linkHeight) {
|
||||
this.linkHeight = document.getElementsByClassName(
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
.sidebar-section-link-prefix.icon,
|
||||
.sidebar-section-link {
|
||||
background: none;
|
||||
color: var(--primary-low);
|
||||
color: var(--primary-low-mid);
|
||||
}
|
||||
.sidebar-section-link.drag {
|
||||
font-weight: bold;
|
||||
|
|
Loading…
Reference in New Issue
Block a user