import { Component , Mixins , Prop } from "vue-property-decorator" ; import { BehaviourComponent } from "../../../src" ; @ Component export class HoverBehaviour extends Mixins ( BehaviourComponent ) { @ Prop ( { required : true , type : Object } ) public position ! : { y : number ; } ; @ Prop ( { type : Number , default : 1 } ) public distance ! : number ; @ Prop ( { type : Number , default : 1 } ) public speed ! : number ; private m_moveUp = true ; private m_originalY = 0 ; public created ( ) { const app = this . app ; const scene = this . scene ; const object = this . object ; this . m_originalY = this . position . y ; this . ready ( ) ; } public update ( deltaTime ) { this . position . y += deltaTime * ( this . m_moveUp ? 1 : - 1 ) * this . speed ; if ( this . position . y > this . m_originalY + this . distance ) { this . m_moveUp = false ; } else if ( this . position . y < this . m_originalY - this . distance ) { this . m_moveUp = true ; } } public destroyed ( ) { } public render ( h ) { return h ( "div" ) ; } }