Skip to content

Commit

Permalink
Merge pull request #11 from lhoyong/dev
Browse files Browse the repository at this point in the history
#Fix: progress bar move error
  • Loading branch information
lhoyong authored Apr 15, 2018
2 parents f62d4a9 + 314c974 commit dc43c4c
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class TransParencySeekBar @JvmOverloads constructor(
val height = View.getDefaultSize(suggestedMinimumHeight, heightMeasureSpec)
val width = View.getDefaultSize(suggestedMinimumWidth, widthMeasureSpec)

thumbX = getThumbPosition(width)
thumbX = getThumbPosition()
setMeasuredDimension(width, height)
super.onMeasure(widthMeasureSpec, heightMeasureSpec)
}
Expand All @@ -88,8 +88,8 @@ class TransParencySeekBar @JvmOverloads constructor(
}

override fun invoke(progress: Int) {
this.progress = progress

this.progress = progress // Progress Update
thumbX = getThumbPosition() // thumb Position Update
invalidate()
}

Expand All @@ -116,9 +116,9 @@ class TransParencySeekBar @JvmOverloads constructor(
}

// get Thumb X Position
private fun getThumbPosition(width: Int): Float {
private fun getThumbPosition(): Float {
val percent = (progress.toFloat() / maxProgress.toFloat()) * 100
return (width.toFloat() / 100) * percent
return (measuredWidth.toFloat() / 100) * percent
}

// change Progress
Expand Down

0 comments on commit dc43c4c

Please sign in to comment.