| OLD | NEW |
| (Empty) |
| 1 | |
| 2 | |
| 3 Polymer({ | |
| 4 | |
| 5 is: 'iron-media-query', | |
| 6 | |
| 7 properties: { | |
| 8 | |
| 9 /** | |
| 10 * The Boolean return value of the media query. | |
| 11 * | |
| 12 * @attribute queryMatches | |
| 13 * @type Boolean | |
| 14 * @default false | |
| 15 */ | |
| 16 queryMatches: { | |
| 17 type: Boolean, | |
| 18 value: false, | |
| 19 readOnly: true, | |
| 20 notify: true | |
| 21 }, | |
| 22 | |
| 23 /** | |
| 24 * The CSS media query to evaluate. | |
| 25 * | |
| 26 * @attribute query | |
| 27 * @type String | |
| 28 */ | |
| 29 query: { | |
| 30 type: String, | |
| 31 observer: 'queryChanged' | |
| 32 } | |
| 33 | |
| 34 }, | |
| 35 | |
| 36 created: function() { | |
| 37 this._mqHandler = this.queryHandler.bind(this); | |
| 38 }, | |
| 39 | |
| 40 queryChanged: function(query) { | |
| 41 if (this._mq) { | |
| 42 this._mq.removeListener(this._mqHandler); | |
| 43 } | |
| 44 if (query[0] !== '(') { | |
| 45 query = '(' + query + ')'; | |
| 46 } | |
| 47 this._mq = window.matchMedia(query); | |
| 48 this._mq.addListener(this._mqHandler); | |
| 49 this.queryHandler(this._mq); | |
| 50 }, | |
| 51 | |
| 52 queryHandler: function(mq) { | |
| 53 this._setQueryMatches(mq.matches); | |
| 54 } | |
| 55 | |
| 56 }); | |
| 57 | |
| OLD | NEW |