Coder Social home page Coder Social logo

Comments (9)

indragiek avatar indragiek commented on April 29, 2024

#70 is caused by this same problem. Fixing this has the additional bonus of resolving that issue 🤘

from reactivecocoalayout.

jspahrsummers avatar jspahrsummers commented on April 29, 2024

You're probably seeing CGRectNull (or, at least, a rectangle passing the CGRectIsNull test).

yielding negative values for some members, which won't throw an exception

Most CGRect functions will standardize the provided rectangle, which would turn a negative width/height into a flipped rectangle. That's an incorrect (and probably very confusing) result.

check for NaN values afterwards, replacing them with 0's or something suitable

This could also cause problems, since some views don't gracefully handle having a zero size.


TBH, I don't have a good answer to this. No potential solution here (including "don't do that") is really satisfactory, since they all cause incorrect or obnoxious behavior of some sort.

from reactivecocoalayout.

indragiek avatar indragiek commented on April 29, 2024

What about adding an operator that lets you pass in a parameter of a rect rect signal to use in place of CGRectNull?

from reactivecocoalayout.

jspahrsummers avatar jspahrsummers commented on April 29, 2024

To really do it right, it'd have to be an error not to provide a null mapping.

I guess we should just use an empty rectangle. That's what division does right now.

from reactivecocoalayout.

indragiek avatar indragiek commented on April 29, 2024

Are you proposing that the null mapping be accepted as a parameter into any method that could yield a CGRectNull value or that it be an operator that can be applied to any signal that sends CGRects?

from reactivecocoalayout.

jspahrsummers avatar jspahrsummers commented on April 29, 2024

I'm saying that in order for a mapping to be valuable, it would have to be required anywhere a CGRectNull might appear — otherwise, nobody will know the variant is there, and we're back to the same shitty exceptions.

Of course, that'd be a huge burden for maintainers and consumers of the framework, and still doesn't prevent a null rectangle from slipping through when binding to frame/rcl_frame, so I think falling back to an empty rectangle is better.

from reactivecocoalayout.

indragiek avatar indragiek commented on April 29, 2024

otherwise, nobody will know it's there, and we're back to the same shitty exceptions.

I think I disagree there, because this is nothing new to anyone who uses CGRectInset by itself. It's logical to assume that a signal operator that wraps CGRectInset would have the same caveats. An optional mapping using a separate operator would eliminate the burden of having to enforce it and give people an easy option for resolving the problem in cases where they know that it's possible for a CGRectNull value to be generated.

from reactivecocoalayout.

indragiek avatar indragiek commented on April 29, 2024

Also, applying said operator at the end of the signal chain would guarantee that it does not get passed through to rcl_frame.

from reactivecocoalayout.

jspahrsummers avatar jspahrsummers commented on April 29, 2024

We can adjust the inset operator, but it absolutely should have a required nullRect: parameter (using a constant rectangle, since it's just meant as a fallback). If the user doesn't care about that case, they can pass in CGRectNull anyways.

from reactivecocoalayout.

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.