useIntersection function

IntersectionSnapshot? useIntersection(
  1. GlobalNodeKey<Element> target, [
  2. IntersectionOptions options = const IntersectionOptions()
])

Returns the latest intersection state for target.

Implementation

IntersectionSnapshot? useIntersection(
  GlobalNodeKey<web.Element> target, [
  IntersectionOptions options = const IntersectionOptions(),
]) {
  final snapshot = IntersectionOptions(
    root: options.root,
    rootMargin: options.rootMargin,
    thresholds: List<double>.unmodifiable(options.thresholds),
    freezeOnceVisible: options.freezeOnceVisible,
  );
  if (snapshot.thresholds.isEmpty || snapshot.thresholds.any((value) => !value.isFinite || value < 0 || value > 1)) {
    throw ArgumentError.value(snapshot.thresholds, 'options.thresholds', 'must contain values from zero to one');
  }
  return use(_IntersectionHook(target, snapshot));
}