pirony / ks-vue-scrollmagic

Vue plugin that makes using Scrollmagic with Vue a walk in the park
MIT License
45 stars 9 forks source link

When using $emit('destroy') scenes in plugin data are not destroyed #8

Open morganlegal opened 6 years ago

morganlegal commented 6 years ago

Maybe it is designed so on purpose, but it seems to me that if you destroy the controller the scenes attached to it should be erased too.

Someting like:

   created () {
      const vm = this
      vm.$on('addScene', (name, scenes) => {
        Vue.nextTick(() => {
          if(vm.controller === null) vm.controller = new vm.$scrollmagic.Controller();
          vm.scenes[name] = scenes
          vm.scenes[name].addTo(vm.controller)
        })
      })
      vm.$on('destroyScene', (name) => {
        vm.scenes[name].destroy(true)
      })
      vm.$on('destroy', (name, scenes) => {
        vm.scenes = {}
        vm.controller.destroy(true)
        vm.controller = null
      })
    }
pirony commented 6 years ago

Hi @Morganlegal, you're right, will be fixed in next release. Thx for your feedback

morganlegal commented 6 years ago

Perfect. Thank you