-
Notifications
You must be signed in to change notification settings - Fork 13.5k
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
bug: Android native scrolling strange behaviour #4022
Comments
@CheetahDev, this might also partly be coming from the same problem as what we're seeing in ios in #4008. .run(function() {
ionic.Gestures.gestures.Drag.handler = function dragGesture(ev, inst) {
if(ev.srcEvent.type == 'touchstart' || ev.srcEvent.type == 'touchend') {
this.preventedFirstMove = false;
} else if(!this.preventedFirstMove && ev.srcEvent.type == 'touchmove') {
// Prevent gestures that are not intended for this event handler from firing subsequent times
if(inst.options.prevent_default_directions.length > 0 && inst.options.prevent_default_directions.indexOf(ev.direction) != -1) {
ev.srcEvent.preventDefault();
}
this.preventedFirstMove = true;
}
// current gesture isnt drag, but dragged is true
// this means an other gesture is busy. now call dragend
if(ionic.Gestures.detection.current.name != this.name && this.triggered) {
inst.trigger(this.name + 'end', ev);
this.triggered = false;
return;
}
// max touches
if(inst.options.drag_max_touches > 0 &&
ev.touches.length > inst.options.drag_max_touches) {
return;
}
switch(ev.eventType) {
case ionic.Gestures.EVENT_START:
this.triggered = false;
break;
case ionic.Gestures.EVENT_MOVE:
// when the distance we moved is too small we skip this gesture
// or we can be already in dragging
if(ev.distance < inst.options.drag_min_distance &&
ionic.Gestures.detection.current.name != this.name) {
return;
}
// we are dragging!
if(ionic.Gestures.detection.current.name != this.name) {
ionic.Gestures.detection.current.name = this.name;
if(inst.options.correct_for_drag_min_distance) {
// When a drag is triggered, set the event center to drag_min_distance pixels from the original event center.
// Without this correction, the dragged distance would jumpstart at drag_min_distance pixels instead of at 0.
// It might be useful to save the original start point somewhere
var factor = Math.abs(inst.options.drag_min_distance / ev.distance);
ionic.Gestures.detection.current.startEvent.center.pageX += ev.deltaX * factor;
ionic.Gestures.detection.current.startEvent.center.pageY += ev.deltaY * factor;
// recalculate event data using new start point
ev = ionic.Gestures.detection.extendEventData(ev);
}
}
// lock drag to axis?
if(ionic.Gestures.detection.current.lastEvent.drag_locked_to_axis || (inst.options.drag_lock_to_axis && inst.options.drag_lock_min_distance <= ev.distance)) {
ev.drag_locked_to_axis = true;
}
var last_direction = ionic.Gestures.detection.current.lastEvent.direction;
if(ev.drag_locked_to_axis && last_direction !== ev.direction) {
// keep direction on the axis that the drag gesture started on
if(ionic.Gestures.utils.isVertical(last_direction)) {
ev.direction = (ev.deltaY < 0) ? ionic.Gestures.DIRECTION_UP : ionic.Gestures.DIRECTION_DOWN;
} else {
ev.direction = (ev.deltaX < 0) ? ionic.Gestures.DIRECTION_LEFT : ionic.Gestures.DIRECTION_RIGHT;
}
}
// first time, trigger dragstart event
if(!this.triggered) {
inst.trigger(this.name + 'start', ev);
this.triggered = true;
}
// trigger normal event
inst.trigger(this.name, ev);
// direction event, like dragdown
inst.trigger(this.name + ev.direction, ev);
// block the browser events
if((inst.options.drag_block_vertical && ionic.Gestures.utils.isVertical(ev.direction)) ||
(inst.options.drag_block_horizontal && !ionic.Gestures.utils.isVertical(ev.direction))) {
ev.preventDefault();
}
break;
case ionic.Gestures.EVENT_END:
// trigger dragend
if(this.triggered) {
inst.trigger(this.name + 'end', ev);
}
this.triggered = false;
break;
}
};
}) |
@jskrzypek your fix seems to work well! Waiting for a response from Ionic' team. Sad to see that native scrolling doesn't work properly in two consecutive releases. 😞 |
Awesome! Should we merge this issue with #4008? |
Moving this over to #4008 |
@jskrzypek, your code fixed it for me on android 4.4. but with the side effect that I can now scroll vertical lists a few pixels left and right. |
Review revert fix in #3695 for 1.2.2 |
This appears to be an issue with the side menu content area specifically. The drag handler on the side menu interacts with the content touch events |
Fixed. Will be out in 1.2.2 |
Reopening, need a slightly different approach to ensure no issues with iOS |
Hi @CheetahDev, Are you still seeing an issue here? What am I supposed to be seeing on my device when I follow your steps? Everything seems fine on my device. Is there a particular action I should be taking? Please let me know. Thanks, |
Hello all! As it seems it has been a while since there was any activity on this issue i will be closing it for now. Feel free to comment if you are still running into this issue. Thanks for using Ionic! |
Type: bug
Platform: android 4.4 webview
Hi,
I've been using Ionic' native scrolling since it has been released, but I disabled it in the last version due to #3727.
I saw the 1.0.1 update yesterday and I tried it as soon as I arrived at work. I re-enabled native scrolling and... boom... huge bug/strange behaviour.
Sometimes scroll is working, sometimes not (depending on the touched element, etc.).
Easiest way to reproduce:
Infos:
J.
The text was updated successfully, but these errors were encountered: