Guest User

Untitled

a guest
Sep 20th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. private const val MAX_SCALE = 1.0f
  2.  
  3. private const val MIN_SCALE = 0.8f
  4.  
  5. class ZoomOutSlideTransformer : ViewPager.PageTransformer {
  6.  
  7. override fun transformPage(page: View, pos: Float) {
  8. val position = when {
  9. pos < -1 -> -1f
  10. pos > 1 -> 1f
  11. else -> pos
  12. }
  13.  
  14. val tempScale = if (position < 0) 1 + position else 1 - position
  15.  
  16. val slope = (MAX_SCALE - MIN_SCALE) / 1
  17. val scaleValue = MIN_SCALE + tempScale * slope
  18. page.scaleX = scaleValue
  19. page.scaleY = scaleValue
  20. }
  21. }
Add Comment
Please, Sign In to add comment