readScrollPosition function
Future<({bool notScrollable, (double, double, double)? position})>
readScrollPosition(
- GlintSession session,
- Scene scene,
- String? glintId
The pixels, minimum and maximum extent of the scrollable around the node glintId in scene, by one small eval; position is null when it cannot be read and notScrollable says whether nothing scrolls there.
Implementation
Future<({(double, double, double)? position, bool notScrollable})> readScrollPosition(
GlintSession session, Scene scene, String? glintId) async {
final node = glintId == null ? null : scene.findByGlintId(glintId);
if (node == null) return (position: null, notScrollable: true);
final String? raw;
try {
raw = await session.runtime.evaluateWithSelection(
expression: _positionExpr,
inspectorId: node.inspectorId,
groupName: scene.groupName,
);
} on Object {
return (position: null, notScrollable: false);
}
final parts = raw?.split(',').map(double.tryParse).toList();
if (parts == null || parts.length != 3 || parts.contains(null)) {
return (position: null, notScrollable: raw == 'none');
}
return (position: (parts[0]!, parts[1]!, parts[2]!), notScrollable: false);
}