Javascript Konva vue js文本滑入舞台,然后停止

Javascript Konva vue js文本滑入舞台,然后停止,javascript,vue.js,canvas,konvajs,Javascript,Vue.js,Canvas,Konvajs,嗨,我在vue中使用konva js(),我正在尝试设置文本动画,使其从舞台上滑到屏幕上的某个位置,但是我不是100%确定这应该如何工作,我已经能够在这里进行演示 Vue 常量宽度=window.innerWidth; const height=window.innerHeight; 导出默认值{ 数据(){ 返回{ 阶段化:{ 宽度:宽度, 高度:高度 } }; }, 方法:{ 更改大小(e){ //to()是'Konva.Node'实例的方法 e、 target.to({ scaleX:

嗨,我在vue中使用konva js(),我正在尝试设置文本动画,使其从舞台上滑到屏幕上的某个位置,但是我不是100%确定这应该如何工作,我已经能够在这里进行演示

Vue


常量宽度=window.innerWidth;
const height=window.innerHeight;
导出默认值{
数据(){
返回{
阶段化:{
宽度:宽度,
高度:高度
}
};
},
方法:{
更改大小(e){
//to()是'Konva.Node'实例的方法
e、 target.to({
scaleX:Math.random()+0.8,
scaleY:Math.random()+0.8,
持续时间:0.2
});
}
},
安装的(){
const vm=这个;
常数振幅=100;
常数周期=5000;
//在ms中
const centerX=vm.$refs.stage.getStage().getWidth()/2;
const text=this.$refs.text1.getStage();
//Konva.Animation的示例
const anim=新的Konva.Animation(函数(帧){
text.setX(
振幅*Math.sin((帧时间*2*Math.PI)/周期)+centerX
);
},text.getLayer());
anim.start();
}
};

你知道如何让文本从舞台外部显示,然后在画布内的某个点停止吗?

你可以使用
node.to()
方法对任何
Konva.node
进行动画制作:

mounted() {
    const textNode = this.$refs.text1.getNode();
    const endX = width / 2 - textNode.width() / 2;
    // run the animation
    textNode.to({
      x: endX,
      onFinish: () => {
        // update the state at the end
        this.textPos.x = endX;
      }
    })
  }
演示:

mounted() {
    const textNode = this.$refs.text1.getNode();
    const endX = width / 2 - textNode.width() / 2;
    // run the animation
    textNode.to({
      x: endX,
      onFinish: () => {
        // update the state at the end
        this.textPos.x = endX;
      }
    })
  }