question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Pan to centre on click

See original GitHub issue

I need to pan the clicked object to the center every time. It works when I set the _viewer.viewport.goHome(true); before re pan / Zoom but when I remove it does not bring the object to the center of the screen. Please let me know where I’m wrong. Thanx

export function setTransformationLevel(scaleLevel, x, y) {
 _viewer.viewport.goHome(true);
    let point = snapDragon.getMousePosition({ pageX: x, pageY: y });
    let vp = _viewer.viewport.pointFromPixel(point, true);
    let vpX = vp.x;
    let vpY = vp.y;
    if (x <= 146 || x >= 1275 || y < 47 || y>624.9793700777778) {
      _viewer.viewport.zoomTo(scaleLevel, new snapDragon.Point(vpX, vpY), false);
      return true;
    }else{
    _viewer.viewport.panTo({ x:vpX, y:vpY}); 
    _viewer.viewport.zoomTo(scaleLevel,null, false);
    }
  return true;
}

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:16 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
iangilmancommented, Jun 14, 2021

Sure, here’s an example using fitBounds:

https://codepen.io/iangilman/pen/poeqovO

1reaction
jamtechdevcommented, Jun 28, 2021

@iangilman Sir, Thank you so much. Things are working as expected now. It would never have happened without your guidance.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Google Map Pan to center when clicking a link - Stack Overflow
Objective: When a user click on a link, Google Map will pan to the center of the location. Current: User click on Marker,...
Read more >
Middle mouse button or wheel does not perform PAN ...
In the Windows control panel, double-click the Mouse icon to open the Mouse Properties dialog window. Click the Buttons tab. In the Wheel...
Read more >
Configuring mouse centre scroll click to pan drawing
Ive got a Logitech LS1 laser mouse which is a standard mouse with a scroll wheel which is clickable. On some machines ive...
Read more >
Zoom and pan in a diagram - Microsoft Support
Right-click and drag to pan the diagram. Pan and zoom by using the scroll wheel. Do either of the following: To scroll up...
Read more >
Set track pan positions in GarageBand on Mac - Apple Support
In GarageBand on Mac, set the pan or balance position of each track in a project to place ... Option-click the Pan knob...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found