本文整理汇总了C++中FrameMetrics::ScrollBy方法的典型用法代码示例。如果您正苦于以下问题:C++ FrameMetrics::ScrollBy方法的具体用法?C++ FrameMetrics::ScrollBy怎么用?C++ FrameMetrics::ScrollBy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FrameMetrics
的用法示例。
在下文中一共展示了FrameMetrics::ScrollBy方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: IsFinished
bool
WheelScrollAnimation::DoSample(FrameMetrics& aFrameMetrics, const TimeDuration& aDelta)
{
TimeStamp now = AsyncPanZoomController::GetFrameTime();
CSSToParentLayerScale2D zoom = aFrameMetrics.GetZoom();
// If the animation is finished, make sure the final position is correct by
// using one last displacement. Otherwise, compute the delta via the timing
// function as normal.
bool finished = IsFinished(now);
nsPoint sampledDest = finished
? mDestination
: PositionAt(now);
ParentLayerPoint displacement =
(CSSPoint::FromAppUnits(sampledDest) - aFrameMetrics.GetScrollOffset()) * zoom;
// Note: we ignore overscroll for wheel animations.
ParentLayerPoint adjustedOffset, overscroll;
mApzc.mX.AdjustDisplacement(displacement.x, adjustedOffset.x, overscroll.x);
mApzc.mY.AdjustDisplacement(displacement.y, adjustedOffset.y, overscroll.y,
!aFrameMetrics.AllowVerticalScrollWithWheel());
// If we expected to scroll, but there's no more scroll range on either axis,
// then end the animation early. Note that the initial displacement could be 0
// if the compositor ran very quickly (<1ms) after the animation was created.
// When that happens we want to make sure the animation continues.
if (!IsZero(displacement) && IsZero(adjustedOffset)) {
// Nothing more to do - end the animation.
return false;
}
aFrameMetrics.ScrollBy(adjustedOffset / zoom);
return !finished;
}
示例2: IsFinished
bool
WheelScrollAnimation::DoSample(FrameMetrics& aFrameMetrics, const TimeDuration& aDelta)
{
TimeStamp now = AsyncPanZoomController::GetFrameTime();
CSSToParentLayerScale2D zoom = aFrameMetrics.GetZoom();
// If the animation is finished, make sure the final position is correct by
// using one last displacement. Otherwise, compute the delta via the timing
// function as normal.
bool finished = IsFinished(now);
nsPoint sampledDest = finished
? mDestination
: PositionAt(now);
ParentLayerPoint displacement =
(CSSPoint::FromAppUnits(sampledDest) - aFrameMetrics.GetScrollOffset()) * zoom;
// Note: we ignore overscroll for wheel animations.
ParentLayerPoint adjustedOffset, overscroll;
mApzc.mX.AdjustDisplacement(displacement.x, adjustedOffset.x, overscroll.x);
mApzc.mY.AdjustDisplacement(displacement.y, adjustedOffset.y, overscroll.y,
!aFrameMetrics.AllowVerticalScrollWithWheel());
if (IsZero(adjustedOffset)) {
// Nothing more to do - end the animation.
return false;
}
aFrameMetrics.ScrollBy(adjustedOffset / zoom);
return !finished;
}
示例3: IsFinished
bool
GenericScrollAnimation::DoSample(FrameMetrics& aFrameMetrics, const TimeDuration& aDelta)
{
TimeStamp now = mApzc.GetFrameTime();
CSSToParentLayerScale2D zoom = aFrameMetrics.GetZoom();
// If the animation is finished, make sure the final position is correct by
// using one last displacement. Otherwise, compute the delta via the timing
// function as normal.
bool finished = IsFinished(now);
nsPoint sampledDest = finished
? mDestination
: PositionAt(now);
ParentLayerPoint displacement =
(CSSPoint::FromAppUnits(sampledDest) - aFrameMetrics.GetScrollOffset()) * zoom;
if (finished) {
mApzc.mX.SetVelocity(0);
mApzc.mY.SetVelocity(0);
} else if (!IsZero(displacement)) {
// Velocity is measured in ParentLayerCoords / Milliseconds
float xVelocity = displacement.x / aDelta.ToMilliseconds();
float yVelocity = displacement.y / aDelta.ToMilliseconds();
mApzc.mX.SetVelocity(xVelocity);
mApzc.mY.SetVelocity(yVelocity);
}
// Note: we ignore overscroll for generic animations.
ParentLayerPoint adjustedOffset, overscroll;
mApzc.mX.AdjustDisplacement(displacement.x, adjustedOffset.x, overscroll.x);
mApzc.mY.AdjustDisplacement(displacement.y, adjustedOffset.y, overscroll.y,
mForceVerticalOverscroll);
// If we expected to scroll, but there's no more scroll range on either axis,
// then end the animation early. Note that the initial displacement could be 0
// if the compositor ran very quickly (<1ms) after the animation was created.
// When that happens we want to make sure the animation continues.
if (!IsZero(displacement) && IsZero(adjustedOffset)) {
// Nothing more to do - end the animation.
return false;
}
aFrameMetrics.ScrollBy(adjustedOffset / zoom);
return !finished;
}