【问题标题】:How can I overwrite the .on() Method in Famo.us如何覆盖 Famo.us 中的 .on() 方法
【发布时间】:2014-11-09 06:02:22
【问题描述】:

第一次点击后我想改变我的 .on() 方法。

mySurface.on("touchstart",function(){
      doSomething();       
})

第一次点击后,我想将其更改为:

mySurface.on("touchstart",function(){
      doSomethingDifferent();       
})

如何覆盖我的 .on 方法?

【问题讨论】:

    标签: famo.us surface


    【解决方案1】:

    在您的情况下,实际上不需要覆盖 .on() 方法。

    这是处理用例的一种方法。

      var doSomethingElse = function(event) {
        console.log('doSomethingElse', event);
        console.log('mySurface', this);
      };
    
      var doSomething = function(event) {
        console.log('doSomething', event);
        console.log('mySurface', this);
        func = doSomethingElse;
      };
    
      var func = doSomething;
    
      mySurface.on("touchstart",function(event){
        func.call(this, event);       
      });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-07-08
      • 1970-01-01
      • 2016-07-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多