Skip to content

Commit

Permalink
Refactor classes name and some variable
Browse files Browse the repository at this point in the history
  • Loading branch information
abdularis committed Apr 13, 2018
1 parent 01ac4ba commit 3683737
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Creates effect such as vertical parallax, horizontal parallax etc. on android Im
## Usage
- Create vertical parallax image view
~~~xml
<com.github.abdularis.piv.VerticalParallaxImageView
<com.github.abdularis.piv.VerticalScrollParallaxImageView
android:id="@+id/image_view"
android:layout_width="200dp"
android:layout_height="170dp"
Expand All @@ -17,7 +17,7 @@ Creates effect such as vertical parallax, horizontal parallax etc. on android Im

- Create Horizontal parallax image view
~~~xml
<com.github.abdularis.piv.HorizontalParallaxImageView
<com.github.abdularis.piv.HorizontalScrollParallaxImageView
android:id="@+id/image_view"
android:layout_width="200dp"
android:layout_height="170dp"
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/item_image.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
android:layout_width="match_parent"
android:layout_height="200dp">

<com.github.abdularis.piv.VerticalParallaxImageView
<com.github.abdularis.piv.VerticalScrollParallaxImageView
android:id="@+id/image"
android:layout_width="match_parent"
android:layout_height="match_parent"
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/item_image_horizontal.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
android:layout_width="180dp"
android:layout_height="240dp">

<com.github.abdularis.piv.HorizontalParallaxImageView
<com.github.abdularis.piv.HorizontalScrollParallaxImageView
android:id="@+id/image"
android:layout_width="match_parent"
android:layout_height="match_parent"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import com.github.abdularis.piv.transformer.HorizontalParallaxTransformer
/**
* Created by abdularis 08/04/2018
*/
class HorizontalParallaxImageView : ScrollTransformImageView {
class HorizontalScrollParallaxImageView : ScrollTransformImageView {
constructor(ctx: Context) : super(ctx)
constructor(ctx: Context, attributeSet: AttributeSet) : super(ctx, attributeSet)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import com.github.abdularis.piv.transformer.VerticalParallaxTransformer
/**
* Created by abdularis 08/04/2018
*/
class VerticalParallaxImageView : ScrollTransformImageView {
class VerticalScrollParallaxImageView : ScrollTransformImageView {
constructor(ctx: Context) : super(ctx)
constructor(ctx: Context, attributeSet: AttributeSet) : super(ctx, attributeSet)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ class HorizontalParallaxTransformer : ViewTransformer() {
// image view and the bitmap image itself
if (imageWidth * viewHeight > viewWidth * imageHeight) {
val scale = viewHeight.toFloat() / imageHeight.toFloat()
val invisibleBitmapWidth = imageWidth * scale - viewWidth
val invisibleHorizontalArea = imageWidth * scale - viewWidth

val x = centeredX(viewX, viewWidth, deviceWidth)
val translationScale = invisibleBitmapWidth / (deviceWidth + viewWidth)
val translationScale = invisibleHorizontalArea / (deviceWidth + viewWidth)
canvas.translate(-x * translationScale, 0f)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ class VerticalParallaxTransformer : ViewTransformer() {
// image view and the bitmap image itself
if (imageWidth * viewHeight < viewWidth * imageHeight) {
val scale = viewWidth.toFloat() / imageWidth.toFloat()
val invisibleBitmapHeight = imageHeight * scale - viewHeight
val invisibleVerticalArea = imageHeight * scale - viewHeight

val y = centeredY(viewY, viewHeight, deviceHeight)
val translationScale = invisibleBitmapHeight / (deviceHeight + viewHeight)
val translationScale = invisibleVerticalArea / (deviceHeight + viewHeight)
canvas.translate(0f, y * translationScale)
}
}
Expand Down

0 comments on commit 3683737

Please sign in to comment.