You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+39-47Lines changed: 39 additions & 47 deletions
Original file line number
Diff line number
Diff line change
@@ -318,36 +318,25 @@ If you want to render chunks of template conditionally, use this syntax:
318
318
319
319
```html
320
320
<ElementQueryas|EQ|>
321
-
<EQ.at-m>
321
+
{{#if EQ.at-m}}
322
322
{{! This will only be rendered when the `<ElementQuery>` component is of size `m`. }}
323
-
</at.m>
323
+
{{/if}}
324
324
325
-
<EQ.from-m>
325
+
{{#if EQ.from-m}}
326
326
{{! This will only be rendered when the `<ElementQuery>` component is of size `m` or larger. }}
327
327
</EQ.from-m>
328
328
329
-
<EQ.to-m>
329
+
{{#if EQ.to-m}}
330
330
{{! This will only be rendered when the `<ElementQuery>` component is of size `m` or smaller. }}
331
-
</EQ.to-m>
331
+
{{/EQ.to-m}}
332
332
333
-
<EQ.from-s><EQ.to-l>
333
+
{{#if (and EQ.from-sEQ.to-l)}}
334
334
{{! This will only be rendered when the `<ElementQuery>` component is of size `s`, `m` or `l`. }}
335
-
</EQ.to-l></EQ.from-s>
335
+
{{/if}}
336
336
</ElementQuery>
337
337
```
338
338
339
-
If you want to "sprinke" your tempalte with small responsive bits, you may find it more convenient to use the `{{#if}}` syntax together with [ember-truth-helpers](https://github.com/jmurphyau/ember-truth-helpers):
340
-
341
-
```html
342
-
<ElementQueryas|EQEQInfo|>
343
-
<SomeOtherComponent
344
-
@isMedium={{eqEQInfo.size"s"}}
345
-
@isMediumOrLarger={{boolEQ.from-m}}
346
-
>
347
-
</ElementQuery>
348
-
```
349
-
350
-
The first yield argument `EQ` is a hash of current element query attributes. Keys are attribute names and values are truthy strings, so `{{bool EQ.from-m}}` gives you `true` when the element is of size `m` or larger, and `false` when the element is smaller than `m`.
339
+
The first yield argument `EQ` is an object with current element query attributes. Keys are attribute names and values are `true`. Non-matching attributes are undefined. Thus, `{{#if EQ.from-m}}` renders only when the element is of size `m` or larger.
351
340
352
341
The second argument `EQInfo` is the same hash that is passed to the [onResize callback](#onresize-callback).
353
342
@@ -363,15 +352,16 @@ You can pass a callback to the `onResize` argument and it will be called wheneve
363
352
```js
364
353
@action
365
354
reportResize(info) {
366
-
info.element// => current element
367
-
info.width// => current element's width in px (number)
368
-
info.height// => current element's height in px (number)
369
-
info.ratio// => current element's aspect ratio (width/height, number)
370
-
info.size// => current element's width size (string or undefined)
371
-
info.sizeHeight// => current element's height size (string or undefined)
372
-
info.dimension// => current dimension ('width', 'height' or 'both')
373
-
info.prefix// => current prefix (string or undefined)
374
-
info.attributes// => element query attributes used on the element (array of strings)
355
+
info.element// => current element
356
+
info.width// => current element's width in px (number)
357
+
info.height// => current element's height in px (number)
358
+
info.ratio// => current element's aspect ratio (width/height, number)
359
+
info.size// => current element's width size (string or undefined)
360
+
info.sizeHeight// => current element's height size (string or undefined)
361
+
info.dimension// => current dimension ('width', 'height' or 'both')
362
+
info.prefix// => current prefix (string or undefined)
363
+
info.attributes// => matching element query attributes in array form: ['from-xxs', 'from-xs', ...]
364
+
info.attributesRecord// => matching element query attributes in object form: {'from-xxs': true, 'from-xs': true, ...}
375
365
}
376
366
```
377
367
@@ -458,9 +448,9 @@ You can customize height sizes into `@sizesHeight`. Make sure that height size n
Initially implemented by Andrey Mikhaylov ([lolmaus](https://github.com/lolmaus)) and [contributors](https://github.com/lolmaus/ember-element-query/graphs/contributors).
1062
1052
1063
-
Thanks to Chad Carbert ([chadian](https://github.com/chadian)) and Isaac Lee ([ijlee2](https://github.com/ijlee2)) for feedback, ideas, brainstorming and criticism.
1053
+
Thanks to Chad Carbert ([@chadian](https://github.com/chadian)) and Isaac Lee ([@ijlee2](https://github.com/ijlee2)) for feedback, ideas, brainstorming and criticism.
1054
+
1055
+
Sponsored by [@kaliber5](https://github.com/kaliber5), https://kaliber5.de.
0 commit comments