-
-
Notifications
You must be signed in to change notification settings - Fork 3.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
allowTouchScrolling doesn't work #5903
Comments
Is anyone able to merge this? |
I got stuck in understanding if there is something fundamentally wrong in my last touch events pr. |
How to solve this problem @asturur |
"we have this same line in _onMouseMove event here?" What does this sentence mean @0ro |
@Oro your pr is probably good and i did not forget about it. |
I meant we have the same behavior in _onMouseMove method and in onTouchStart we don't. I added this behavior in my pr. |
I will look into this as soon as i m having back my touch device. not firing preventDefault would mean add back the removal of mousedown listener when touchstart fires. Stuff i was happy to have removed. Seems silly to me that is possible to stop the mouse events fire but just at the cost of preventing everything. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Same problem here, scrolling doesn't work on mobile devices with allowTouchScrolling = true. |
We have a PR tracking this |
Same problem. |
Same Problem here |
could fix it adding this to the Script
|
Same problem in version 3.6.2, does anybody has any solution for this ? |
you can see my solution in pull request above #5904 |
@0ro does that mean I need to go into the code and update it myself? I'm using the 3.6.3 npm package. |
I tried your solution but its still not working. |
The same problem |
uses fix outlined in fabricjs#5903 to address touch issues
Same Problem here, Is there any fix ?? |
Is there any hack solution while waiting for this issue being solved? thanks! |
Found the cause of this bug. First line (e.preventDefault();) in the _onTouchStart function prevents the event propagation. FabricJS version 4.1.0 |
Has anyone found a fix to allow mobile scrolling to work? I've tried a bunch of workarounds but couldn't get any to work. |
Try this code in your project. It works with fabric 4.1.0
Also set touch-action for canvases:
|
Thanks @AlexShmalex for your solution, very helpful. My solution was similar - I wanted to allow object selection/move and drawing - I think for a general solution there could be more considerations. (function(){
var defaultOnTouchStartHandler = fabric.Canvas.prototype._onTouchStart;
fabric.util.object.extend(fabric.Canvas.prototype, {
_onTouchStart: function(e) {
var target = this.findTarget(e);
// if allowTouchScrolling is enabled, no object was at the
// the touch position and we're not in drawing mode, then
// let the event skip the fabricjs canvas and do default
// behavior
if (this.allowTouchScrolling && !target && !this.isDrawingMode) {
// returning here should allow the event to propagate and be handled
// normally by the browser
return;
}
// otherwise call the default behavior
defaultOnTouchStartHandler.call(this, e);
}
});
})(); |
@AlexShmalex I wasn't able to get your code above to work. My create canvas function looks like:
And then I put your code into a <script> at the bottom of the body. It had no effect so I probably did something incorrect. I'm not too well versed in Javascript. |
It works well, thank you |
I got this code to work, but if I select and try to move an object the canvas is still scrolling. How can I stop the scrolling behavior if an object is selected? |
Try this:
|
Uncaught TypeError: Cannot read property 'on' of undefined. Seems there is an issue around "canvas.on" |
Hi @wnbittle , where exactly should I add this code? Sorry if this is a bad question, I am new to fabric.js library. |
@NandeeshG This should be run after you've loaded the fabric.js script but before you interact with the library. |
Any update on this? It's pretty important to have this functionality on mobile and it's been over a year with no fix. |
Try this code (basically @AlexShmalex's code with a minor change):
|
This issue is still relevant in version 3.4.1, I'm experiencing the same issue in #6980 edit: var defaultOnTouchStartHandler = fabric.Canvas.prototype._onTouchStart;
}); Seems to work well, perhaps this could be integrated into the master branch? |
Same Problem here |
@alexey-altteam's code and @wnbittle's edit work like a charm in fabricjs 4.2.0, thank you! |
Hi, do you know how to make it work in Typescript? |
@asturur |
This fix is needed for fabric 5.3 too |
Does anybody has a working solution to use in fabric v6 ? |
I am too looking for a solution for V6. Is allowTouchScrolling not working at all? or is there a specific set of parameters that need to be added/avoided for it to work properly? @0ro your solution works perfectly for v 5.3, do you know how it can be recreated for v6? |
This solution works for my scenario in V6, @alexisbar not sure if it will work for everybody, but you can try this: (function () {
var defaultOnTouchStartHandler = Canvas.prototype._onTouchStart;
Object.assign(Canvas.prototype, {
_onTouchStart: function (e) {
var target = this.findTarget(e);
if (this.allowTouchScrolling && !target && !this.isDrawingMode) {
return;
}
defaultOnTouchStartHandler.call(this, e);
}
});
})(); |
For everyone having issue with allowTouchScrolling check this |
Version
3.4.0
Test Case
https://codepen.io/den-bogdanov/pen/eYOwbPj
Information about the environment
mobile browser chrome, safari
Steps to reproduce
Open test case and try to scroll with help device emulation in devtools or from a mobile device
Expected Behavior
Must be scrolling
Actual Behavior
No touch scrolling
The text was updated successfully, but these errors were encountered: