MacViews: Get c/b/ui/views/tabs to build on Mac
[chromium-blink-merge.git] / third_party / polymer / components-chromium / paper-menu-button / paper-menu-button-overlay-extracted.js
blobd4fac62fa1e6f2cead8c58016b4f084ce2156874
2 Polymer('paper-menu-button-overlay', {
4 publish: {
6 /**
7 * The `relatedTarget` is an element used to position the overlay, for example a
8 * button the user taps to show a menu.
10 * @attribute relatedTarget
11 * @type Element
13 relatedTarget: null,
15 /**
16 * The horizontal alignment of the overlay relative to the `relatedTarget`.
18 * @attribute halign
19 * @type 'left'|'right'|'center'
20 * @default 'left'
22 halign: 'left'
26 updateTargetDimensions: function() {
27 this.super();
29 var t = this.target;
30 this.target.cachedSize = t.getBoundingClientRect();
33 positionTarget: function() {
34 if (this.relatedTarget) {
36 var rect = this.relatedTarget.getBoundingClientRect();
38 if (this.halign === 'left') {
39 this.target.style.left = rect.left + 'px';
40 } else if (this.halign === 'right') {
41 this.target.style.right = (window.innerWidth - rect.right) + 'px';
42 } else {
43 this.target.style.left = (rect.left - (rect.width - this.target.cachedSize.width) / 2) + 'px';
46 if (this.valign === 'top') {
47 this.target.style.top = rect.top + 'px';
48 } else if (this.valign === 'bottom') {
49 this.target.style.top = rect.bottom + 'px';
50 } else {
51 this.target.style.top = rect.top + 'px';
54 // this.target.style.top = rect.top + 'px';
56 } else {
57 this.super();
61 });