<commit_before>// Provides overlay for the source image being pointed at
// Override juxtaCallback for custom behaviour or override createHeader & createFooter
// for smaller tweaks to default behaviour

var dragonbox = document.getElementById('zoom-display');
var infobox = document.getElementById('infobox');
var header = document.getElementById('header');
var footer = document.getElementById('footer');
var imagePoint = 0;

function rawToWeb(rawX, rawY) {
    var ip = new OpenSeadragon.Point(rawX * juxtaRawW * juxtaTileSize, rawY * juxtaRawH * juxtaTileSize);
    var wp = myDragon.viewport.imageToViewportCoordinates(ip);
    var rwp = myDragon.viewport.pixelFromPoint(wp);
    return rwp;
}

function handleChange() {
    var rawX = Math.floor(imagePoint.x / juxtaTileSize / juxtaRawW);
    var rawY = Math.floor(imagePoint.y / juxtaTileSize / juxtaRawH);
    roundWebPoint = rawToWeb(rawX, rawY);
    roundWebBRPoint = rawToWeb(rawX+1, rawY+1);
    roundWebBRPoint.x = roundWebBRPoint.x-1;
    roundWebBRPoint.y = roundWebBRPoint.y-1;
    var zoom = myDragon.viewport.getZoom(true);
    juxtaExpand(rawX, rawY,
                Math.floor(roundWebPoint.x), Math.floor(roundWebPoint.y),
                Math.floor(roundWebBRPoint.x-roundWebPoint.x), Math.floor(roundWebBRPoint.y-roundWebPoint.y));
}                      

// https://openseadragon.github.io/examples/viewport-coordinates/
myDragon.addHandler('open', function() {
    var tracker = new OpenSeadragon.MouseTracker({
        element: myDragon.container,
        moveHandler: function(event) {
            var webPoint = event.position;
            var viewportPoint = myDragon.viewport.pointFromPixel(webPoint);
            imagePoint = myDragon.viewport.viewportToImageCoordinates(viewportPoint);
            handleChange();
        }
    });
    myDragon.addHandler('animation', handleChange);
    tracker.setTracking(true);  
});

var createHeader = function(x, y, image, meta) {
    return image == "" ? '(' + x + ', ' + y + ')' : image;
}
var createFooter = function(x, y, image, meta) {
  return meta;
}

var showFullInfo = function(boxWidth, boxHeight) {
    return boxWidth >= 150;
}
var showFooter = function(x, y, image, meta) {<commit_msg>Made the focus follow actions on mobile devices. This closes #28<commit_after>// Provides overlay for the source image being pointed at
// Override juxtaCallback for custom behaviour or override createHeader & createFooter
// for smaller tweaks to default behaviour

var dragonbox = document.getElementById('zoom-display');
var infobox = document.getElementById('infobox');
var header = document.getElementById('header');
var footer = document.getElementById('footer');
var imagePoint = 0;

function rawToWeb(rawX, rawY) {
    var ip = new OpenSeadragon.Point(rawX * juxtaRawW * juxtaTileSize, rawY * juxtaRawH * juxtaTileSize);
    var wp = myDragon.viewport.imageToViewportCoordinates(ip);
    var rwp = myDragon.viewport.pixelFromPoint(wp);
    return rwp;
}

function handleChange() {
    var rawX = Math.floor(imagePoint.x / juxtaTileSize / juxtaRawW);
    var rawY = Math.floor(imagePoint.y / juxtaTileSize / juxtaRawH);
    roundWebPoint = rawToWeb(rawX, rawY);
    roundWebBRPoint = rawToWeb(rawX+1, rawY+1);
    roundWebBRPoint.x = roundWebBRPoint.x-1;
    roundWebBRPoint.y = roundWebBRPoint.y-1;
    var zoom = myDragon.viewport.getZoom(true);
    juxtaExpand(rawX, rawY,
                Math.floor(roundWebPoint.x), Math.floor(roundWebPoint.y),
                Math.floor(roundWebBRPoint.x-roundWebPoint.x), Math.floor(roundWebBRPoint.y-roundWebPoint.y));
}                      

// https://openseadragon.github.io/examples/viewport-coordinates/
focusChanged = function(event) {
    var webPoint = event.position;
    var viewportPoint = myDragon.viewport.pointFromPixel(webPoint);
    imagePoint = myDragon.viewport.viewportToImageCoordinates(viewportPoint);
    handleChange();
}

myDragon.addHandler('open', function() {
    console.log("Setting up handlers");
    var tracker = new OpenSeadragon.MouseTracker({
        element: myDragon.container,
        moveHandler: focusChanged
    });
    myDragon.addHandler('animation', handleChange);
    myDragon.addHandler('canvas-drag', focusChanged);
    myDragon.addHandler('canvas-click', focusChanged);
    tracker.setTracking(true);  
});


var createHeader = function(x, y, image, meta) {
    return image == "" ? '(' + x + ', ' + y + ')' : image;
}
var createFooter = function(x, y, image, meta) {
  return meta;
}

var showFullInfo = function(boxWidth, boxHeight) {
    return boxWidth >= 150;
}
var showFooter = function(x, y, image, meta) {
{'fraction_non_alphanumeric': 0.11938687392055268, 'fraction_numerical': 0.0038860103626943004, 'mean_word_length': 3.8110072689511942, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 2, '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': '2682180', 'n_tokens_mistral': 1498, 'n_tokens_neox': 1446, 'n_words': 311}