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

Scroll support for mobile #2555

Merged
merged 6 commits into from Jun 22, 2015
Merged

Scroll support for mobile #2555

merged 6 commits into from Jun 22, 2015

Conversation

AStoker
Copy link

@AStoker AStoker commented Jun 17, 2015

There is an outstanding issue with scroll support on touch devices (one the issues described here: fix: #37 , fix: #403, fix: #1726 ). Added event listeners for touch move and touch start events to scroll appropriately.

@AStoker
Copy link
Author

AStoker commented Jun 17, 2015

Tests fail on

[4/1] test tab detection FAIL
AssertionError: "undefined" == 4
    at Object.module.exports.test tab detection (/Users/astoker/Sites/AceEditorFork/lib/ace/ext/whitespace_test.js:41:16)
    at /Users/astoker/Sites/AceEditorFork/node_modules/asyncjs/lib/async.js:226:16
    at /Users/astoker/Sites/AceEditorFork/node_modules/asyncjs/lib/async.js:35:21
    at null._onTimeout (/Users/astoker/Sites/AceEditorFork/node_modules/asyncjs/lib/async.js:149:25)
    at Timer.listOnTimeout [as ontimeout] (timers.js:112:15)

Tests currently fail on main build of Ace, so the problem isn't caused by my changes.

@AStoker
Copy link
Author

AStoker commented Jun 17, 2015

Added fixes to test described by: 2a0a696

@@ -253,6 +254,26 @@ function DefaultHandlers(mouseHandler) {
return ev.stop();
}
};

this.onTouchMove = function (ev) {
if (ev.getAccelKey())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this checks are probably not relevant for touch events

@nightwing
Copy link
Member

This looks good as a simple way to get minimal scrolling support.

Btw have you seen #2474?

var factor = 1,
touchObj = e.changedTouches[0];

e.wheelX = -(parseInt(touchObj.clientX) - startx) / factor;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are there browsers where touchObj.clientX is not a number?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I saw that pull request, but noticed it was removed, and was for an iOS application. So I have nothing to go off of there.
In regards to touchObj.clientX not being a number, if that's ever the case, then the browser is not following W3 standards (http://www.w3.org/TR/touch-events/#idl-def-Touch).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

then the browser is not following W3 standards

then we don't need parseInt call here, right?

I can merge this once you fill the cla form as described in CONTRIBUTING.md

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From the W3 site,
"clientX of type long, readonly
The horizontal coordinate of point relative to the viewport in pixels, excluding any scroll offset"

Since it's a long, we want to parse it as an int to keep scrolling at individual pixel sizes. I guess technically we could skip the parsing of an int, since a long still isn't a decimal. And thanks, I'll get right on that cla.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CLA submitted.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

long and int are the same in javascript.
Some browsers can also return fractional values for clientX, but they support fractional values for things like style.top, and work better if scroll values are not rounded.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good to know. Those changes have been committed.

nightwing added a commit that referenced this pull request Jun 22, 2015
Scroll support for mobile
@nightwing nightwing merged commit de6f75f into ajaxorg:master Jun 22, 2015
@nightwing
Copy link
Member

Thank you.

wmfgerrit pushed a commit to wikimedia/mediawiki-extensions-CodeEditor that referenced this pull request Nov 19, 2015
Updates ACE to commit:
ajaxorg/ace-builds@3fb55e8

This includes basic scrolling support in mobiles
ajaxorg/ace#2555

iOS 6 or later supported.

Android 4.x or later is supported.

Re enabled indent and outdent seems to work now, Ive tested it.

Bug: T119086
Bug: T69328
Change-Id: If8ecc499c281c92c53982cee281a88119a773514
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants