2 Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
3 This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
4 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
5 The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
6 Code distributed by Google as part of the polymer project is also
7 subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
10 <link rel="import" href="../polymer/polymer.html">
11 <link rel="import" href="../core-overlay/core-overlay.html">
15 `paper-menu-button-overlay` is a helper class to position an overlay relative to another
16 element, e.g. the button with a pulldown menu.
19 @element paper-menu-button-overlay
24 <polymer-element name="paper-menu-button-overlay" extends="core-overlay" attributes="relatedTarget halign valign">
26 Polymer('paper-menu-button-overlay', {
31 * The `relatedTarget` is an element used to position the overlay, for example a
32 * button the user taps to show a menu.
34 * @attribute relatedTarget
40 * The horizontal alignment of the overlay relative to the `relatedTarget`.
43 * @type 'left'|'right'|'center'
50 updateTargetDimensions: function() {
54 this.target.cachedSize = t.getBoundingClientRect();
57 positionTarget: function() {
58 if (this.relatedTarget) {
60 var rect = this.relatedTarget.getBoundingClientRect();
62 if (this.halign === 'left') {
63 this.target.style.left = rect.left + 'px';
64 } else if (this.halign === 'right') {
65 this.target.style.right = (window.innerWidth - rect.right) + 'px';
67 this.target.style.left = (rect.left - (rect.width - this.target.cachedSize.width) / 2) + 'px';
70 if (this.valign === 'top') {
71 this.target.style.top = rect.top + 'px';
72 } else if (this.valign === 'bottom') {
73 this.target.style.top = rect.bottom + 'px';
75 this.target.style.top = rect.top + 'px';
78 // this.target.style.top = rect.top + 'px';