Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to pass placeholder config as HTMLElement #489

Closed
christophe-g opened this issue Feb 22, 2019 · 0 comments
Closed

Allow to pass placeholder config as HTMLElement #489

christophe-g opened this issue Feb 22, 2019 · 0 comments

Comments

@christophe-g
Copy link
Contributor

Motivation:

  • In general: have greater flexibility for manipulating placeholder (e.g. changing its content depending on start-drag scenario).
  • In my particular use case: allow polymer data-binding for placeholder as pseudo-code below
<dom-module id="custom-drag-container">
  <template>
      <div id="placeholder">
         <div class="placeholder">[[placeHolderContent]]</div>
      </div>
      <polymer-sortable handle="#drag" placeholder="[[placeholder]]">
          <dom-repeat items="[[arrayItems]]" > 
             <repeated-items></repeated-items>
         </dom-repeat>
      </polymer-sortable>
  </template>
</dom-module>
 class CustomDragElement extends Polymer.Element {
      static get properties() {
        return {
            /*
             * `placeholder` the Element to use as sortable placeholder
             */
             placeholder: {
               type: Object
            },

            /*
             * `placeholderContent` content of placeholder
             */
            placeholderContent: {
              type: String, 
              value: 'new question'
            }

        }

       connectedCallback() {
        super.connectedCallback();
        Polymer.RenderStatus.afterNextRender(this, () => {
          // set placeholder as HTMLElement
          this.placeholder = this.$.placeholder;
          this.addEventListener('sort-start', this._onSortStart);

        });
      }

     _onSortStart(e) {
        console.info(e);
        this.placeholderContent =  ... handle logic to change placeholder content ... 
      }
}

As for #488, will submit a PR soon (with much less code change as this is really a simple change)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant