1
0
mirror of https://github.com/lrsjng/pagemap.git synced 2025-08-29 07:50:04 +02:00
This commit is contained in:
Lars Jung
2024-11-09 19:17:33 +01:00
parent cff4c99036
commit 192be62516
10 changed files with 5372 additions and 6182 deletions

229
dist/pagemap.js vendored
View File

@@ -1,4 +1,4 @@
/*! pagemap v1.4.0 - https://larsjung.de/pagemap/ */
/*! pagemap v1.4.1 - undefined */
(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory();
@@ -8,108 +8,21 @@
exports["pagemap"] = factory();
else
root["pagemap"] = factory();
})((typeof self !== 'undefined' ? self : this), function() {
return /******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
/******/ }
/******/ };
/******/
/******/ // define __esModule on exports
/******/ __webpack_require__.r = function(exports) {
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ }
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
/******/
/******/ // create a fake namespace object
/******/ // mode & 1: value is a module id, require it
/******/ // mode & 2: merge all properties of value into the ns
/******/ // mode & 4: return value when already ns object
/******/ // mode & 8|1: behave like require
/******/ __webpack_require__.t = function(value, mode) {
/******/ if(mode & 1) value = __webpack_require__(value);
/******/ if(mode & 8) return value;
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
/******/ var ns = Object.create(null);
/******/ __webpack_require__.r(ns);
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
/******/ return ns;
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 0);
/******/ })
/************************************************************************/
/******/ ([
})((typeof self !== 'undefined' ? self : this), () => {
return /******/ (() => { // webpackBootstrap
/******/ var __webpack_modules__ = ([
/* 0 */
/***/ (function(module, exports, __webpack_require__) {
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
/* WEBPACK VAR INJECTION */(function(global) {module.exports = function (canvas, options) {
var WIN = global.window;
module.exports = function (canvas, options) {
var WIN = __webpack_require__.g.window;
var DOC = WIN.document;
var DOC_EL = DOC.documentElement;
var BODY = DOC.querySelector('body');
var CTX = canvas.getContext('2d');
var black = function black(pc) {
return "rgba(0,0,0,".concat(pc / 100, ")");
};
var settings = Object.assign({
viewport: null,
styles: {
@@ -122,21 +35,17 @@ return /******/ (function(modules) { // webpackBootstrap
drag: black(10),
interval: null
}, options);
var _listener = function _listener(el, method, types, fn) {
return types.split(/\s+/).forEach(function (type) {
return el[method](type, fn);
});
};
var on = function on(el, types, fn) {
return _listener(el, 'addEventListener', types, fn);
};
var off = function off(el, types, fn) {
return _listener(el, 'removeEventListener', types, fn);
};
var Rect = function Rect(x, y, w, h) {
return {
x: x,
@@ -145,7 +54,6 @@ return /******/ (function(modules) { // webpackBootstrap
h: h
};
};
var rect_rel_to = function rect_rel_to(rect) {
var pos = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
x: 0,
@@ -153,15 +61,12 @@ return /******/ (function(modules) { // webpackBootstrap
};
return Rect(rect.x - pos.x, rect.y - pos.y, rect.w, rect.h);
};
var rect_of_doc = function rect_of_doc() {
return Rect(0, 0, DOC_EL.scrollWidth, DOC_EL.scrollHeight);
};
var rect_of_win = function rect_of_win() {
return Rect(WIN.pageXOffset, WIN.pageYOffset, DOC_EL.clientWidth, DOC_EL.clientHeight);
};
var el_get_offset = function el_get_offset(el) {
var br = el.getBoundingClientRect();
return {
@@ -169,31 +74,24 @@ return /******/ (function(modules) { // webpackBootstrap
y: br.top + WIN.pageYOffset
};
};
var rect_of_el = function rect_of_el(el) {
var _el_get_offset = el_get_offset(el),
x = _el_get_offset.x,
y = _el_get_offset.y;
x = _el_get_offset.x,
y = _el_get_offset.y;
return Rect(x, y, el.offsetWidth, el.offsetHeight);
};
var rect_of_viewport = function rect_of_viewport(el) {
var _el_get_offset2 = el_get_offset(el),
x = _el_get_offset2.x,
y = _el_get_offset2.y;
x = _el_get_offset2.x,
y = _el_get_offset2.y;
return Rect(x + el.clientLeft, y + el.clientTop, el.clientWidth, el.clientHeight);
};
var rect_of_content = function rect_of_content(el) {
var _el_get_offset3 = el_get_offset(el),
x = _el_get_offset3.x,
y = _el_get_offset3.y;
x = _el_get_offset3.x,
y = _el_get_offset3.y;
return Rect(x + el.clientLeft - el.scrollLeft, y + el.clientTop - el.scrollTop, el.scrollWidth, el.scrollHeight);
};
var calc_scale = function () {
var width = canvas.clientWidth;
var height = canvas.clientHeight;
@@ -201,27 +99,22 @@ return /******/ (function(modules) { // webpackBootstrap
return Math.min(width / w, height / h);
};
}();
var resize_canvas = function resize_canvas(w, h) {
canvas.width = w;
canvas.height = h;
canvas.style.width = "".concat(w, "px");
canvas.style.height = "".concat(h, "px");
};
var viewport = settings.viewport;
var find = function find(sel) {
return Array.from((viewport || DOC).querySelectorAll(sel));
};
var drag = false;
var root_rect;
var view_rect;
var scale;
var drag_rx;
var drag_ry;
var draw_rect = function draw_rect(rect, col) {
if (col) {
CTX.beginPath();
@@ -230,7 +123,6 @@ return /******/ (function(modules) { // webpackBootstrap
CTX.fill();
}
};
var apply_styles = function apply_styles(styles) {
Object.keys(styles).forEach(function (sel) {
var col = styles[sel];
@@ -239,7 +131,6 @@ return /******/ (function(modules) { // webpackBootstrap
});
});
};
var draw = function draw() {
root_rect = viewport ? rect_of_content(viewport) : rect_of_doc();
view_rect = viewport ? rect_of_viewport(viewport) : rect_of_win();
@@ -252,98 +143,108 @@ return /******/ (function(modules) { // webpackBootstrap
apply_styles(settings.styles);
draw_rect(rect_rel_to(view_rect, root_rect), drag ? settings.drag : settings.view);
};
var on_drag = function on_drag(ev) {
ev.preventDefault();
var cr = rect_of_viewport(canvas);
var x = (ev.pageX - cr.x) / scale - view_rect.w * drag_rx;
var y = (ev.pageY - cr.y) / scale - view_rect.h * drag_ry;
if (viewport) {
viewport.scrollLeft = x;
viewport.scrollTop = y;
} else {
WIN.scrollTo(x, y);
}
draw();
};
var on_drag_end = function on_drag_end(ev) {
var _on_drag_end = function on_drag_end(ev) {
drag = false;
canvas.style.cursor = 'pointer';
BODY.style.cursor = 'auto';
off(WIN, 'mousemove', on_drag);
off(WIN, 'mouseup', on_drag_end);
off(WIN, 'mouseup', _on_drag_end);
on_drag(ev);
};
var on_drag_start = function on_drag_start(ev) {
drag = true;
var cr = rect_of_viewport(canvas);
var vr = rect_rel_to(view_rect, root_rect);
drag_rx = ((ev.pageX - cr.x) / scale - vr.x) / vr.w;
drag_ry = ((ev.pageY - cr.y) / scale - vr.y) / vr.h;
if (drag_rx < 0 || drag_rx > 1 || drag_ry < 0 || drag_ry > 1) {
drag_rx = 0.5;
drag_ry = 0.5;
}
canvas.style.cursor = 'crosshair';
BODY.style.cursor = 'crosshair';
on(WIN, 'mousemove', on_drag);
on(WIN, 'mouseup', on_drag_end);
on(WIN, 'mouseup', _on_drag_end);
on_drag(ev);
};
var init = function init() {
canvas.style.cursor = 'pointer';
on(canvas, 'mousedown', on_drag_start);
on(viewport || WIN, 'load resize scroll', draw);
if (settings.interval > 0) {
setInterval(function () {
return draw();
}, settings.interval);
}
draw();
};
init();
return {
redraw: draw
};
};
/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(1)))
/***/ }),
/* 1 */
/***/ (function(module, exports) {
var g;
// This works in non-strict mode
g = (function() {
return this;
})();
try {
// This works if eval is allowed (see CSP)
g = g || new Function("return this")();
} catch (e) {
// This works if the window reference is available
if (typeof window === "object") g = window;
}
// g can still be undefined, but nothing to do about it...
// We return undefined, instead of nothing here, so it's
// easier to handle this case. if(!global) { ...}
module.exports = g;
/***/ })
/******/ ]);
/******/ ]);
/************************************************************************/
/******/ // The module cache
/******/ var __webpack_module_cache__ = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/ // Check if module is in cache
/******/ var cachedModule = __webpack_module_cache__[moduleId];
/******/ if (cachedModule !== undefined) {
/******/ return cachedModule.exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = __webpack_module_cache__[moduleId] = {
/******/ // no module.id needed
/******/ // no module.loaded needed
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/************************************************************************/
/******/ /* webpack/runtime/global */
/******/ (() => {
/******/ __webpack_require__.g = (function() {
/******/ if (typeof globalThis === 'object') return globalThis;
/******/ try {
/******/ return this || new Function('return this')();
/******/ } catch (e) {
/******/ if (typeof window === 'object') return window;
/******/ }
/******/ })();
/******/ })();
/******/
/************************************************************************/
/******/
/******/ // startup
/******/ // Load entry module and return exports
/******/ // This entry module is referenced by other modules so it can't be inlined
/******/ var __webpack_exports__ = __webpack_require__(0);
/******/
/******/ return __webpack_exports__;
/******/ })()
;
});