MCPcopy Index your code
hub / github.com/plotly/plotly.js / handleInteraction

Function handleInteraction

stackgl_modules/index.js:18298–18348  ·  view source on GitHub ↗
(buttons, x, y, mods)

Source from the content-addressed store, hash-verified

18296 }, hasPassive ? {passive: true} : false)
18297
18298 function handleInteraction (buttons, x, y, mods) {
18299 var keyBindingMode = camera.keyBindingMode
18300
18301 if(keyBindingMode === false) return
18302
18303 var rotate = keyBindingMode === 'rotate'
18304 var pan = keyBindingMode === 'pan'
18305 var zoom = keyBindingMode === 'zoom'
18306
18307 var ctrl = !!mods.control
18308 var alt = !!mods.alt
18309 var shift = !!mods.shift
18310 var left = !!(buttons & 1)
18311 var right = !!(buttons & 2)
18312 var middle = !!(buttons & 4)
18313
18314 var scale = 1.0 / element.clientHeight
18315 var dx = scale * (x - camera._lastX)
18316 var dy = scale * (y - camera._lastY)
18317
18318 var flipX = camera.flipX ? 1 : -1
18319 var flipY = camera.flipY ? 1 : -1
18320
18321 var drot = Math.PI * camera.rotateSpeed
18322
18323 var t = now()
18324
18325 if(camera._lastX !== -1 && camera._lastY !== -1) {
18326 if((rotate && left && !ctrl && !alt && !shift) || (left && !ctrl && !alt && shift)) {
18327 // Rotate
18328 view.rotate(t, flipX * drot * dx, -flipY * drot * dy, 0)
18329 }
18330
18331 if((pan && left && !ctrl && !alt && !shift) || right || (left && ctrl && !alt && !shift)) {
18332 // Pan
18333 view.pan(t, -camera.translateSpeed * dx * distance, camera.translateSpeed * dy * distance, 0)
18334 }
18335
18336 if((zoom && left && !ctrl && !alt && !shift) || middle || (left && !ctrl && alt && !shift)) {
18337 // Zoom
18338 var kzoom = -camera.zoomSpeed * dy / window.innerHeight * (t - view.lastT()) * 100
18339 view.pan(t, 0, 0, distance * (Math.exp(kzoom) - 1))
18340 }
18341 }
18342
18343 camera._lastX = x
18344 camera._lastY = y
18345 camera._lastMods = mods
18346
18347 return true
18348 }
18349
18350 camera.wheelListener = mouseWheel(element, function(dx, dy) {
18351 // TODO remove now that we can disable scroll via scrollZoom?

Callers 1

createCameraFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…