GithubHelp home page GithubHelp logo

Comments (2)

traviskirton avatar traviskirton commented on June 14, 2024

Got it.

You should do this:

square.addPanGestureRecognizer { locations, center, translation, velocity, state in
    let p = self.canvas.convert(center, from: square)
    square.center = p
}

This converts the gesture's center point to it's relative position in the canvas.

Reasoning...

The demo attaches the gesture to the canvas. However, you're attaching the gesture to the shape itself, which causes the flicker because of this:

  1. your touch starts in the center of the shape {50,50}
  2. square.center = center sets the shape's actual center to {50, 50}
  3. your touch doesn't move relative to the canvas, and...
  4. your touch is now at a relative point outside the shape, let's say ~{200,200}
  5. square.center = center sets the shape's center to ~{200,200}
  6. your touch is now in the shape again, and measured relative to the shape's top-right corner
  7. square.center = center sets the shape's actual center to ~{50, 50}
  8. repeat...

from c4ios.

traviskirton avatar traviskirton commented on June 14, 2024

The warning you get is something that comes with Xcode8, we get it too... Doesn't seem to affect anything.

from c4ios.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.