1

Check this documentation:

https://docs.nativescript.org/ui/animation

I'm trying to add a class or ID of this element as <Label> to animate anything but I'm not sure what's is supposed to assign an element using view to take full control of any animation by calling animation methods directly with code instead of CSS animations in Vue template.

1 Answer 1

8

there's a good example of doing this from the Groceries sample app by Tiago Alves. I borrowed some of his code here, and you can animate like this:

Give your element a ref:

<AbsoluteLayout marginTop="-340" ref="logoContainer" class="logo-container">
    <Image translateY="0" src="res://seal" stretch="none"/>
</AbsoluteLayout>

and then grab that ref and animate it using the standard NativeScript Animation API:

this.$refs.logoContainer.nativeView
    .animate({
      translate: { x: 0, y: platformModule.isAndroid ? -70 : -50 },
      duration: 500,
      curve: enums.AnimationCurve.easeIn })
    .then(() => {
      this.state = 'main'
    })
Sign up to request clarification or add additional context in comments.

1 Comment

Your original code gave me some errors, but I managed to edit some undefined objects and it worked. Replace platformModule.isAndroid to some number like -50 just as y: -50 and comment curve: enums.AnimationCurve.easeIn it seems enums is undefined too, also comment this.state = "main" because this callback is optional.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.