Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

238
Views
How to make a function run only during a click, not a click and drag

I have a function that grabs the mouses lat and long in cesium when the mouse is clicked. However, if you drag, it still runs the function. I put an if statement in the function to make sure it runs when my variable, app.drag is false. app.drag is turned to true when the mouse moves. Now I need to check when the mouse has stopped so app.drag can go back to false. Doing !'mousemove' doesn't work so how do you do that? I think this is the best method to check if the mouse is dragged, but if there's a simpler way, please let me know. My code:

    app.drag = false;
    app.viewer.scene.canvas.addEventListener("mousemove", () => app.drag = true);
    app.viewer.scene.canvas.addEventListener("click", function(e) {
      if (!app.drag) {
        let ellipsoid = app.viewer.scene.globe.ellipsoid;
        let cartesian = app.viewer.camera.pickEllipsoid(new Cesium.Cartesian3(e.clientX, e.clientY), ellipsoid);
        let cartographic = ellipsoid.cartesianToCartographic(cartesian);
        let latitude = Cesium.Math.toDegrees(cartographic.latitude);
        let longitude = Cesium.Math.toDegrees(cartographic.longitude);
        document.getElementById("lat").value = Math.round(latitude);
        document.getElementById("lon").value = Math.round(longitude);
      }
    });
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!