Page MenuHomePhabricator

mobile-html section offsets
Closed, ResolvedPublic

Description

Background information

To handle quick scrolling in the table of contents, the Android app needs to know the offset of every section in the article

What

getSectionOffsets(...tbd...)

Event Timeline

These change with screen dimensions (on rotation etc) and when tables are (un)collapsed. Shouldn't the offset simply be determined on click?

@Dbrant answered my question above ^ it's cause Android's TOC needs to know all section offsets at once.

Ideally we would need the WebView to provide us with this kind of structure:

{"sections": [
    {"heading":"Barack Obama", "id":"0", "yOffset":290},
    {"heading":"Early life and career", "id":"1", "yOffset":2923},
    {"heading":"Education", "id":"2", "yOffset":4300},
   ...

with yOffset assumed to be px units (device independent pixels)

Sounds like we need to have a way for the page library to know the ToC structure, right?

Still ok if I take a stab at this?

Assuming the body is present (would have to be to get offsets) the method I was thinking about would be similar to...
getSectionHeadingsData(body: HTMLBodyElement)
...and would return data structured the way @Dbrant specified.

@Mhurd and @bearND here is the first try for this task: https://github.com/wikimedia/wikimedia-page-library/pull/206

Testing is not ideal, would like some feedback.

Mentioned in SAL (#wikimedia-operations) [2019-07-02T17:43:34Z] <bsitzmann@deploy1001> Started deploy [mobileapps/deploy@9ca9b0f]: Update mobileapps to 941e14f (T219998 T217352 T219909)

Mentioned in SAL (#wikimedia-operations) [2019-07-02T17:49:24Z] <bsitzmann@deploy1001> Finished deploy [mobileapps/deploy@9ca9b0f]: Update mobileapps to 941e14f (T219998 T217352 T219909) (duration: 05m 49s)