-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbasic-spread-items.html
More file actions
65 lines (50 loc) · 1.27 KB
/
basic-spread-items.html
File metadata and controls
65 lines (50 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<!--
Spreads out a set of items horizontally so they take equal space.
This component currently requires an explicit size by applied to it. For a
variant that automatically sizes to fit the list items, see the related
component basic-spread-fit.
@element basic-spread-items
-->
<link rel="import" href="../basic-aspect/basic-aspect.html">
<dom-module id="basic-spread-items">
<template>
<style>
:host {
display: block;
}
#spreadContainer {
display: -webkit-flex;
display: flex;
height: 100%;
position: relative;
}
#spreadContainer ::content > * {
object-fit: var(--basic-item-object-fit, contain);
touch-action: none;
height: 100%;
-webkit-user-drag: none;
-moz-user-select: none;
user-select: none;
}
</style>
<div id="spreadContainer">
<content></content>
</div>
</template>
</dom-module>
<script>
Polymer({
contribute: {
itemsChanged: function() {
var items = this.collective.items;
var count = items.length;
this.$.spreadContainer.style.width = (count * 100) + '%';
var itemWidth = (100 / count) + "%";
items.forEach(function(item) {
item.style.width = itemWidth;
});
}
},
is: 'basic-spread-items'
});
</script>