public void act(float delta) { super.act(delta); boolean panning = flickScrollListener.getGestureDetector().isPanning(); if (fadeAlpha > 0 && fadeScrollBars && !panning && !touchScrollH && !touchScrollV) { fadeDelay -= delta; if (fadeDelay <= 0) fadeAlpha = Math.max(0, fadeAlpha - delta); } if (flingTimer > 0) { resetFade(); float alpha = flingTimer / flingTime; amountX -= velocityX * alpha * delta; amountY -= velocityY * alpha * delta; clamp(); // Stop fling if hit overscroll distance. if (amountX == -overscrollDistance) velocityX = 0; if (amountX >= maxX + overscrollDistance) velocityX = 0; if (amountY == -overscrollDistance) velocityY = 0; if (amountY >= maxY + overscrollDistance) velocityY = 0; flingTimer -= delta; if (flingTimer <= 0) { velocityX = 0; velocityY = 0; } } if (smoothScrolling && flingTimer <= 0 && !touchScrollH && !touchScrollV && !panning) { if (visualAmountX != amountX) { if (visualAmountX < amountX) visualScrollX( Math.min( amountX, visualAmountX + Math.max(150 * delta, (amountX - visualAmountX) * 5 * delta))); else visualScrollX( Math.max( amountX, visualAmountX - Math.max(150 * delta, (visualAmountX - amountX) * 5 * delta))); } if (visualAmountY != amountY) { if (visualAmountY < amountY) visualScrollY( Math.min( amountY, visualAmountY + Math.max(150 * delta, (amountY - visualAmountY) * 5 * delta))); else visualScrollY( Math.max( amountY, visualAmountY - Math.max(150 * delta, (visualAmountY - amountY) * 5 * delta))); } } else { if (visualAmountX != amountX) visualScrollX(amountX); if (visualAmountY != amountY) visualScrollY(amountY); } if (!panning) { if (overscrollX && scrollX) { if (amountX < 0) { resetFade(); amountX += (overscrollSpeedMin + (overscrollSpeedMax - overscrollSpeedMin) * -amountX / overscrollDistance) * delta; if (amountX > 0) scrollX(0); } else if (amountX > maxX) { resetFade(); amountX -= (overscrollSpeedMin + (overscrollSpeedMax - overscrollSpeedMin) * -(maxX - amountX) / overscrollDistance) * delta; if (amountX < maxX) scrollX(maxX); } } if (overscrollY && scrollY) { if (amountY < 0) { resetFade(); amountY += (overscrollSpeedMin + (overscrollSpeedMax - overscrollSpeedMin) * -amountY / overscrollDistance) * delta; if (amountY > 0) scrollY(0); } else if (amountY > maxY) { resetFade(); amountY -= (overscrollSpeedMin + (overscrollSpeedMax - overscrollSpeedMin) * -(maxY - amountY) / overscrollDistance) * delta; if (amountY < maxY) scrollY(maxY); } } } }