纸纹mouseDown事件处理程序downAction重写 [英] paper-ripple mouseDown event handler downAction Override

查看:89
本文介绍了纸纹mouseDown事件处理程序downAction重写的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

聚合物1.1

纸张波纹源代码中,它们具有mouseDown事件处理程序:

In paper ripple source code they have the mouseDown event handler:

  /** @param {Event=} event */
  downAction: function(event) {
    var xCenter = this.containerMetrics.width / 2;
    var yCenter = this.containerMetrics.height / 2;

在文档中指出:

paper-ripple会监听"mousedown"和"mouseup"事件,因此触摸它们时会显示涟漪效果.您还可以取消默认行为,并将向下和向上操作手动路由到涟漪元素

paper-ripple listens to "mousedown" and "mouseup" events so it would display ripple effect when touches on it. You can also defeat the default behavior and manually route the down and up actions to the ripple element

但是,在我的自定义元素中,我无法覆盖此处理程序:

However, in my custom element I am not able to override this handler:

        <paper-ripple
          fit
          id="ripple"
          initial-opacity="0.95"
          opacity-decay-velocity="0.98">
        </paper-ripple>
      </section>
    </template>
  </template>

  <script>
    Polymer({
      is: "portfolio-page",
     ...
      downAction: function(e) {
        console.log('sssssssssssssssssssssssss');
      },
      upAction: function(e) {
        this.$.ripple.upAction();
      }

当我通过单击元素引起纸张波纹的动作时,没有任何控制台输出.

When I induce the action of paper ripple by clicking on my element, I do not get any console output.

paper-ripple监听的mouseDown的默认downAction处理程序="nofollow">纸质文档?

How do I override the default downAction handler for mouseDown that paper-ripple listens for as documented in paper-ripple doc?

推荐答案

最有可能的文档假设一个人应该添加一个侦听器,例如

Most likely documentation assumes that one should add a listener, like

listeners: {
    'up' : 'upAction',
    'down' : 'downAction',
}

您仍然可以覆盖方法,但这可能不是应该使用涟漪元素的方式:

you still can override the methods, but that's probably not how ripple element was supposed to be used:

ready: function(){
   this.ripplesDownAction = this.$.ripple.downAction.bind(this.$.ripple);
   this.$.ripple.downAction = this.downAction.bind(this);
},

downAction: function(e) {
    console.log('sssssssssssssssssssssssss');
    this.ripplesDownAction();
}

这篇关于纸纹mouseDown事件处理程序downAction重写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆