Allow landing on fixed elements in obsidian

This commit is contained in:
Idrees Hassan
2025-11-13 20:44:11 -05:00
parent 042d0e3b07
commit fbbfd25f30
9 changed files with 30 additions and 10 deletions

6
dist/birb.js vendored
View File

@@ -1946,7 +1946,7 @@
insertModal(`${birdBirb()} Mode`, message);
}),
new Separator(),
new MenuItem("2025.11.13.47", () => { alert("Thank you for using Pocket Bird! You are on version: 2025.11.13.47"); }, false),
new MenuItem("2025.11.13.64", () => { alert("Thank you for using Pocket Bird! You are on version: 2025.11.13.64"); }, false),
];
const styleElement = document.createElement("style");
@@ -2590,7 +2590,11 @@
// @ts-expect-error
const largeElements = Array.from(visible).filter((img) => img instanceof HTMLElement && img !== focusedElement && img.offsetWidth >= MIN_FOCUS_ELEMENT_WIDTH);
// Ensure the bird doesn't land on fixed or sticky elements
const fixedAllowed = getContext() instanceof ObsidianContext;
const nonFixedElements = largeElements.filter((el) => {
if (fixedAllowed) {
return true;
}
const style = window.getComputedStyle(el);
return style.position !== "fixed" && style.position !== "sticky";
});

BIN
dist/extension.zip vendored

Binary file not shown.

View File

@@ -1946,7 +1946,7 @@
insertModal(`${birdBirb()} Mode`, message);
}),
new Separator(),
new MenuItem("2025.11.13.47", () => { alert("Thank you for using Pocket Bird! You are on version: 2025.11.13.47"); }, false),
new MenuItem("2025.11.13.64", () => { alert("Thank you for using Pocket Bird! You are on version: 2025.11.13.64"); }, false),
];
const styleElement = document.createElement("style");
@@ -2590,7 +2590,11 @@
// @ts-expect-error
const largeElements = Array.from(visible).filter((img) => img instanceof HTMLElement && img !== focusedElement && img.offsetWidth >= MIN_FOCUS_ELEMENT_WIDTH);
// Ensure the bird doesn't land on fixed or sticky elements
const fixedAllowed = getContext() instanceof ObsidianContext;
const nonFixedElements = largeElements.filter((el) => {
if (fixedAllowed) {
return true;
}
const style = window.getComputedStyle(el);
return style.position !== "fixed" && style.position !== "sticky";
});

View File

@@ -2,7 +2,7 @@
"manifest_version": 3,
"name": "Pocket Bird",
"description": "It's a pet bird in your browser, what more could you want?",
"version": "2025.11.13.47",
"version": "2025.11.13.64",
"homepage_url": "https://idreesinc.com",
"icons": {
"48": "images/icons/transparent/48x48x1.png",

View File

@@ -2,7 +2,7 @@
const { Plugin, Notice } = require('obsidian');
module.exports = class PocketBird extends Plugin {
onload() {
console.log("Loading Pocket Bird version 2025.11.13.47...");
console.log("Loading Pocket Bird version 2025.11.13.64...");
const OBSIDIAN_PLUGIN = this;
(function () {
'use strict';
@@ -1952,7 +1952,7 @@ module.exports = class PocketBird extends Plugin {
insertModal(`${birdBirb()} Mode`, message);
}),
new Separator(),
new MenuItem("2025.11.13.47", () => { alert("Thank you for using Pocket Bird! You are on version: 2025.11.13.47"); }, false),
new MenuItem("2025.11.13.64", () => { alert("Thank you for using Pocket Bird! You are on version: 2025.11.13.64"); }, false),
];
const styleElement = document.createElement("style");
@@ -2596,7 +2596,11 @@ module.exports = class PocketBird extends Plugin {
// @ts-expect-error
const largeElements = Array.from(visible).filter((img) => img instanceof HTMLElement && img !== focusedElement && img.offsetWidth >= MIN_FOCUS_ELEMENT_WIDTH);
// Ensure the bird doesn't land on fixed or sticky elements
const fixedAllowed = getContext() instanceof ObsidianContext;
const nonFixedElements = largeElements.filter((el) => {
if (fixedAllowed) {
return true;
}
const style = window.getComputedStyle(el);
return style.position !== "fixed" && style.position !== "sticky";
});

View File

@@ -1,7 +1,7 @@
{
"id": "pocket-bird",
"name": "Pocket Bird",
"version": "2025.11.13.47",
"version": "2025.11.13.64",
"minAppVersion": "0.15.0",
"description": "It's a pet bird in your Obsidian, what more could you want?",
"author": "Idrees Hassan",

View File

@@ -1,7 +1,7 @@
// ==UserScript==
// @name Pocket Bird
// @namespace https://idreesinc.com
// @version 2025.11.13.47
// @version 2025.11.13.64
// @description It's a bird that hops around your web browser, the future is here
// @author Idrees
// @downloadURL https://github.com/IdreesInc/Pocket-Bird/raw/refs/heads/main/dist/userscript/birb.user.js
@@ -1960,7 +1960,7 @@
insertModal(`${birdBirb()} Mode`, message);
}),
new Separator(),
new MenuItem("2025.11.13.47", () => { alert("Thank you for using Pocket Bird! You are on version: 2025.11.13.47"); }, false),
new MenuItem("2025.11.13.64", () => { alert("Thank you for using Pocket Bird! You are on version: 2025.11.13.64"); }, false),
];
const styleElement = document.createElement("style");
@@ -2604,7 +2604,11 @@
// @ts-expect-error
const largeElements = Array.from(visible).filter((img) => img instanceof HTMLElement && img !== focusedElement && img.offsetWidth >= MIN_FOCUS_ELEMENT_WIDTH);
// Ensure the bird doesn't land on fixed or sticky elements
const fixedAllowed = getContext() instanceof ObsidianContext;
const nonFixedElements = largeElements.filter((el) => {
if (fixedAllowed) {
return true;
}
const style = window.getComputedStyle(el);
return style.position !== "fixed" && style.position !== "sticky";
});

View File

@@ -2,7 +2,7 @@ import Frame from './frame.js';
import Layer from './layer.js';
import Anim from './anim.js';
import { Birb, Animations } from './birb.js';
import { getContext } from './context.js';
import { getContext, ObsidianContext } from './context.js';
import {
Directions,
@@ -880,7 +880,11 @@ Promise.all([
// @ts-expect-error
const largeElements = Array.from(visible).filter((img) => img instanceof HTMLElement && img !== focusedElement && img.offsetWidth >= MIN_FOCUS_ELEMENT_WIDTH);
// Ensure the bird doesn't land on fixed or sticky elements
const fixedAllowed = getContext() instanceof ObsidianContext;
const nonFixedElements = largeElements.filter((el) => {
if (fixedAllowed) {
return true;
}
const style = window.getComputedStyle(el);
return style.position !== "fixed" && style.position !== "sticky";
});

View File

@@ -222,7 +222,7 @@ class BrowserExtensionContext extends Context {
}
}
class ObsidianContext extends Context {
export class ObsidianContext extends Context {
/**
* @override