HomeDocs
Skip to main content

dlt.createAnimation

Introduction​

Create an animation instance animation.

Parameters​

Object object

Return Value​

Animation

Explanation of object parameters​

PropertyTypeRequiredDefaultDescription
durationNumberNo400Duration of the animation (in ms)
timingFunctionStringNo'linear'Defines the animation effect
delayNumberNo0Delay time of the animation (in ms)
transformOriginStringNo'50% 50% 0'The origin of the animation transformation

Valid values for timingFunction​

ValueDescription
linearStarts and ends at the same speed
easeStarts slowly, then speeds up, and slows down at the end
ease-inStarts slowly
ease-in-outStarts and ends slowly
ease-outEnds slowly
step-startJumps to the end state at the first frame and stays there
step-endStays in the start state and jumps to the end state at the last frame

Sample Code​

<view class="wrap">
<view class="anim" bind:tap="startToAnimate" :animation="animationData"></view>
</view>
Page({
data: {
animationData: {}
},
startToAnimate() {
const animation = dlt.createAnimation({
transformOrigin: '50% 50%',
duration: 1000,
// timingFunction can also be ease, ease-in, ease-in-out, ease-out, step-start, step-end
timingFunction: 'linear',
delay: 0
});
animation.rotate(90).translateY(10).step();
this.setData({
animationData: animation.export()
});
console.log('createAnimation', animation);
}
});
Privacy agreementDeveloper agreementcontact us: developer_private.mi@dlightek.com © 2024 MiniApp. All Rights Reserved.