From: xangelo Date: Wed, 25 Jan 2023 18:43:20 +0000 (-0500) Subject: bug: stop scrolling page when moving through search results X-Git-Url: https://git.xangelo.ca/?a=commitdiff_plain;h=f3a8b6fe0a0f68a43103347fc065734fbaedddb6;p=outliner.git bug: stop scrolling page when moving through search results Disable scrolling the page when moving through search results. Will auto-focus on result if it is off screen. --- diff --git a/public/assets/bundle.js b/public/assets/bundle.js index 0a39e1d..ae072e4 100644 --- a/public/assets/bundle.js +++ b/public/assets/bundle.js @@ -18624,12 +18624,13 @@ save(); /*!***********************!*\ !*** ./src/cursor.ts ***! \***********************/ -/***/ ((__unused_webpack_module, exports) => { +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { "use strict"; Object.defineProperty(exports, "__esModule", ({ value: true })); exports.Cursor = void 0; +const dom_1 = __webpack_require__(/*! dom */ "./src/dom.ts"); class Cursor { constructor() { } @@ -18650,7 +18651,7 @@ class Cursor { const el = document.querySelector(elementId); if (el) { el.classList.add('cursor'); - if (!this.isVisible(elementId)) { + if (!(0, dom_1.isVisible)(el)) { el.scrollIntoView(true); } } @@ -18669,18 +18670,32 @@ class Cursor { isNodeExpanded() { return this.get().classList.contains('expanded'); } - isVisible(elementId) { - const el = document.querySelector(elementId); - var rect = el.getBoundingClientRect(); - return (rect.top >= 0 && - rect.left >= 0 && - rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) && - rect.right <= (window.innerWidth || document.documentElement.clientWidth)); - } } exports.Cursor = Cursor; +/***/ }), + +/***/ "./src/dom.ts": +/*!********************!*\ + !*** ./src/dom.ts ***! + \********************/ +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.isVisible = void 0; +function isVisible(element) { + const rect = element.getBoundingClientRect(); + return (rect.top >= 0 && + rect.left >= 0 && + rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) && + rect.right <= (window.innerWidth || document.documentElement.clientWidth)); +} +exports.isVisible = isVisible; + + /***/ }), /***/ "./src/help.ts": @@ -19058,6 +19073,7 @@ exports.Search = void 0; const lyra_1 = __webpack_require__(/*! @lyrasearch/lyra */ "./node_modules/@lyrasearch/lyra/dist/cjs/index.cjs"); const lodash_1 = __webpack_require__(/*! lodash */ "./node_modules/lodash/lodash.js"); const keyboardjs_1 = __importDefault(__webpack_require__(/*! keyboardjs */ "./node_modules/keyboardjs/dist/keyboard.js")); +const dom_1 = __webpack_require__(/*! dom */ "./src/dom.ts"); const searchModal = `