2017-06-30 5 views
1

私はDOMエレメント(here)にポインターイベントリスナーを付けるjavascriptライブラリーを構築しました。今日、私はFirefoxの上のポインタイベントをポリフィルするPEPを使用して、それをラップするポリマー1.9 Webコンポーネントでそれを使用していて、それが正常に動作します:Polymer 2でFirefox上のWebコンポーネントでPointerイベントを捕捉する方法は?

<link rel="import" href="./pepjs-import.html"> 
<link rel="import" href="./myscriptjs-import.html"> 

<dom-module id="myscript-common-element"> 
<template> 
    <style></style> 
    <div id="editorDomElement" class="ms-editor"></div> 
</template> 
<script> 
    Polymer({ 
       is: 'myscript-common-element', 
       properties: {}, 
       attached: function() { 
        this.editorDomElement = this.querySelector('#editorDomElement'); 
        // Attach an editor to the DOM element and listen pointer events 
        this.editor = MyScript.register(this.editorDomElement, this.buildConfiguration(), this.buildCustomStyle()); 
       } 
      } 
    ); 
</script> 

私はちょうどレジスタの下elementDomElement.addEventListener('pointerdown', (e) => { // Some code });をやっています、 特にない。

ポリマー2に移行した後、私はそのような何かしている:

<dom-module id="myscript-common-element"> 
<template> 
    <style></style> 
    <div id="editorDomElement" class="ms-editor"></div> 
</template> 
<script> 
    class MyScriptCommonElement extends Polymer.mixinBehaviors([Polymer.IronResizableBehavior], Polymer.Element) { 

     static get is() { 
      return 'myscript-common-element' 
     } 

     connectedCallback() { 
      super.connectedCallback(); 
      this.editorDomElement = this.shadowRoot.querySelector('#editorDomElement'); 
      this.editor = MyScript.register(this.editorDomElement, this._buildConfiguration(), this._buildCustomStyle()); 
     } 
    } 
    customElements.define(MyScriptCommonElement.is, MyScriptCommonElement); 
</script> 

ポインタイベントが正しくChromeとエッジの下で処理されますが、FirefoxのイベントにshadowRootに立ち往生しています。もし私がthisで聴いていると、私はそれらを扱うことができます。 shadowRootですが、editorDomElementにはありません。

私は何か間違っているのですか、またはFirefoxのPolymer 2イベント転送に関する問題ですか?それを動作させるための解決策または回避策がありますか? ありがとう

+0

完全なポリマー1.9のコードを: https://github.com/MyScript/myscript-common-element/blob/2.0.0-alpha1/myscript-common-element.html – FXG

答えて

0

ポリマー2.0では、eventsは、シャドウルートの煙の上で煙が止まり、消えます。

あなたはイベントがshadowRoots外に漏れるようにしたい場合は、あなたがにdispatchEvent機能で合成属性を渡す必要があります:

this.dispatchEvent('my-event', { bubbles: true, composed: true }); 

はこちら続きを読む:Fire Custom Events (polymer-project.org)

+0

はい、私はそれを読みましたが、私の問題はイベントを送信することではありません。それを捕まえるために、そしてFirefox上でのポインタイベントだけです。申し訳ありませんが明示的でない場合は、トピック名を変更します。 – FXG

関連する問題