Skip to content

Commit

Permalink
feat: support mouse on touch device
Browse files Browse the repository at this point in the history
  • Loading branch information
surunzi committed Jul 18, 2023
1 parent 26a18a5 commit 85b32e3
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/color-picker/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

.luna-color-picker {
@include component();
touch-action: none;
width: 225px;
box-shadow: $box-shadow;
}
Expand Down
4 changes: 3 additions & 1 deletion src/cropper/style.scss
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
@import '../share/variable';
@import '../share/mixin';

.luna-cropper {
@include component();
background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQAQMAAAAlPW0iAAAAA3NCSVQICAjb4U/gAAAABlBMVEXMzMz////TjRV2AAAACXBIWXMAAArrAAAK6wGCiw1aAAAAHHRFWHRTb2Z0d2FyZQBBZG9iZSBGaXJld29ya3MgQ1M26LyyjAAAABFJREFUCJlj+M/AgBVhF/0PAH6/D/HkDxOGAAAAAElFTkSuQmCC');
position: relative;
user-select: none;
min-height: 150px;
touch-action: none;
}

.preview {
Expand Down
1 change: 1 addition & 0 deletions src/data-grid/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@
bottom: 0;
width: 5px;
z-index: 500;
touch-action: none;
cursor: col-resize;
}

Expand Down
1 change: 1 addition & 0 deletions src/image-viewer/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
.luna-image-viewer {
@include component();
overflow: hidden;
touch-action: none;
border: 1px solid $border-color;
}

Expand Down
2 changes: 2 additions & 0 deletions src/music-player/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
}

.controller-left {
touch-action: none;
margin: 0 0 0 5px;
padding: 6px 0;
flex: 1;
Expand Down Expand Up @@ -154,6 +155,7 @@
}

.volume-controller {
touch-action: none;
height: 0;
position: absolute;
bottom: 15px;
Expand Down
1 change: 1 addition & 0 deletions src/scrollbar/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@

.thumb {
position: absolute;
touch-action: none;
background: rgba(0, 0, 0, 0.2);
border-radius: 3px;
}
Expand Down
2 changes: 1 addition & 1 deletion src/shader-toy-player/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
background: #000;
width: 100%;
height: 100%;
user-select: none;
touch-action: none;
position: relative;
}

Expand Down
10 changes: 10 additions & 0 deletions src/share/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ function traverseTree(tree: any[], handler: any) {
}

export const hasTouchSupport = 'ontouchstart' in root
export const hasPointerSupport = 'PointerEvent' in root
const touchEvents: any = {
start: 'touchstart',
move: 'touchmove',
Expand All @@ -70,8 +71,17 @@ const mouseEvents: any = {
move: 'mousemove',
end: 'mouseup',
}
const pointerEvents: any = {
start: 'pointerdown',
move: 'pointermove',
end: 'pointerup',
}

export function drag(name: string) {
if (hasPointerSupport) {
return pointerEvents[name]
}

return hasTouchSupport ? touchEvents[name] : mouseEvents[name]
}

Expand Down
2 changes: 2 additions & 0 deletions src/video-player/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
}

.controller-top {
touch-action: none;
padding: 5px 0;
position: absolute;
bottom: 38px;
Expand Down Expand Up @@ -95,6 +96,7 @@
}

.volume-controller {
touch-action: none;
display: inline-block;
width: 0;
height: 100%;
Expand Down
2 changes: 2 additions & 0 deletions src/window/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,11 @@

.resizer {
@include fill-window;
touch-action: none;
}

.title-bar {
touch-action: none;
height: 30px;
cursor: default;
user-select: none;
Expand Down

0 comments on commit 85b32e3

Please sign in to comment.