paper-ripple mouseDown事件处理程序downAction覆盖

时间:2015-10-11 02:07:58

标签: javascript polymer polymer-1.0 paper-elements

聚合物1.1

paper ripple source code中,他们拥有mouseDown事件处理程序:

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

在文件中说明:

  

paper-ripple会侦听“mousedown”和“mouseup”事件,因此触摸它时会显示涟漪效应。您还可以打败默认行为并手动将向下和向上操作路由到波纹元素

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

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

当我通过点击我的元素来引发纸张波纹的动作时,我没有得到任何控制台输出。

如何覆盖downAction mouseDownpaper-ripple所记录的using System.Runtime.InteropServices; using System.Text; using System.Threading.Tasks; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { HandlerRoutine hr = new HandlerRoutine(InspectControlType); SetConsoleCtrlHandler(hr, true); Console.WriteLine("Click on Windows Close Button"); Console.ReadLine(); } [DllImport("Kernel32")] public static extern bool SetConsoleCtrlHandler(HandlerRoutine Handler, bool Add); public delegate bool HandlerRoutine(ControlTypes CtrlType); public enum ControlTypes { CTRL_C_EVENT = 0, CTRL_BREAK_EVENT, CTRL_CLOSE_EVENT, CTRL_LOGOFF_EVENT = 5, CTRL_SHUTDOWN_EVENT } private static bool InspectControlType(ControlTypes ctrlType) { Console.WriteLine("Hello You choose to end this program.Do you really want to close? :" + ctrlType.ToString()); Console.ReadLine(); return true; } } } 的默认float处理程序?

1 个答案:

答案 0 :(得分:1)

最有可能的文档假定应该添加一个监听器,比如

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

你仍然可以覆盖这些方法,但这可能不是应该如何使用涟漪元素:

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