Skip to content

the question about the guide of the chapter of the State Transitions #1574

Open
@darkleave

Description

@darkleave

Transitions & Animation >> State Transitions >> Organizing Transitions into Components

the code here:

Vue.component('animated-integer', {
template: '{{ tweeningValue }}',
props: {
value: {
type: Number,
required: true
}
},
data: function () {
return {
tweeningValue: 0
}
},
watch: {
value: function (newValue, oldValue) {
this.tween(oldValue, newValue)
}
},
mounted: function () {
this.tween(0, this.value)
},
methods: {
tween: function (startValue, endValue) {
var vm = this
function animate () {
if (TWEEN.update()) {
requestAnimationFrame(animate)
}
}

  new TWEEN.Tween({ tweeningValue: startValue })
    .to({ tweeningValue: endValue }, 500)
    **.onUpdate(function (object) {
      vm.tweeningValue = object.tweeningValue.toFixed(0)
    })**
    .start()

  animate()
}

}
})

it should be:
.onUpdate(function () {
vm.tweeningValue = this.tweeningValue.toFixed(0)
})

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions