Skip to content

Commit

Permalink
Fix Drawer can be over-offset (#3)
Browse files Browse the repository at this point in the history
* Bump to 1.0.1
  • Loading branch information
drakeet committed Jan 5, 2021
1 parent cf66a94 commit 83e2979
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ In your `build.gradle`:

```groovy
dependencies {
implementation 'com.drakeet.drawer:drawer:1.0.0'
implementation 'com.drakeet.drawer:drawer:1.0.1'
// Optional: No need if you just use the FullDraggableHelper
implementation 'androidx.drawerlayout:drawerlayout:1.1.1'
}
Expand Down Expand Up @@ -62,7 +62,7 @@ See `com.drakeet.drawer.FullDraggableHelper`
## TODO

- [x] Add support for the right drawer / RTL
- [x] Add support for other kinds of drawer
- [x] Add support for other kinds of drawers

License
-------
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
buildscript {

ext.kotlinVersion = '1.4.21'
ext.buildConfig = ['versionCode' : 3,
'versionName' : "1.0.0",
ext.buildConfig = ['versionCode' : 4,
'versionName' : "1.0.1",
'compileSdkVersion': 30,
'minSdkVersion' : 19,
'targetSdkVersion' : 30]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import android.widget.FrameLayout;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.math.MathUtils;
import androidx.core.view.GravityCompat;
import androidx.core.view.ViewCompat;
import androidx.drawerlayout.widget.DrawerLayout;
Expand Down Expand Up @@ -141,7 +142,7 @@ protected List<DrawerLayout.DrawerListener> getDrawerListeners() {

protected void setDrawerToOffset(int gravity, float offset) {
View drawerView = findDrawerWithGravity(gravity);
float slideOffsetPercent = offset / requireNonNull(drawerView).getWidth();
float slideOffsetPercent = MathUtils.clamp(offset / requireNonNull(drawerView).getWidth(), 0f, 1f);
try {
Method method = DrawerLayout.class.getDeclaredMethod("moveDrawerToOffset", View.class, float.class);
method.setAccessible(true);
Expand Down

0 comments on commit 83e2979

Please sign in to comment.