Skip to content
This repository was archived by the owner on Mar 13, 2018. It is now read-only.

Commit 7935970

Browse files
author
Yvonne Yip
committed
contacts-v2: use polymer-sectioned-list
1 parent 313425d commit 7935970

File tree

1 file changed

+10
-40
lines changed

1 file changed

+10
-40
lines changed

shiny/Contacts-v2/components/contacts-app.html

+10-40
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<link href="../../../../polymer-ui-elements/polymer-ui-menu-item/polymer-ui-menu-item.html" rel="import">
1313
<link href="../../../../polymer-ui-elements/polymer-ui-overlay/polymer-ui-overlay.html" rel="import">
1414
<link href="../../../../polymer-ui-elements/polymer-ui-toolbar/polymer-ui-toolbar.html" rel="import">
15-
<link href="../../../list/elements/polymer-list/polymer-list.html" rel="import">
15+
<link href="../../../list/elements/polymer-sectioned-list/polymer-sectioned-list.html" rel="import">
1616
<link href="contacts-create.html" rel="import">
1717
<link href="contacts-detail.html" rel="import">
1818
<link href="contacts-icon.html" rel="import">
@@ -70,29 +70,25 @@
7070
min-width: 320px;
7171
max-width: 384px;
7272
}
73-
polymer-list {
73+
polymer-sectioned-list {
7474
height: 100%;
7575
}
76-
[tabletLayout] polymer-list {
76+
[tabletLayout] polymer-sectioned-list {
7777
margin: 24px;
7878
}
7979
.contactItem {
8080
position: relative;
81+
}
82+
polymer-sectioned-list ^ #sticky,
83+
.contactItem {
8184
font-size: 14px;
8285
font-family: 'Helvetica Neue', HelveticaNeue, Helvetica, sans-serif;
8386
user-select: none;
8487
}
85-
.contactItem.sticky {
86-
position: absolute;
87-
top: 0;
88-
left: 0;
89-
right: 0;
90-
z-index: 10;
91-
opacity: 0.95;
92-
}
93-
[tabletLayout] .contactItem.sticky {
88+
[tabletLayout] polymer-sectioned-list ^ #sticky {
9489
display: none;
9590
}
91+
polymer-sectioned-list ^ #sticky,
9692
.contactItem.header {
9793
background: white;
9894
border-style: solid;
@@ -229,10 +225,7 @@
229225
</template>
230226
</polymer-ui-toolbar>
231227
<div id="listContainer" desktopLayout?="{{desktopLayout}}" tabletLayout?="{{tabletLayout}}">
232-
<div id="sticky" class="contactItem header sticky">
233-
{{stickyContent}}
234-
</div>
235-
<polymer-list id="list" data="{{$.mock.withHeaders}}" listData="{{listData}}" on-polymer-list-scroll="{{scrollAction}}">
228+
<polymer-sectioned-list id="list" data="{{$.mock.withHeaders}}" listData="{{listData}}">
236229
<template repeat="{{contact in listData}}">
237230
<!-- <contacts-list-item contact="{{contact}}"></contacts-list-item> -->
238231

@@ -257,7 +250,7 @@
257250
</template>
258251

259252
</template>
260-
</polymer-list>
253+
</polymer-sectioned-list>
261254
</div>
262255
<contacts-detail id="details" contact="{{selectedContact.contact}}" desktopLayout?="{{desktopLayout}}" on-contacts-detail-cancel="{{closeDetailsAction}}"></contacts-detail>
263256
<polymer-ui-overlay id="createOverlay" xdesktopLayout?="{{desktopLayout}}" autocloseDisabled backdrop on-polymer-overlay-open="{{openCreateAction}}">
@@ -298,7 +291,6 @@
298291
Polymer('contacts-app', {
299292
desktopLayout: false,
300293
tabletLayout: false,
301-
stickyContent: 'A',
302294
selectedContact: null,
303295
observe: {
304296
desktopLayout: 'layoutChanged',
@@ -340,28 +332,6 @@
340332
layoutAction: function() {
341333
this.$.list.refresh();
342334
},
343-
scrollAction: function() {
344-
var items = this.$.list.querySelectorAll('.contactItem');
345-
var scrollTop = this.$.list.scrollOffset;
346-
var lastHeader;
347-
for (var i = 0, item; item = items[i]; i++) {
348-
var offset = item.offsetTop + (item.offsetParent ? item.offsetParent.offsetTop : 0);
349-
var isHeader = item.classList.contains('header');
350-
if (lastHeader && offset > scrollTop) {
351-
this.stickyContent = lastHeader.textContent;
352-
var transY = offset - scrollTop - lastHeader.offsetHeight;
353-
if (transY < 0 && isHeader) {
354-
this.$.sticky.style['-webkit-transform'] = 'translateY(' + transY + 'px)';
355-
} else {
356-
this.$.sticky.style['-webkit-transform'] = null;
357-
}
358-
break;
359-
}
360-
if (isHeader) {
361-
lastHeader = item;
362-
}
363-
}
364-
},
365335
pointerdownAction: function(e, detail, sender) {
366336
this.$.scrub.target = sender;
367337
this.$.translateAnimation.target = sender;

0 commit comments

Comments
 (0)