| 379 | } |
| 380 | |
| 381 | void ScrollView::relocateContainer(bool animated) |
| 382 | { |
| 383 | Vec2 oldPoint, min, max; |
| 384 | float newX, newY; |
| 385 | |
| 386 | min = this->minContainerOffset(); |
| 387 | max = this->maxContainerOffset(); |
| 388 | |
| 389 | oldPoint = _container->getPosition(); |
| 390 | |
| 391 | newX = oldPoint.x; |
| 392 | newY = oldPoint.y; |
| 393 | if (_direction == Direction::BOTH || _direction == Direction::HORIZONTAL) |
| 394 | { |
| 395 | newX = MAX(newX, min.x); |
| 396 | newX = MIN(newX, max.x); |
| 397 | } |
| 398 | |
| 399 | if (_direction == Direction::BOTH || _direction == Direction::VERTICAL) |
| 400 | { |
| 401 | newY = MIN(newY, max.y); |
| 402 | newY = MAX(newY, min.y); |
| 403 | } |
| 404 | |
| 405 | if (newY != oldPoint.y || newX != oldPoint.x) |
| 406 | { |
| 407 | this->setContentOffset(Vec2(newX, newY), animated); |
| 408 | } |
| 409 | } |
| 410 | |
| 411 | Vec2 ScrollView::maxContainerOffset() |
| 412 | { |
no test coverage detected