Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
junedchhipa committed May 12, 2024
2 parents c1fb18d + 5e0c696 commit 21247c1
Showing 1 changed file with 8 additions and 18 deletions.
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

0 comments on commit 21247c1

Please sign in to comment.