MCPcopy Create free account
hub / github.com/axmolengine/axmol / deaccelerateScrolling

Method deaccelerateScrolling

extensions/GUI/src/GUI/ScrollView/ScrollView.cpp:429–468  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

427}
428
429void ScrollView::deaccelerateScrolling(float /*dt*/)
430{
431 if (_dragging)
432 {
433 this->unschedule(AX_SCHEDULE_SELECTOR(ScrollView::deaccelerateScrolling));
434 return;
435 }
436
437 float newX, newY;
438 Vec2 maxInset, minInset;
439
440 _container->setPosition(_container->getPosition() + _scrollDistance);
441
442 if (_bounceable)
443 {
444 maxInset = _maxInset;
445 minInset = _minInset;
446 }
447 else
448 {
449 maxInset = this->maxContainerOffset();
450 minInset = this->minContainerOffset();
451 }
452
453 newX = _container->getPosition().x;
454 newY = _container->getPosition().y;
455
456 _scrollDistance = _scrollDistance * SCROLL_DEACCEL_RATE;
457 this->setContentOffset(Vec2(newX, newY));
458
459 if ((fabsf(_scrollDistance.x) <= SCROLL_DEACCEL_DIST && fabsf(_scrollDistance.y) <= SCROLL_DEACCEL_DIST) ||
460 ((_direction == Direction::BOTH || _direction == Direction::VERTICAL) &&
461 (newY >= maxInset.y || newY <= minInset.y)) ||
462 ((_direction == Direction::BOTH || _direction == Direction::HORIZONTAL) &&
463 (newX >= maxInset.x || newX <= minInset.x)))
464 {
465 this->unschedule(AX_SCHEDULE_SELECTOR(ScrollView::deaccelerateScrolling));
466 this->relocateContainer(true);
467 }
468}
469
470void ScrollView::stoppedAnimatedScroll(Node* /*node*/)
471{

Callers

nothing calls this directly

Calls 8

maxContainerOffsetMethod · 0.95
minContainerOffsetMethod · 0.95
setContentOffsetMethod · 0.95
relocateContainerMethod · 0.95
Vec2Function · 0.50
unscheduleMethod · 0.45
setPositionMethod · 0.45
getPositionMethod · 0.45

Tested by

no test coverage detected