Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[iOS] NativescriptAnimationModule doesn't work when using shadow on iOS #21

Open
acivier-serial opened this issue Sep 25, 2019 · 3 comments

Comments

@acivier-serial
Copy link

When using the NativeScriptAnimationsModule with shadow on a element you got this error:
ERROR Error: View already has a parent. View: Button(3) Parent: StackLayout(2)

Which platform(s) does your issue occur on?

  • iOS

Please, provide the following version numbers that your issue occurs with:

  • CLI: 6.1.2
  • Cross-platform modules: 6.1.0
  • Runtime: 6.1.0
  • Plugin(s):
    • "nativescript-ngx-shadow": "6.5.0"
    • "nativescript-angular": "8.2.0"

Please, tell us how to recreate the issue in as much detail as possible.

Just import the NativeScriptAnimationsModule in your app.module.ts then use the shadow directive on an element.

This is probably caused by the addIosWrapper function inside the directive

private addIosWrapper() {
if (isIOS) {
const originalElement = this.el.nativeElement as View;
this.iosShadowRapper = this.render.createElement(
'StackLayout'
) as StackLayout;
// wrappingElement.cssClasses = mainElement.cssClasses;
const parent = originalElement.parentNode;
this.render.insertBefore(parent, this.iosShadowRapper, originalElement);
this.render.removeChild(parent, originalElement);
this.render.appendChild(this.iosShadowRapper, originalElement);
}
}

Is there any code involved?

Here is a sample project to reproduce the issue : https://github.com/acivier-serial/issue-ngx-shadow-angular-animation

@pekevski
Copy link

This is impacting me as well.

@alexist
Copy link

alexist commented Apr 7, 2021

same issue for me, is there a workaround ?

@alexist
Copy link

alexist commented Apr 7, 2021

just found a workaround

    this.render.removeChild(parent, originalElement); 
    if (originalElement.parentNode) {
        originalElement.parentNode.removeChild(originalElement);
    }

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

No branches or pull requests

3 participants