Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement startDelay + fix image scale transition #6137

Merged
merged 1 commit into from
Apr 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package com.reactnativenavigation.utils

import android.animation.Animator
import android.animation.TimeInterpolator
import android.view.animation.Interpolator

fun Animator.withStartDelay(delay: Long): Animator {
startDelay = delay
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@ import androidx.core.animation.doOnStart
import com.facebook.react.views.text.ReactTextView
import com.facebook.react.views.view.ReactViewBackgroundDrawable
import com.reactnativenavigation.parse.SharedElementTransitionOptions
import com.reactnativenavigation.utils.ColorUtils
import com.reactnativenavigation.utils.ViewUtils
import com.reactnativenavigation.utils.withInterpolator
import com.reactnativenavigation.utils.withStartDelay
import com.reactnativenavigation.utils.*

class BackgroundColorAnimator(from: View, to: View) : PropertyAnimatorCreator<ViewGroup>(from, to) {
override fun shouldAnimateProperty(fromChild: ViewGroup, toChild: ViewGroup): Boolean {
Expand All @@ -35,7 +32,7 @@ class BackgroundColorAnimator(from: View, to: View) : PropertyAnimatorCreator<Vi
fromColor,
toColor
)
.setDuration(options.getDuration())
.withDuration(options.getDuration())
.withStartDelay(options.getStartDelay())
.withInterpolator(options.interpolation.interpolator)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class ClipBoundsAnimator(from: View, to: View) : PropertyAnimatorCreator<ReactIm
startDrawingRect,
endDrawingRect
)
.setDuration(options.getDuration())
.withDuration(options.getDuration())
.withStartDelay(options.getStartDelay())
.withInterpolator(options.interpolation.interpolator)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
package com.reactnativenavigation.views.element.animators

import android.animation.Animator
import android.animation.AnimatorListenerAdapter
import android.animation.ObjectAnimator
import android.animation.TypeEvaluator
import android.graphics.Rect
import android.view.View
import androidx.core.animation.addListener
import androidx.core.animation.doOnStart
import com.facebook.drawee.drawable.ScalingUtils.InterpolatingScaleType
import com.facebook.react.views.image.ReactImageView
import com.reactnativenavigation.parse.SharedElementTransitionOptions
Expand Down Expand Up @@ -38,7 +35,7 @@ class MatrixAnimator(from: View, to: View) : PropertyAnimatorCreator<ReactImageV
}
null
}, 0, 1)
.setDuration(options.getDuration())
.withDuration(options.getDuration())
.withStartDelay(options.getStartDelay())
.withInterpolator(options.interpolation.interpolator)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class ScaleXAnimator(from: View, to: View) : PropertyAnimatorCreator<ViewGroup>(
to.scaleX = from.width.toFloat() / to.width
return ObjectAnimator
.ofFloat(to, View.SCALE_X, from.width.toFloat() / to.width, 1f)
.setDuration(options.getDuration())
.withDuration(options.getDuration())
.withStartDelay(options.getStartDelay())
.withInterpolator(options.interpolation.interpolator)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import android.animation.Animator
import android.animation.ObjectAnimator
import android.view.View
import android.view.ViewGroup
import androidx.core.animation.addListener
import androidx.core.animation.doOnStart
import com.facebook.react.views.text.ReactTextView
import com.reactnativenavigation.parse.SharedElementTransitionOptions
import com.reactnativenavigation.utils.withDuration
Expand All @@ -23,7 +21,7 @@ class ScaleYAnimator(from: View, to: View) : PropertyAnimatorCreator<ViewGroup>(
to.scaleY = from.height.toFloat() / to.height
return ObjectAnimator
.ofFloat(to, View.SCALE_Y, from.height.toFloat() / to.height, 1f)
.setDuration(options.getDuration())
.withDuration(options.getDuration())
.withStartDelay(options.getStartDelay())
.withInterpolator(options.interpolation.interpolator)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import androidx.core.animation.doOnStart
import com.facebook.react.views.text.ReactTextView
import com.reactnativenavigation.parse.SharedElementTransitionOptions
import com.reactnativenavigation.utils.ViewUtils
import com.reactnativenavigation.utils.withDuration
import com.reactnativenavigation.utils.withInterpolator
import com.reactnativenavigation.utils.withStartDelay

Expand All @@ -31,7 +32,7 @@ class XAnimator(from: View, to: View) : PropertyAnimatorCreator<View>(from, to)
to.translationX = dx.toFloat()
return ObjectAnimator
.ofFloat(to, TRANSLATION_X, dx.toFloat(), 0f)
.setDuration(options.getDuration())
.withDuration(options.getDuration())
.withStartDelay(options.getStartDelay())
.withInterpolator(options.interpolation.interpolator)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
package com.reactnativenavigation.views.element.animators

import android.animation.Animator
import android.animation.AnimatorListenerAdapter
import android.animation.ObjectAnimator
import android.view.View
import android.view.View.TRANSLATION_Y
import android.view.ViewGroup
import androidx.core.animation.addListener
import androidx.core.animation.doOnStart
import com.facebook.react.views.text.ReactTextView
import com.reactnativenavigation.parse.SharedElementTransitionOptions
import com.reactnativenavigation.utils.ViewUtils
import com.reactnativenavigation.utils.withDuration

import com.reactnativenavigation.utils.withInterpolator
import com.reactnativenavigation.utils.withStartDelay

Expand All @@ -32,7 +31,7 @@ class YAnimator(from: View, to: View) : PropertyAnimatorCreator<View>(from, to)
to.translationY = dy.toFloat()
return ObjectAnimator
.ofFloat(to, TRANSLATION_Y, dy.toFloat(), 0f)
.setDuration(options.getDuration())
.withDuration(options.getDuration())
.withStartDelay(options.getStartDelay())
.withInterpolator(options.interpolation.interpolator)
}
Expand Down