Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Fixed mobile touch issue in pan zoom selection" #4462

Merged
merged 1 commit into from
May 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 8 additions & 18 deletions src/modules/ZoomPanSelection.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import Scales from './Scales'
export default class ZoomPanSelection extends Toolbar {
constructor(ctx) {
super(ctx)

this.ctx = ctx
this.w = ctx.w

Expand Down Expand Up @@ -156,8 +157,9 @@ export default class ZoomPanSelection extends Toolbar {
? e.changedTouches[0].clientY
: e.clientY

if ((e.type === 'mousedown' || e.type === 'touchmove') && e.which === 1) {
if (e.type === 'mousedown' && e.which === 1) {
let gridRectDim = me.gridRect.getBoundingClientRect()

me.startX = me.clientX - gridRectDim.left
me.startY = me.clientY - gridRectDim.top

Expand All @@ -170,30 +172,14 @@ export default class ZoomPanSelection extends Toolbar {

if (w.globals.panEnabled) {
w.globals.selection = null
if (me.w.globals.mousedown || e.type === 'touchmove') {
if (e.type === 'touchmove' && !me.w.globals.mousedown) {
console.warn('me.w.globals.mousedown ', me.w.globals.mousedown)
let gridRectDim = me.gridRect.getBoundingClientRect()
me.startX = me.clientX - gridRectDim.left
me.startY = me.clientY - gridRectDim.top
me.w.globals.mousedown = true
}

if (me.w.globals.mousedown) {
me.panDragging({
context: me,
zoomtype,
xyRatios,
})
}
} else {
if (e.type === 'touchmove') {
if (!me.w.globals.mousedown) {
let gridRectDim = me.gridRect.getBoundingClientRect()
me.startX = me.clientX - gridRectDim.left
me.startY = me.clientY - gridRectDim.top
}
me.w.globals.mousedown = true
}
if (
(me.w.globals.mousedown && w.globals.zoomEnabled) ||
(me.w.globals.mousedown && w.globals.selectionEnabled)
Expand Down Expand Up @@ -679,6 +665,7 @@ export default class ZoomPanSelection extends Toolbar {
panDragging({ context }) {
const w = this.w
let me = context

// check to make sure there is data to compare against
if (typeof w.globals.lastClientPosition.x !== 'undefined') {
// get the change from last position to this position
Expand All @@ -696,14 +683,17 @@ export default class ZoomPanSelection extends Toolbar {
this.moveDirection = 'down'
}
}

// set the new last position to the current for next time (to get the position of drag)
w.globals.lastClientPosition = {
x: me.clientX,
y: me.clientY,
}

let xLowestValue = w.globals.isRangeBar ? w.globals.minY : w.globals.minX

let xHighestValue = w.globals.isRangeBar ? w.globals.maxY : w.globals.maxX

// on a category, we don't pan continuosly as it causes bugs
if (!w.config.xaxis.convertedCatToNumeric) {
me.panScrolled(xLowestValue, xHighestValue)
Expand Down