| OLD | NEW |
| 1 <!-- | 1 <!-- |
| 2 Copyright (c) 2015 The Polymer Project Authors. All rights reserved. | 2 Copyright (c) 2015 The Polymer Project Authors. All rights reserved. |
| 3 This code may only be used under the BSD style license found at http://polymer.g
ithub.io/LICENSE.txt | 3 This code may only be used under the BSD style license found at http://polymer.g
ithub.io/LICENSE.txt |
| 4 The complete set of authors may be found at http://polymer.github.io/AUTHORS.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/CONTRI
BUTORS.txt | 5 The complete set of contributors may be found at http://polymer.github.io/CONTRI
BUTORS.txt |
| 6 Code distributed by Google as part of the polymer project is also | 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/PATEN
TS.txt | 7 subject to an additional IP rights grant found at http://polymer.github.io/PATEN
TS.txt |
| 8 --> | 8 --> |
| 9 | 9 |
| 10 <link rel="import" href="../polymer/polymer.html"> | 10 <link rel="import" href="../polymer/polymer.html"> |
| 11 | 11 |
| 12 <!-- | 12 <!-- |
| 13 `iron-media-query` can be used to data bind to a CSS media query. | 13 `iron-media-query` can be used to data bind to a CSS media query. |
| 14 The `query` property is a bare CSS media query. | 14 The `query` property is a bare CSS media query. |
| 15 The `queryMatches` property is a boolean representing if the page matches that m
edia query. | 15 The `query-matches` property is a boolean representing whether the page matches
that media query. |
| 16 | 16 |
| 17 Example: | 17 Example: |
| 18 | 18 |
| 19 <iron-media-query query="(min-width: 600px)" queryMatches="{{queryMatches}}"
></iron-media-query> | 19 <iron-media-query query="(min-width: 600px)" query-matches="{{queryMatches}}
"></iron-media-query> |
| 20 | 20 |
| 21 @group Iron Elements | 21 @group Iron Elements |
| 22 @demo demo/index.html | 22 @demo demo/index.html |
| 23 @hero hero.svg | 23 @hero hero.svg |
| 24 @element iron-media-query | 24 @element iron-media-query |
| 25 --> | 25 --> |
| 26 | 26 |
| 27 <script> | 27 <script> |
| 28 | 28 |
| 29 Polymer({ | 29 Polymer({ |
| 30 | 30 |
| 31 is: 'iron-media-query', | 31 is: 'iron-media-query', |
| 32 | 32 |
| 33 properties: { | 33 properties: { |
| 34 | 34 |
| 35 /** | 35 /** |
| 36 * The Boolean return value of the media query. | 36 * The Boolean return value of the media query. |
| 37 * | |
| 38 * @attribute queryMatches | |
| 39 * @type Boolean | |
| 40 * @default false | |
| 41 */ | 37 */ |
| 42 queryMatches: { | 38 queryMatches: { |
| 43 type: Boolean, | 39 type: Boolean, |
| 44 value: false, | 40 value: false, |
| 45 readOnly: true, | 41 readOnly: true, |
| 46 notify: true | 42 notify: true |
| 47 }, | 43 }, |
| 48 | 44 |
| 49 /** | 45 /** |
| 50 * The CSS media query to evaluate. | 46 * The CSS media query to evaluate. |
| 51 * | |
| 52 * @attribute query | |
| 53 * @type String | |
| 54 */ | 47 */ |
| 55 query: { | 48 query: { |
| 56 type: String, | 49 type: String, |
| 57 observer: 'queryChanged' | 50 observer: 'queryChanged' |
| 58 } | 51 } |
| 59 | 52 |
| 60 }, | 53 }, |
| 61 | 54 |
| 62 created: function() { | 55 created: function() { |
| 63 this._mqHandler = this.queryHandler.bind(this); | 56 this._mqHandler = this.queryHandler.bind(this); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 75 this.queryHandler(this._mq); | 68 this.queryHandler(this._mq); |
| 76 }, | 69 }, |
| 77 | 70 |
| 78 queryHandler: function(mq) { | 71 queryHandler: function(mq) { |
| 79 this._setQueryMatches(mq.matches); | 72 this._setQueryMatches(mq.matches); |
| 80 } | 73 } |
| 81 | 74 |
| 82 }); | 75 }); |
| 83 | 76 |
| 84 </script> | 77 </script> |
| OLD | NEW |