Skip to content

Commit

Permalink
Fix the occasional black screen problem when sliding (#232)
Browse files Browse the repository at this point in the history
Fix the occasional black screen problem when sliding

---------

Co-authored-by: Hannes Achleitner <[email protected]>
  • Loading branch information
wcl9900 and hannesa2 authored May 18, 2023
1 parent 368d5ac commit 44a5dc4
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions library/src/main/java/com/panoramagl/PLManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -849,12 +849,17 @@ open class PLManager(private val context: Context) : PLIView, SensorEventListene

protected fun inertia() {
if (this.isLocked || isValidForCameraAnimation || mIsValidForTransition) return
val m = (mEndPoint!!.y - mStartPoint!!.y) / (mEndPoint!!.x - mStartPoint!!.x)
val b = (mStartPoint!!.y * mEndPoint!!.x - mEndPoint!!.y * mStartPoint!!.x) / (mEndPoint!!.x - mStartPoint!!.x)
val dx = mEndPoint!!.x - mStartPoint!!.x
if(dx == 0f){
stopInertia()
return
}
val m = (mEndPoint!!.y - mStartPoint!!.y) / dx
val b = (mStartPoint!!.y * mEndPoint!!.x - mEndPoint!!.y * mStartPoint!!.x) / dx
val x: Float
val y: Float
val add: Float
if (Math.abs(mEndPoint!!.x - mStartPoint!!.x) >= Math.abs(mEndPoint!!.y - mStartPoint!!.y)) {
if (Math.abs(dx) >= Math.abs(mEndPoint!!.y - mStartPoint!!.y)) {
add = if (mEndPoint!!.x > mStartPoint!!.x) -mInertiaStepValue else mInertiaStepValue
x = mEndPoint!!.x + add
if (add > 0.0f && x > mStartPoint!!.x || add <= 0.0f && x < mStartPoint!!.x) {
Expand Down

0 comments on commit 44a5dc4

Please sign in to comment.