OLD | NEW |
(Empty) | |
| 1 |
| 2 Polymer('core-media-query', { |
| 3 |
| 4 /** |
| 5 * The Boolean return value of the media query |
| 6 * |
| 7 * @attribute queryMatches |
| 8 * @type Boolean |
| 9 * @default false |
| 10 */ |
| 11 queryMatches: false, |
| 12 |
| 13 /** |
| 14 * The CSS media query to evaulate |
| 15 * |
| 16 * @attribute query |
| 17 * @type string |
| 18 * @default '' |
| 19 */ |
| 20 query: '', |
| 21 ready: function() { |
| 22 this._mqHandler = this.queryHandler.bind(this); |
| 23 this._mq = null; |
| 24 }, |
| 25 queryChanged: function() { |
| 26 if (this._mq) { |
| 27 this._mq.removeListener(this._mqHandler); |
| 28 } |
| 29 var query = this.query; |
| 30 if (query[0] !== '(') { |
| 31 query = '(' + this.query + ')'; |
| 32 } |
| 33 this._mq = window.matchMedia(query); |
| 34 this._mq.addListener(this._mqHandler); |
| 35 this.queryHandler(this._mq); |
| 36 }, |
| 37 queryHandler: function(mq) { |
| 38 this.queryMatches = mq.matches; |
| 39 this.asyncFire('core-media-change', mq); |
| 40 } |
| 41 }); |
| 42 |
OLD | NEW |