Skip to content

Commit

Permalink
fix: mouse event on touch device
Browse files Browse the repository at this point in the history
  • Loading branch information
surunzi committed Jul 18, 2023
1 parent 8a200d4 commit 97122c8
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
4 changes: 2 additions & 2 deletions build/webpack.analyser.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer')
.BundleAnalyzerPlugin
const BundleAnalyzerPlugin =
require('webpack-bundle-analyzer').BundleAnalyzerPlugin

exports = require('./webpack.prod')

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
"licia": "^1.38.2",
"luna-box-model": "^0.1.0",
"luna-console": "^1.3.3",
"luna-data-grid": "^0.4.3",
"luna-data-grid": "^0.5.1",
"luna-dom-viewer": "^1.2.3",
"luna-modal": "^1.0.0",
"luna-notification": "^0.1.4",
Expand Down
1 change: 1 addition & 0 deletions src/DevTools/DevTools.scss
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
.resizer {
position: absolute;
width: 100%;
touch-action: none;
left: 0;
top: -8px;
cursor: row-resize;
Expand Down
10 changes: 10 additions & 0 deletions src/lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ function processClass(str) {
}

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

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

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

Expand Down

1 comment on commit 97122c8

@Matthewssoftdev
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow I’m shocked !!
Amazing

Please sign in to comment.