<commit_before>

// WARNING: iOS 9 requires ES5


// Notify native code that the page has loaded.
window.addEventListener("load", function(){ // on page load
    // Notify native code that the page is loaded.
    webkit.messageHandlers.didLoad.postMessage("");
    window.addEventListener("orientationchange", orientationChanged);
}, false);

var last_known_scroll_position = 0;
var ticking = false;
var maxScreenX = 0;

// Position in range [0 - 1].
var update = function(position) {
    var positionString = position.toString()
    webkit.messageHandlers.updateProgression.postMessage(positionString);
};

window.addEventListener('scroll', function(e) {
    last_known_scroll_position = window.scrollX / document.getElementsByTagName("body")[0].scrollWidth;
    if (!ticking) {
        window.requestAnimationFrame(function() {
            update(last_known_scroll_position);
            ticking = false;
        });
    }
    ticking = true;
});

function orientationChanged() {
    maxScreenX = (window.orientation === 0 || window.orientation == 180) ? screen.width : screen.height;
    snapCurrentPosition();
}

// Scroll to the given TagId in document and snap.
var scrollToId = function(id) {
    var element = document.getElementById(id);
    var elementOffset = element.scrollLeft // element.getBoundingClientRect().left works for Gutenbergs books
    var offset = window.scrollX + elementOffset;

    document.body.scrollLeft = snapOffset(offset);<commit_msg>Report the proper scroll position depending on the scroll mode<commit_after>

// WARNING: iOS 9 requires ES5


// Notify native code that the page has loaded.
window.addEventListener("load", function(){ // on page load
    // Notify native code that the page is loaded.
    webkit.messageHandlers.didLoad.postMessage("");
    window.addEventListener("orientationchange", orientationChanged);
}, false);

var last_known_scrollX_position = 0;
var last_known_scrollY_position = 0;
var ticking = false;
var maxScreenX = 0;

// Position in range [0 - 1].
var update = function(position) {
    var positionString = position.toString()
    webkit.messageHandlers.updateProgression.postMessage(positionString);
};

window.addEventListener('scroll', function(e) {
    last_known_scrollY_position = window.scrollY / document.body.scrollHeight;
    last_known_scrollX_position = window.scrollX / document.body.scrollWidth;
    if (!ticking) {
        window.requestAnimationFrame(function() {
            update(isScrollModeEnabled() ? last_known_scrollY_position : last_known_scrollX_position);
            ticking = false;
        });
    }
    ticking = true;
});

function orientationChanged() {
    maxScreenX = (window.orientation === 0 || window.orientation == 180) ? screen.width : screen.height;
    snapCurrentPosition();
}

function isScrollModeEnabled() {
    return document.documentElement.style.getPropertyValue("--USER__scroll").toString().trim() == 'readium-scroll-on';
}

// Scroll to the given TagId in document and snap.
var scrollToId = function(id) {
    var element = document.getElementById(id);
    var elementOffset = element.scrollLeft // element.getBoundingClientRect().left works for Gutenbergs books
    var offset = window.scrollX + elementOffset;

    document.body.scrollLeft = snapOffset(offset);
{'fraction_non_alphanumeric': 0.11070559610705596, 'fraction_numerical': 0.006690997566909975, 'mean_word_length': 4.067796610169491, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2458667', 'n_tokens_mistral': 922, 'n_tokens_neox': 891, 'n_words': 229}