3.0.1 • Published 6 years ago

@polymer/iron-resizable-behavior v3.0.1

Weekly downloads
29,407
License
BSD-3-Clause
Repository
github
Last release
6 years ago

Published on NPM Build status Published on webcomponents.org

IronResizableBehavior

IronResizableBehavior is a behavior that can be used in Polymer elements to coordinate the flow of resize events between "resizers" (elements that control the size or hidden state of their children) and "resizables" (elements that need to be notified when they are resized or un-hidden by their parents in order to take action on their new measurements).

Elements that perform measurement should add the IronResizableBehavior behavior to their element definition and listen for the iron-resize event on themselves. This event will be fired when they become showing after having been hidden, when they are resized explicitly by another resizable, or when the window has been resized.

Note, the iron-resize event is non-bubbling.

See: Documentation, Demo.

Usage

Installation

npm install --save @polymer/iron-resizable-behavior

In a Polymer 3 element

import {PolymerElement, html} from '@polymer/polymer';
import {mixinBehaviors} from '@polymer/polymer/lib/legacy/class.js';
import {IronResizableBehavior} from '@polymer/iron-resizable-behavior/iron-resizable-behavior.js';

class SampleElement extends mixinBehaviors([IronResizableBehavior], PolymerElement) {
  static get template() {
    return html`
      <style>
        :host {
          display: block;
          position: absolute;
          top: 0;
          right: 0;
          bottom: 0;
          left: 0;
        }
      </style>
      <span>width: [[width]] </span>
      <span>height: [[height]]</span>
    `;
  }

  static get properties() {
    return {
      width: Number,
      height: Number,
    }
  }

  connectedCallback() {
    super.connectedCallback();
    this.addEventListener('iron-resize', this.onIronResize.bind(this));
  }

  onIronResize() {
    this.width = this.offsetWidth;
    this.height = this.offsetHeight;
  }
}
customElements.define('sample-element', SampleElement);

Contributing

If you want to send a PR to this element, here are the instructions for running the tests and demo locally:

Installation

git clone https://github.com/PolymerElements/iron-resizable-behavior
cd iron-resizable-behavior
npm install
npm install -g polymer-cli

Running the demo locally

polymer serve --npm
open http://127.0.0.1:<port>/demo/

Running the tests

polymer test --npm
@infinitebrahmanuniverse/nolb-_pol@everything-registry/sub-chunk-731@aspen-elements/google-map@aspen-elements/s-circle-progress@aigan/iron-overlay-behavior@atomiko/google-map-holdout@danielturner/google-map@custom-pdf-viewer/custom-pdf-viewerratinglsitratingbarpaper-carousel@flowingcode/google-mapub-date-pickerunity-core-betaz-report-designer-cmtz-report-designer-compz-report-designer-componentvaadin-flow-bomvaadin-gridsoniacomponent@hakanc/google-map@doubletrade/google-map@appreciated/color-picker@anviltech/wuf-poly-paper-elements@hatiolab/things-shell@aire-ux/aire-overlay@aire-ux/aire-switch@aire-ux/aire-wizard@ion-erik/color-pickerdr-niels-communitybuilder-google-mapdr-niels-google-map@em-polymer/google-map@fabricelements/fabric-imgix@datadobi/color-picker@kano/kwc-blockly@kano/kwc-color-picker@kano-computing/kwc-color-picker@myfrom/iron-swipeable-pages@myfrom/paper-calendar@mistio/vaadin-grid@mistio/mist-insights@lrnwebcomponents/swipe-action@lucentray/pine-web-components@luigdima/google-map@lrnwebcomponents/hax-bookmarklet@lrnwebcomponents/iron-data-table@lrnwebcomponents/circle-progress@nuskin/ns-app-elements@nuxeo/nuxeo-ui-elements@nuskin/ns-dev-portal@logo-elements/date-range-picker@lordoftheflies/plutonium-charthomeassistant-frontend-raceland@johnriv/google-map@operato/color-picker@polymer/neon-animation@polymer/paper-badge@polymer/paper-drawer-panel@polymer/iron-list@polymer/iron-overlay-behavior@polymer/iron-pages@polymer/paper-scroll-header-panel@polymer/paper-tabs@polymer/iron-collapse@polymer/app-layout@polymer/app-media@telecomsante/pdf-viewer@tadevel/polymer-google-mapironlist@things-factory/modeller-uilist-qs@things-real/shell@vic10us/paper-search-input@unifide/app-layout@vowo/chart-elements@vowo/google-map@vaadin-component-factory/vcf-multi-select@vaadin-component-factory/vcf-date-range-picker@vaadin-component-factory/vcf-enhanced-dialog@vaadin/vaadin-core-shrinkwrap@vaadin/vaadin-dropdown-menu@vaadin/vaadin-shrinkwrap@vaadin/vaadin-pdf-viewerfabric-canvasmyscript-common-element@xpertsea/vaadin-gridneon-animation-polymer-3ns-test-app-elementsavs-goavs-web-componentsoe-ui-misc
3.0.1

6 years ago

3.0.0

6 years ago

3.0.0-pre.26

6 years ago

3.0.0-pre.25

6 years ago

3.0.0-pre.24

6 years ago

3.0.0-pre.23

6 years ago

3.0.0-pre.22

6 years ago

3.0.0-pre.21

6 years ago

3.0.0-pre.20

6 years ago

3.0.0-pre.19

6 years ago

3.0.0-pre.18

6 years ago

3.0.0-pre.17

6 years ago

3.0.0-pre.16

6 years ago

3.0.0-pre.15

6 years ago

3.0.0-pre.14

6 years ago

3.0.0-pre.13

6 years ago

3.0.0-pre.12

6 years ago

3.0.0-pre.11

6 years ago

3.0.0-pre.10

6 years ago

3.0.0-pre.8

6 years ago

3.0.0-pre.7

6 years ago

3.0.0-pre.6

6 years ago

3.0.0-pre.4

6 years ago

3.0.0-pre.3

6 years ago

3.0.0-pre.2

6 years ago

3.0.0-pre.1

7 years ago

1.0.5-pre.3

7 years ago

1.0.5-pre.2

7 years ago

1.0.5-pre.1

7 years ago

0.0.4

7 years ago

0.0.3

8 years ago

0.0.1

8 years ago