paper-ripple mouseDown event handler downAction Override

爱⌒轻易说出口 提交于 2020-01-16 03:41:23

问题


Polymer 1.1

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;

In documentation it states:

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.

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


回答1:


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();
}


来源:https://stackoverflow.com/questions/33060861/paper-ripple-mousedown-event-handler-downaction-override

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!