public static ScrollMetrics copyWith(ScrollMetrics it, double?minScrollExtent = null, double?maxScrollExtent = null, double?pixels = null, double?viewportDimension = null, AxisDirection?axisDirection = null, double?viewportFraction = null ) { if (it is IPageMetrics) { return(new PageMetrics( minScrollExtent: minScrollExtent ?? it.minScrollExtent, maxScrollExtent: maxScrollExtent ?? it.maxScrollExtent, pixels: pixels ?? it.pixels, viewportDimension: viewportDimension ?? it.viewportDimension, axisDirection: axisDirection ?? it.axisDirection, viewportFraction: viewportFraction ?? ((IPageMetrics)it).viewportFraction )); } return(new FixedScrollMetrics( minScrollExtent: minScrollExtent ?? it.minScrollExtent, maxScrollExtent: maxScrollExtent ?? it.maxScrollExtent, pixels: pixels ?? it.pixels, viewportDimension: viewportDimension ?? it.viewportDimension, axisDirection: axisDirection ?? it.axisDirection )); }
bool _handleScrollNotification(ScrollNotification notification) { ScrollMetrics metrics = notification.metrics; if (metrics.maxScrollExtent <= metrics.minScrollExtent) { return(false); } if (notification is ScrollUpdateNotification || notification is OverscrollNotification) { if (_fadeoutAnimationController.status != AnimationStatus.forward) { _fadeoutAnimationController.forward(); } _fadeoutTimer?.cancel(); _painter.update(notification.metrics, notification.metrics.axisDirection); } else if (notification is ScrollEndNotification) { if (_dragScrollbarPositionY == null) { _startFadeoutTimer(); } } return(false); }
public override float applyBoundaryConditions(ScrollMetrics position, float value) { if (!this.enableOverScroll) { if (value < position.pixels && position.pixels <= position.minScrollExtent) { return(value - position.pixels); } if (value < position.minScrollExtent && position.minScrollExtent < position.pixels) { return(value - position.minScrollExtent); } if (position.maxScrollExtent <= position.pixels && position.pixels < value) { return(value - position.pixels); } if (position.pixels < position.maxScrollExtent && position.maxScrollExtent < value) { return(value - position.maxScrollExtent); } } return(0.0f); }
public static float extentInside(this ScrollMetrics it) { D.assert(it.minScrollExtent <= it.maxScrollExtent); return(it.viewportDimension - (it.minScrollExtent - it.pixels).clamp(0, max: it.viewportDimension) - (it.pixels - it.maxScrollExtent).clamp(0, max: it.viewportDimension)); }
bool _handleScrollNotification(ScrollNotification notification) { ScrollMetrics metrics = notification.metrics; if (metrics.maxScrollExtent <= metrics.minScrollExtent) { return(false); } if (!_useCupertinoScrollbar.Value && (notification is ScrollUpdateNotification || notification is OverscrollNotification)) { if (_fadeoutAnimationController.status != AnimationStatus.forward) { _fadeoutAnimationController.forward(); } _materialPainter.update( notification.metrics, notification.metrics.axisDirection ); if (!widget.isAlwaysShown) { _fadeoutTimer?.cancel(); _fadeoutTimer = Timer.create(ScrollbarUtils._kScrollbarTimeToFade, () => { _fadeoutAnimationController.reverse(); _fadeoutTimer = null; }); } } return(false); }
public override Simulation createBallisticSimulation(ScrollMetrics position, float velocity) { D.assert( position is _FixedExtentScrollPosition, () => "FixedExtentScrollPhysics can only be used with Scrollables that uses " + "the FixedExtentScrollController" ); _FixedExtentScrollPosition metrics = (_FixedExtentScrollPosition)position; if ((velocity <= 0.0f && metrics.pixels <= metrics.minScrollExtent) || (velocity >= 0.0f && metrics.pixels >= metrics.maxScrollExtent)) { return(base.createBallisticSimulation(metrics, velocity)); } Simulation testFrictionSimulation = base.createBallisticSimulation(metrics, velocity); if (testFrictionSimulation != null && (testFrictionSimulation.x(float.PositiveInfinity) == metrics.minScrollExtent || testFrictionSimulation.x(float.PositiveInfinity) == metrics.maxScrollExtent)) { return(base.createBallisticSimulation(metrics, velocity)); } int settlingItemIndex = ListWheelScrollViewUtils._getItemFromOffset( offset: testFrictionSimulation?.x(float.PositiveInfinity) ?? metrics.pixels, itemExtent: metrics.itemExtent, minScrollExtent: metrics.minScrollExtent, maxScrollExtent: metrics.maxScrollExtent ); float settlingPixels = settlingItemIndex * metrics.itemExtent; if (velocity.abs() < tolerance.velocity && (settlingPixels - metrics.pixels).abs() < tolerance.distance) { return(null); } if (settlingItemIndex == metrics.itemIndex) { return(new SpringSimulation( spring, metrics.pixels, settlingPixels, velocity, tolerance: tolerance )); } return(FrictionSimulation.through( metrics.pixels, settlingPixels, velocity, tolerance.velocity * velocity.sign() )); }
public ScrollStartNotification( ScrollMetrics metrics = null, BuildContext context = null, DragStartDetails dragDetails = null ) : base(metrics: metrics, context: context) { this.dragDetails = dragDetails; }
public UserScrollNotification( ScrollMetrics metrics = null, BuildContext context = null, ScrollDirection direction = ScrollDirection.idle ) : base(metrics: metrics, context: context) { this.direction = direction; }
public override void dispatchScrollStartNotification(ScrollMetrics metrics, BuildContext context) { object lastDetails = this._controller.lastDetails; D.assert(lastDetails is DragStartDetails); new ScrollStartNotification(metrics: metrics, context: context, dragDetails: (DragStartDetails)lastDetails) .dispatch(context); }
protected ScrollNotification( ScrollMetrics metrics = null, BuildContext context = null ) { this.metrics = metrics; this.context = context; }
public virtual float applyPhysicsToUserOffset(ScrollMetrics position, float offset) { if (parent == null) { return(offset); } return(parent.applyPhysicsToUserOffset(position, offset)); }
public virtual Simulation createBallisticSimulation(ScrollMetrics position, double velocity) { if (this.parent == null) { return(null); } return(this.parent.createBallisticSimulation(position, velocity)); }
public virtual double applyBoundaryConditions(ScrollMetrics position, double value) { if (this.parent == null) { return(0.0); } return(this.parent.applyBoundaryConditions(position, value)); }
public virtual bool shouldAcceptUserOffset(ScrollMetrics position) { if (this.parent == null) { return(position.pixels != 0.0 || position.minScrollExtent != position.maxScrollExtent); } return(this.parent.shouldAcceptUserOffset(position)); }
public virtual double applyPhysicsToUserOffset(ScrollMetrics position, double offset) { if (this.parent == null) { return(offset); } return(this.parent.applyPhysicsToUserOffset(position, offset)); }
public virtual float applyBoundaryConditions(ScrollMetrics position, float value) { if (this.parent == null) { return(0.0f); } return(this.parent.applyBoundaryConditions(position, value)); }
public ScrollIncrementDetails( ScrollIncrementType type, ScrollMetrics metrics ) { D.assert(metrics != null); this.type = type; this.metrics = metrics; }
float _getPage(ScrollMetrics position) { if (position is _PagePosition) { return(((_PagePosition)position).page); } return(position.pixels / position.viewportDimension); }
float _getPixels(ScrollMetrics position, float page) { if (position is _PagePosition) { return(((_PagePosition)position).getPixelsFromPage(page)); } return(page * position.viewportDimension); }
public override void dispatchOverscrollNotification(ScrollMetrics metrics, BuildContext context, double overscroll) { object lastDetails = this._controller.lastDetails; D.assert(lastDetails is DragUpdateDetails); new OverscrollNotification(metrics: metrics, context: context, overscroll: overscroll, dragDetails: (DragUpdateDetails)lastDetails).dispatch(context); }
public override void dispatchScrollUpdateNotification(ScrollMetrics metrics, BuildContext context, double scrollDelta) { object lastDetails = this._controller.lastDetails; D.assert(lastDetails is DragUpdateDetails); new ScrollUpdateNotification(metrics: metrics, context: context, scrollDelta: scrollDelta, dragDetails: (DragUpdateDetails)lastDetails).dispatch(context); }
public ScrollUpdateNotification( ScrollMetrics metrics = null, BuildContext context = null, DragUpdateDetails dragDetails = null, float scrollDelta = 0 ) : base(metrics: metrics, context: context) { this.dragDetails = dragDetails; this.scrollDelta = scrollDelta; }
float _getScrollToTrack(ScrollMetrics metrics, float thumbExtent) { float scrollableExtent = metrics.maxScrollExtent - metrics.minScrollExtent; float fractionPast = (scrollableExtent > 0) ? ((metrics.pixels - metrics.minScrollExtent) / scrollableExtent).clamp(0.0f, 1.0f) : 0; return((_isReversed ? 1 - fractionPast : fractionPast) * (_trackExtent - thumbExtent)); }
public override void dispatchScrollEndNotification(ScrollMetrics metrics, BuildContext context) { object lastDetails = this._controller.lastDetails; new ScrollEndNotification( metrics: metrics, context: context, dragDetails: lastDetails as DragEndDetails ).dispatch(context); }
public ScrollEndNotification( ScrollMetrics metrics = null, BuildContext context = null, DragEndDetails dragDetails = null, float overscroll = 0, float velocity = 0 ) : base(metrics: metrics, context: context) { this.dragDetails = dragDetails; }
public bool recommendDeferredLoading(float velocity, ScrollMetrics metrics, BuildContext context) { D.assert(metrics != null); D.assert(context != null); if (parent == null) { float maxPhysicalPixels = WidgetsBinding.instance.window.physicalSize.longestSide; return(velocity.abs() > maxPhysicalPixels); } return(parent.recommendDeferredLoading(velocity, metrics, context)); }
public OverscrollNotification( ScrollMetrics metrics = null, BuildContext context = null, DragUpdateDetails dragDetails = null, float overscroll = 0, float velocity = 0 ) : base(metrics: metrics, context: context) { this.dragDetails = dragDetails; this.overscroll = overscroll; this.velocity = velocity; }
float _getTargetPixels(ScrollMetrics position, Tolerance tolerance, float velocity) { float page = _getPage(position); if (velocity < -tolerance.velocity) { page -= 0.5f; } else if (velocity > tolerance.velocity) { page += 0.5f; } return(_getPixels(position, page.round())); }
public override Simulation createBallisticSimulation(ScrollMetrics position, double velocity) { Tolerance tolerance = this.tolerance; if (position.outOfRange()) { double?end = null; if (position.pixels > position.maxScrollExtent) { end = position.maxScrollExtent; } if (position.pixels < position.minScrollExtent) { end = position.minScrollExtent; } D.assert(end != null); return(new ScrollSpringSimulation( this.spring, position.pixels, position.maxScrollExtent, Math.Min(0.0, velocity), tolerance: tolerance )); } if (velocity.abs() < tolerance.velocity) { return(null); } if (velocity > 0.0 && position.pixels >= position.maxScrollExtent) { return(null); } if (velocity < 0.0 && position.pixels <= position.minScrollExtent) { return(null); } return(new ClampingScrollSimulation( position: position.pixels, velocity: velocity, tolerance: tolerance )); }
public override Simulation createBallisticSimulation(ScrollMetrics position, float velocity) { if ((velocity <= 0.0 && position.pixels <= position.minScrollExtent) || (velocity >= 0.0 && position.pixels >= position.maxScrollExtent)) { return(base.createBallisticSimulation(position, velocity)); } Tolerance tolerance = this.tolerance; float target = _getTargetPixels((ScrollPosition)position, tolerance, velocity); if (target != position.pixels) { return(new ScrollSpringSimulation(spring, position.pixels, target, velocity, tolerance: tolerance)); } return(null); }