Skip to content

Commit 928d07f

Browse files
authored
Merge pull request #64 from dukefirehawk/migrated/bug-fix-6
Fixed scrolling exception
2 parents 2d5c203 + 126a487 commit 928d07f

File tree

7 files changed

+42
-41
lines changed

7 files changed

+42
-41
lines changed

angular_components/lib/utils/angular/scroll_host/angular_2.dart

Lines changed: 30 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,13 @@ class ElementScrollHost implements OnInit, OnDestroy, ElementScrollHostBase {
5151
final StreamController<Null> _onUpdate =
5252
StreamController.broadcast(sync: true);
5353

54-
late ElementScrollHostBase _scrollHost;
54+
ElementScrollHostBase? _scrollHost;
5555

56-
late bool _disableAutoScroll;
56+
ElementScrollHostBase get scrollHost {
57+
return _scrollHost!;
58+
}
59+
60+
bool _disableAutoScroll = false;
5761
bool _usePositionSticky = false;
5862
bool _useTouchGestureListener = true;
5963
bool _enableSmoothPushing = false;
@@ -67,7 +71,7 @@ class ElementScrollHost implements OnInit, OnDestroy, ElementScrollHostBase {
6771
}
6872

6973
void _init() {
70-
_scrollHost.dispose();
74+
_scrollHost?.dispose();
7175
_scrollHost = ElementScrollHostBase(
7276
_domService, _ngZone, _gestureListenerFactory, element,
7377
usePositionSticky: _usePositionSticky,
@@ -160,81 +164,81 @@ class ElementScrollHost implements OnInit, OnDestroy, ElementScrollHostBase {
160164

161165
@override
162166
void dispose() {
163-
_scrollHost.dispose();
167+
scrollHost.dispose();
164168
_onUpdate.close();
165169
}
166170

167171
@override
168-
Rectangle calcViewportRect() => _scrollHost.calcViewportRect();
172+
Rectangle calcViewportRect() => scrollHost.calcViewportRect();
169173

170174
@override
171-
void scrollToPosition(int position) => _scrollHost.scrollToPosition(position);
175+
void scrollToPosition(int position) => scrollHost.scrollToPosition(position);
172176

173177
@override
174-
void scrollWithDelta(int delta) => _scrollHost.scrollWithDelta(delta);
178+
void scrollWithDelta(int delta) => scrollHost.scrollWithDelta(delta);
175179

176180
@override
177-
void startNativeScrollListener() => _scrollHost.startNativeScrollListener();
181+
void startNativeScrollListener() => scrollHost.startNativeScrollListener();
178182

179183
@override
180-
int get scrollHeight => _scrollHost.scrollHeight;
184+
int get scrollHeight => scrollHost.scrollHeight;
181185

182186
@override
183-
int get clientHeight => _scrollHost.clientHeight;
187+
int get clientHeight => scrollHost.clientHeight;
184188

185189
@override
186-
Stream<ScrollHostEvent> get nativeOnScroll => _scrollHost.nativeOnScroll;
190+
Stream<ScrollHostEvent> get nativeOnScroll => scrollHost.nativeOnScroll;
187191

188192
@override
189-
bool get usePositionSticky => _scrollHost.usePositionSticky;
193+
bool get usePositionSticky => scrollHost.usePositionSticky;
190194

191195
@override
192-
bool get useTouchGestureListener => _scrollHost.useTouchGestureListener;
196+
bool get useTouchGestureListener => scrollHost.useTouchGestureListener;
193197

194198
@override
195-
bool get throttleScrollEvents => _scrollHost.throttleScrollEvents;
199+
bool get throttleScrollEvents => scrollHost.throttleScrollEvents;
196200

197201
@override
198-
GlobalEventHandlers get scrollbarHost => _scrollHost.scrollbarHost;
202+
GlobalEventHandlers get scrollbarHost => scrollHost.scrollbarHost;
199203

200204
@override
201-
int get clientWidth => _scrollHost.clientWidth;
205+
int get clientWidth => scrollHost.clientWidth;
202206

203207
@override
204-
num get offsetX => _scrollHost.offsetX;
208+
num get offsetX => scrollHost.offsetX;
205209

206210
@override
207-
num get offsetY => _scrollHost.offsetY;
211+
num get offsetY => scrollHost.offsetY;
208212

209213
@override
210-
Element get anchorElement => _scrollHost.anchorElement;
214+
Element get anchorElement => scrollHost.anchorElement;
211215

212216
@override
213-
Stream<ScrollHostEvent>? get onScroll => _scrollHost.onScroll;
217+
Stream<ScrollHostEvent>? get onScroll => scrollHost.onScroll;
214218

215219
@override
216-
PanController? get panController => _scrollHost.panController;
220+
PanController? get panController => scrollHost.panController;
217221

218222
@override
219-
StickyController? get stickyController => _scrollHost.stickyController;
223+
StickyController? get stickyController => scrollHost.stickyController;
220224

221225
@override
222-
int get scrollLength => _scrollHost.scrollLength;
226+
int get scrollLength => scrollHost.scrollLength;
223227

224228
@override
225-
int get scrollPosition => _scrollHost.scrollPosition;
229+
int get scrollPosition => scrollHost.scrollPosition;
226230

227231
@override
228232
Stream<IntersectionObserverEntry?> onIntersection(Element? element) =>
229-
_scrollHost.onIntersection(element);
233+
scrollHost.onIntersection(element);
230234

231235
@override
232236
void ngOnDestroy() {
233237
dispose();
234238
}
235239

236240
@override
237-
void stopEvent(WheelEvent event) => _scrollHost.stopEvent(event);
241+
void stopEvent(WheelEvent event) => scrollHost.stopEvent(event);
238242
}
239243

240244
/// Provides a scroll host that uses the browser window content area.

angular_components/pubspec.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ dependencies:
2222
js: ^0.6.1
2323
logging: ^1.0.2
2424
meta: ^1.0.4
25-
observable:
26-
git: https://github.com/google/observable
25+
observable: ^0.24.0
2726
protobuf: ^2.0.0
2827
quiver: ^3.0.1
2928
sass_builder: ^2.0.2

angular_gallery_section/lib/gallery_section_config_extraction.dart

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import 'src/common_extractors.dart';
1414
/// Extracts the information from @GallerySectionConfig annotations.
1515
///
1616
/// The asset identified by [assetId] will be read using [assetReader].
17-
Future<Iterable<ConfigInfo?>?> extractGallerySectionConfigs(
17+
Future<Iterable<ConfigInfo>?> extractGallerySectionConfigs(
1818
AssetId assetId, AssetReader assetReader) async =>
1919
parseString(
2020
content: await assetReader.readAsString(assetId),
@@ -23,11 +23,12 @@ Future<Iterable<ConfigInfo?>?> extractGallerySectionConfigs(
2323
/// [AstVisitor] to extract multiple @GallerySectionConfig annotations, and
2424
/// the parameters they are constructed with.
2525
class GallerySectionConfigExtraction
26-
extends SimpleAstVisitor<Iterable<ConfigInfo?>> {
26+
extends SimpleAstVisitor<Iterable<ConfigInfo>> {
2727
@override
2828
visitCompilationUnit(CompilationUnit node) => node.declarations
2929
.map((delcaration) => delcaration.accept(_GallerySectionConfigVisitor()))
30-
.where((config) => config != null);
30+
.where((config) => config != null)
31+
.cast<ConfigInfo>();
3132
}
3233

3334
/// [AstVisitor] to extract a single @GallerySectionConfig annotation, applied
@@ -38,7 +39,7 @@ class _GallerySectionConfigVisitor extends SimpleAstVisitor<ConfigInfo> {
3839
ConfigInfo? config;
3940

4041
@override
41-
visitClassDeclaration(ClassDeclaration node) {
42+
ConfigInfo? visitClassDeclaration(ClassDeclaration node) {
4243
for (final metadata in node.metadata) {
4344
if (metadata.name.name == 'GallerySectionConfig') {
4445
config = ConfigInfo();
@@ -87,7 +88,7 @@ class _GallerySectionConfigVisitor extends SimpleAstVisitor<ConfigInfo> {
8788
/// extracted as Strings.
8889
class ConfigInfo {
8990
String displayName = '';
90-
String group = '';
91+
String? group;
9192
Iterable<String> docs = [];
9293
Iterable<String> demoClassNames = [];
9394
String mainDemoName = '';

angular_gallery_section/lib/resolved_config.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ final _invalidCharacters = RegExp(r'[^a-zA-Z0-9 ]');
1212
/// resolved from raw Strings to the values used by the gallery generators.
1313
class ResolvedConfig {
1414
String displayName = '';
15-
String group = '';
15+
String? group;
1616
Iterable<DocInfo> docs = [];
1717
Iterable<DemoInfo> demos = [];
1818
DemoInfo? mainDemo;
@@ -48,7 +48,7 @@ class ResolvedConfig {
4848
/// Constructs a new [ResolvedConfig] from a decoded json map.
4949
ResolvedConfig.fromJson(Map<String, dynamic> jsonMap) {
5050
displayName = jsonMap['displayName'] as String;
51-
group = jsonMap['group'] as String;
51+
group = jsonMap['group'] as String?;
5252

5353
docs = (jsonMap['docs'] as Iterable?)
5454
?.map((element) => DocInfo.fromJson(element)) ??

examples/angular_components_example/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ Build the entire gallery from the `examples/angular_components_example`
1010
directory.
1111

1212
```
13-
pub run build_runner build --output <output directory>
13+
dart run build_runner build --output <output directory>
1414
```
1515

1616
## Serve
1717

1818
Run a local development server with a file watcher and incremental rebuilds:
1919

2020
```
21-
pub run build_runner serve web
21+
dart run build_runner serve web
2222
```
2323

2424
Both of the __build__ and __serve__ commands will accept `--release` to build

examples/angular_components_example/pubspec.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,5 +70,3 @@ dev_dependencies:
7070
dependency_overrides:
7171
angular_components:
7272
path: ../../angular_components
73-
observable:
74-
git: https://github.com/google/observable

examples/material_menu_example/pubspec.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ dependencies:
1212
angular_gallery_section:
1313
path: ../../angular_gallery_section
1414
build_config: ^1.0.0
15-
observable: #^0.23.0
16-
git: https://github.com/google/observable
15+
observable: ^0.24.0
1716

1817
dependency_overrides:
1918
angular_components:

0 commit comments

Comments
 (0)