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

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

Issue 969493002: Add support for scroll and fling gestures to SkyShell. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: updated Created 5 years, 9 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 | sky/services/viewport/input_event.mojom » ('j') | 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-element.sky" /> 6 <import src="sky-element.sky" />
7 7
8 <sky-element> 8 <sky-element>
9 <template> 9 <template>
10 <style> 10 <style>
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 double get scrollOffset => _scrollOffset; 87 double get scrollOffset => _scrollOffset;
88 88
89 set scrollOffset(double value) { 89 set scrollOffset(double value) {
90 // TODO(abarth): Can we get these values without forcing a synchronous layou t? 90 // TODO(abarth): Can we get these values without forcing a synchronous layou t?
91 double outerHeight = clientHeight.toDouble(); 91 double outerHeight = clientHeight.toDouble();
92 double innerHeight = _scrollable.clientHeight.toDouble(); 92 double innerHeight = _scrollable.clientHeight.toDouble();
93 double scrollRange = innerHeight - outerHeight; 93 double scrollRange = innerHeight - outerHeight;
94 double newScrollOffset = math.max(0.0, math.min(scrollRange, value)); 94 double newScrollOffset = math.max(0.0, math.min(scrollRange, value));
95 if (newScrollOffset == _scrollOffset) 95 if (newScrollOffset == _scrollOffset)
96 return; 96 return;
97 // TODO(eseidel): We should scroll in device pixels instead of logical
98 // pixels, but to do that correctly we need to use a device pixel unit.
97 _scrollOffset = newScrollOffset; 99 _scrollOffset = newScrollOffset;
98 String transform = 'translateY(${(-_scrollOffset).toStringAsFixed(2)}px)'; 100 String transform = 'translateY(${(-_scrollOffset).toInt()}px)';
99 _scrollable.style['transform'] = transform; 101 _scrollable.style['transform'] = transform;
100 102
101 double topPercent = newScrollOffset / innerHeight * 100.0; 103 double topPercent = newScrollOffset / innerHeight * 100.0;
102 double heightPercent = outerHeight / innerHeight * 100.0; 104 double heightPercent = outerHeight / innerHeight * 100.0;
103 _vbar.style['top'] = '${topPercent}%'; 105 _vbar.style['top'] = '${topPercent}%';
104 _vbar.style['height'] = '${heightPercent}%'; 106 _vbar.style['height'] = '${heightPercent}%';
105 } 107 }
106 108
107 bool scrollBy(double scrollDelta) { 109 bool scrollBy(double scrollDelta) {
108 double oldScrollOffset = _scrollOffset; 110 double oldScrollOffset = _scrollOffset;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 } 153 }
152 154
153 void _handleWheel(WheelEvent event) { 155 void _handleWheel(WheelEvent event) {
154 scrollBy(-event.offsetY); 156 scrollBy(-event.offsetY);
155 } 157 }
156 } 158 }
157 159
158 _init(script) => register(script, SkyScrollable); 160 _init(script) => register(script, SkyScrollable);
159 </script> 161 </script>
160 </sky-element> 162 </sky-element>
OLDNEW
« no previous file with comments | « no previous file | sky/services/viewport/input_event.mojom » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698