Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(97)

Side by Side Diff: sky/framework/sky-scrollable.sky

Issue 879003002: The scrollbar in sky-scrollable should fade in and out (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <!-- 1 <!--
2 // Copyright 2015 The Chromium Authors. All rights reserved. 2 // Copyright 2015 The Chromium Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be 3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file. 4 // found in the LICENSE file.
5 --> 5 -->
6 <import src="/sky/framework/sky-element/sky-element.sky" as="SkyElement" /> 6 <import src="/sky/framework/sky-element/sky-element.sky" as="SkyElement" />
7 <import src="/sky/framework/fling-curve.sky" as="FlingCurve" /> 7 <import src="/sky/framework/fling-curve.sky" as="FlingCurve" />
8 8
9 <sky-element 9 <sky-element
10 name="sky-scrollable" 10 name="sky-scrollable"
(...skipping 13 matching lines...) Expand all
24 transform: translateY(0); 24 transform: translateY(0);
25 } 25 }
26 #vbar { 26 #vbar {
27 position: absolute; 27 position: absolute;
28 right: 0; 28 right: 0;
29 width: 3px; 29 width: 3px;
30 background-color: lightgray; 30 background-color: lightgray;
31 pointer-events: none; 31 pointer-events: none;
32 top: 0; 32 top: 0;
33 height: 0; 33 height: 0;
34 will-change: opacity;
35 opacity: 0;
36 transition: opacity 0.2s ease-in-out;
34 } 37 }
35 </style> 38 </style>
36 <div id="vbar" />
37 <div id="scrollable"> 39 <div id="scrollable">
38 <content /> 40 <content />
39 </div> 41 </div>
42 <div id="vbar" />
40 </template> 43 </template>
41 <script> 44 <script>
42 module.exports = class extends SkyElement { 45 module.exports = class extends SkyElement {
43 created() { 46 created() {
44 this.scrollable_ = null; 47 this.scrollable_ = null;
45 this.vbar_ = null; 48 this.vbar_ = null;
46 this.scrollOffset_ = 0; 49 this.scrollOffset_ = 0;
47 this.flingCurve_ = null; 50 this.flingCurve_ = null;
48 this.flingAnimationId_ = null; 51 this.flingAnimationId_ = null;
49 } 52 }
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 } 85 }
83 86
84 scheduleFlingUpdate_() { 87 scheduleFlingUpdate_() {
85 this.flingAnimationId_ = requestAnimationFrame(this.updateFling_.bind(this)) ; 88 this.flingAnimationId_ = requestAnimationFrame(this.updateFling_.bind(this)) ;
86 } 89 }
87 90
88 stopFling_() { 91 stopFling_() {
89 cancelAnimationFrame(this.flingAnimationId_); 92 cancelAnimationFrame(this.flingAnimationId_);
90 this.flingCurve_ = null; 93 this.flingCurve_ = null;
91 this.flingAnimationId_ = null; 94 this.flingAnimationId_ = null;
95 this.vbar_.style.opacity = 0;
92 } 96 }
93 97
94 updateFling_(timeStamp) { 98 updateFling_(timeStamp) {
95 var scrollDelta = this.flingCurve_.update(timeStamp); 99 var scrollDelta = this.flingCurve_.update(timeStamp);
96 if (!scrollDelta || !this.scrollBy(scrollDelta)) 100 if (!scrollDelta || !this.scrollBy(scrollDelta))
97 return this.stopFling_(); 101 return this.stopFling_();
98 this.scheduleFlingUpdate_(); 102 this.scheduleFlingUpdate_();
99 } 103 }
100 104
101 handleScrollStart_(event) { 105 handleScrollStart_(event) {
106 this.vbar_.style.opacity = 1;
102 } 107 }
103 108
104 handleScrollEnd_(event) { 109 handleScrollEnd_(event) {
110 this.vbar_.style.opacity = 0;
105 } 111 }
106 112
107 handleScrollUpdate_(event) { 113 handleScrollUpdate_(event) {
108 this.scrollBy(-event.dy); 114 this.scrollBy(-event.dy);
109 } 115 }
110 116
111 handleFlingStart_(event) { 117 handleFlingStart_(event) {
112 this.flingCurve_ = new FlingCurve(-event.velocityY, event.timeStamp); 118 this.flingCurve_ = new FlingCurve(-event.velocityY, event.timeStamp);
113 this.scheduleFlingUpdate_(); 119 this.scheduleFlingUpdate_();
114 } 120 }
115 121
116 handleFlingCancel_(event) { 122 handleFlingCancel_(event) {
117 this.stopFling_(); 123 this.stopFling_();
118 } 124 }
119 125
120 handleWheel_(event) { 126 handleWheel_(event) {
121 this.scrollBy(-event.offsetY); 127 this.scrollBy(-event.offsetY);
122 } 128 }
123 }.register(); 129 }.register();
124 </script> 130 </script>
125 </sky-element> 131 </sky-element>
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698