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

fixes issue #352 #367

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
23 changes: 18 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export default class Drawer extends Component {
elevation: PropTypes.number,
initializeOpen: PropTypes.bool,
open: PropTypes.bool,
negotiatePan: PropTypes.bool,
negotiatePan: PropTypes.oneOfType([PropTypes.bool, PropTypes.func]),
onClose: PropTypes.func,
onCloseStart: PropTypes.func,
onOpen: PropTypes.func,
Expand Down Expand Up @@ -260,12 +260,18 @@ export default class Drawer extends Component {
};

onMoveShouldSetPanResponderCapture = (e, gestureState) => {
if (this.shouldCaptureGestures() && this.props.negotiatePan) return this.processMoveShouldSet(e, gestureState)
if (this.shouldCaptureGestures() && this.negotiatePan(e, gestureState)) {
return this.processMoveShouldSet(e, gestureState)
}

return false
};

onMoveShouldSetPanResponder = (e, gestureState) => {
if (!this.shouldCaptureGestures() && this.props.negotiatePan) return this.processMoveShouldSet(e, gestureState)
if (!this.shouldCaptureGestures() && this.negotiatePan(e, gestureState)) {
return this.processMoveShouldSet(e, gestureState)
}

return false
};

Expand Down Expand Up @@ -307,7 +313,7 @@ export default class Drawer extends Component {
if (!this._open && Math.abs(gestureState.dy) >= Math.abs(gestureState.dx)) return false
this._panStartTime = Date.now()
if (inMask && this.shouldCaptureGestures()) return true
if (this.props.negotiatePan) return false
if (this.negotiatePan(e, gestureState)) return false
if (!this.props.acceptPan) return false
this.terminateActiveTween()
return true
Expand All @@ -318,7 +324,7 @@ export default class Drawer extends Component {
if (!inMask && (!this.props.acceptPanOnDrawer || this._open === false )) return false
if (!this.props.acceptPan) return false

if (!this.props.negotiatePan || this.props.disabled || !this.props.acceptPan || this._panning) return false
if (!this.negotiatePan(e, gestureState) || this.props.disabled || !this.props.acceptPan || this._panning) return false
let delta = this.getGestureDelta(gestureState)
let deltaOppositeAxis = this.getGestureDeltaOppositeAxis(gestureState)
let swipeToLeftOrTop = (delta < 0) ? true : false
Expand Down Expand Up @@ -358,6 +364,12 @@ export default class Drawer extends Component {
return false
}

negotiatePan = (e, gestureState) => {
return typeof this.props.negotiatePan === 'function'
? this.props.negotiatePan(e, gestureState)
: this.props.negotiatePan
}

testPanResponderMask = (e, gestureState) => {
if (this.props.disabled) return false

Expand Down Expand Up @@ -621,3 +633,4 @@ const styles = StyleSheet.create({
backgroundColor: 'transparent'
}
})

2 changes: 1 addition & 1 deletion tweener.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Tween.prototype._rafLoop = function() {
}

var tweenVal = easingTypes[easingType](elapsed, start, end, duration);
this._config.onFrame(tweenVal);
this._config.onFrame(Math.round(tweenVal));

requestAnimationFrame(this._rafLoop);
};
Expand Down