Skip to content

fix: css calc inline break app#9582

Closed
vallemar wants to merge 222 commits intoNativeScript:release/8.2.0from
vallemar:master
Closed

fix: css calc inline break app#9582
vallemar wants to merge 222 commits intoNativeScript:release/8.2.0from
vallemar:master

Conversation

@vallemar
Copy link
Contributor

@vallemar vallemar commented Sep 28, 2021

If you insert the width property: calc(x - x); in an element with inline styles the application breaks, it also happens if you do object.nativeView.width = "calc(x - x)"

Works fine if put as styles of a class.

.bar{
   width: calc(x - x);
}

Sample project
https://play.nativescript.org/?template=play-vue&id=mncNi9&v=2

Note: with NS 8.1.x it also breaks the app

Fix: #9581

farfromrefug and others added 30 commits August 27, 2020 09:19
That way we dont “unload” and “load” fragments.
This fixes black screens and slow transitions with opengl or cameras

# Conflicts:
#	packages/core/ui/frame/fragment.transitions.android.ts
#	packages/core/ui/frame/frame-common.ts
#	packages/core/ui/frame/index.android.ts
should be done in a plugin
It comes with a major refactoring of the BorderDrawable. Now all Paths are cached not to regenerate them on every draw pass.

Also it is important to understand that the clipping feature on android comes at a cost.
It will be done only when truelly necessary. but with complex paths ((border radius > 0 && border non uniform) || border-width >0) then we must apply a costly drawing pass (though hardware accelerated) to accomplish it.
This should not happen but it does. Did not manage to find the real source but it seems ok to test it here. Plus if it happens the measurement chain for that view will be broken
# Conflicts:
#	package.json
#	packages/core/bundle-entry-points.ts
#	packages/core/color/color-common.ts
#	packages/core/color/index.d.ts
#	packages/core/globals/index.ts
#	packages/core/package.json
#	packages/core/ui/core/bindable/index.ts
#	packages/core/ui/core/properties/index.ts
#	packages/core/ui/core/view/index.android.ts
#	packages/core/ui/frame/index.android.ts
#	packages/core/ui/styling/style-scope.ts
#	packages/ui-mobile-base/android/gradle/wrapper/gradle-wrapper.properties
#	packages/webpack5/package.json
#	packages/webpack5/src/configuration/base.ts
@cla-bot cla-bot bot added the cla: yes label Sep 28, 2021
NathanWalker
NathanWalker previously approved these changes Sep 28, 2021
Copy link
Contributor

@NathanWalker NathanWalker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent 👏

@rigor789
Copy link
Member

Thanks for the PR, calc is a CSS feature - so in this case, I'd say it's working as intended.

We can make it work on properties like this - but I'm a little hesitant on the change due to the processing overhead of evaluating the expressions.

I would like us to run a few benchmarks, and hold off on merging this right away - some numbers would make this easier to reason about.

/cc @NathanWalker @farfromrefug

@vallemar
Copy link
Contributor Author

vallemar commented Sep 28, 2021

I agree with what you say. I think that setting the property in the nativeView.width = calc(x - y) format might be part of the developer to calculate the size, but I also think that inline styles should work and currently does not. Anyway I would like to see numbers. How do you normally do this?

@edusperoni
Copy link
Contributor

Inline style should work with view.setInlineStyle("width: calc(x)"), does it not?

Maybe view.style.width="calc(x)" also should work?

I believe the distinction here is that views have different ways of setting their properties and CSS is an abstraction on top of them.

@cla-bot
Copy link

cla-bot bot commented Oct 13, 2021

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign the CLA at https://www.nativescript.org/cla.
CLA has not been signed by users: @crowmagnumb, @tarunama.
After signing the CLA, you can ask me to recheck this PR by posting @cla-bot check as a comment to the PR.

@cla-bot cla-bot bot removed the cla: yes label Oct 13, 2021
@vallemar
Copy link
Contributor Author

Sorry, I have done a push of everything without wanting to, I have deleted the repo thinking that the PR would be deleted but it has not been like that. I don't usually work with github XD

@NathanWalker NathanWalker added this to the 8.2 milestone Oct 21, 2021
@NathanWalker
Copy link
Contributor

@vallemar Have you tried @edusperoni comments above? Let us know if those options do not work - if they do, we may want to close this.

@vallemar
Copy link
Contributor Author

vallemar commented Oct 25, 2021

@NathanWalker @edusperoni I have tested the scenarios and this is the result without the PR

view.setInlineStyle("width: calc(200 - 10)") //WORK
view.style.width= "calc(200 - 10)"  //NO WORK
view.width= "calc(200 - 10)"  //NO WORK

Now when I have typed the object to type view I have realized that it is of type CoreTypes.PercentLengthType view.style.width and view.width

@NathanWalker NathanWalker changed the base branch from master to release/8.2.0 February 17, 2022 03:15
@rigor789 rigor789 deleted the branch NativeScript:release/8.2.0 March 8, 2022 22:43
@rigor789 rigor789 closed this Mar 8, 2022
@rigor789
Copy link
Member

rigor789 commented Mar 8, 2022

Looks like the 8.2.0 merge auto deleted and closed this, and I can't seem to reopen it.

Not sure what the consensus is regarding the change, we can still discuss it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

css calc inline break app

7 participants