【问题标题】:Aframe animation component not removingAframe 动画组件未删除
【发布时间】:2016-11-18 22:26:23
【问题描述】:

我尝试了几种方法来删除动画(从 html 属性本身):

element.components["animation__0"].remove(); 
//above works, but has no affect on html list, just "stops" animation.  

delete element.components.animation__0;
//works, in theory but html attribute still there

$("#id").removeAttr("animation__0"); //导致以下错误:

aframe-animation-component.js:468 Uncaught TypeError: Cannot read property '2' of null(…)
getUnit @   aframe-animation-component.js:468
getValidValue   @   aframe-animation-component.js:523
getTweenValues  @   aframe-animation-component.js:584
(anonymous function)    @   aframe-animation-component.js:601
(anonymous function)    @   aframe-animation-component.js:594
getTweensProps  @   aframe-animation-component.js:592
getTweens   @   aframe-animation-component.js:614
createAnimation @   aframe-animation-component.js:755
animation   @   aframe-animation-component.js:784
update  @   aframe-animation-component.js:128
updateProperties    @   component.js:211
value   @   a-entity.js:446
value   @   a-entity.js:607
attr    @   jquery.js?hash=22a0055…:8028
removeAttr  @   jquery.js?hash=22a0055…:8068
(anonymous function)    @   jquery.js?hash=22a0055…:7991
each    @   jquery.js?hash=22a0055…:442
each    @   jquery.js?hash=22a0055…:194
removeAttr  @   jquery.js?hash=22a0055…:7990
(anonymous function)    @   VM8102:1

在删除组件等后我也尝试过 flushToDOM()... 似乎没有更改任何 html

代码笔:http://codepen.io/msj121/pen/yVVmvL

【问题讨论】:

    标签: aframe


    【解决方案1】:

    看看你的这个笔叉: http://codepen.io/thoragio/pen/xRgKBQ

    我将cylinder.components["animation__scale"].remove(); 替换为cylinder.removeAttribute("animation__scale");,现在正在更新DOM。

    另外,第一个 console.log() 需要在 setTimeout() 方法之外,否则您只是同时调用它们。

    【讨论】:

    • 遗憾的是,如问题中所述,flushToDOM 不起作用。我将发布更多代码。
    • 看起来 Jquery 版本是导致错误的问题。但是很高兴提醒您使用非 Jquery 方法,因为在框架中更新 Jquery 似乎并不容易,谢谢。
    • 没问题。很高兴能提供帮助。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-06-12
    • 1970-01-01
    相关资源
    最近更新 更多