GithubHelp home page GithubHelp logo

Updating Constraint contant? about snapkit HOT 5 CLOSED

snapkit avatar snapkit commented on May 3, 2024
Updating Constraint contant?

from snapkit.

Comments (5)

robertjpayne avatar robertjpayne commented on May 3, 2024

Define how you would like to update said constraint? Are you looking to just update the "constant" or also re-assign the LHS/RHS?

If you strictly say want to update that 107 to maybe 40 or something you would just need to:

snp_updateConstraints { make in
    make.top.equalTo(40)
}

from snapkit.

nickvelloff avatar nickvelloff commented on May 3, 2024

Thanks for responding.
I would like to update the self.leftConstraint constant such that left is now = self.view.snp_left, instead of right.
The real goal is to animate draftsSiteManagement from where is off screen to 0 (on screen).
Basically like I would do with a standard NSLayoutConstraint constraint.constant = 5

from snapkit.

nickvelloff avatar nickvelloff commented on May 3, 2024

After reading your other response to my other question I think I'm not approaching this properly.
I probably need to uninstall the constraint and apply a new one and layoutIfNeeded() in an animation block.

from snapkit.

robertjpayne avatar robertjpayne commented on May 3, 2024

@nickvelloff it's important to note there are a couple parts to a constraint. Remember the constant is strictly the offset value of the constraint. Constraints are formulated as such:

(LHS) (RELATION) (RHS)? * (MULTIPLIER) + (CONSTANT)

The RHS can be nil, in cases where you do an equalTo(<non-view-value>) you are actually essentially doing: equalTo(nil).offset(<non-view-value>).

So yes in your particular case you are altering the LHS/RHS of the constraint and thus need a new one.

from snapkit.

nickvelloff avatar nickvelloff commented on May 3, 2024

I was confusing the meaning of self.view.snp_right with it evaluating that value and using it as a <non-view-value> constant. Newbie mistake, thanks for the clarification.

from snapkit.

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.