Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ function startApplication(birbPixels, featherPixels, hatsPixels) {
} else {
newMultiplier = currentMultiplier + 1;
}
newMultiplier = Math.max(0.25, Math.round(newMultiplier * 4) / 4);
newMultiplier = Math.max(0.25, Math.min(5, Math.round(newMultiplier * 4) / 4));
userSettings.birbScaleMultiplier = newMultiplier;
save();
updateBirbScale();
Expand Down
2 changes: 1 addition & 1 deletion src/context.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export class Context {
* @returns {string[]} A list of CSS selectors for focusable elements
*/
getFocusableElements() {
return ["img", "video", ".birb-sticky-note"];
return ["img", "video", ".birb-sticky-note", "[data-birb-target]"];
}

getFocusElementTopMargin() {
Expand Down
26 changes: 24 additions & 2 deletions src/stickyNotes.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import {
* @property {string} content
* @property {number} top
* @property {number} left
* @property {number} [width]
* @property {number} [height]
*/

export class StickyNote {
Expand All @@ -21,13 +23,17 @@ export class StickyNote {
* @param {string} [content]
* @param {number} [top]
* @param {number} [left]
* @param {number} [width]
* @param {number} [height]
*/
constructor(id, site = "", content = "", top = 0, left = 0) {
constructor(id, site = "", content = "", top = 0, left = 0, width, height) {
this.id = id;
this.site = site;
this.content = content;
this.top = top;
this.left = left;
this.width = width;
this.height = height;
}
}

Expand Down Expand Up @@ -56,7 +62,8 @@ export function renderStickyNote(stickyNote, page, onSave, onDelete) {
const content = makeElement("birb-window-content");
const textarea = document.createElement("textarea");
textarea.className = "birb-sticky-note-input";
textarea.style.width = "150px";
textarea.style.width = stickyNote.width ? `${stickyNote.width}px` : "150px";
textarea.style.height = stickyNote.height ? `${stickyNote.height}px` : "";
textarea.placeholder = "Write your notes here and they'll stick to the page!";
textarea.value = stickyNote.content;
content.appendChild(textarea);
Expand Down Expand Up @@ -96,6 +103,21 @@ export function renderStickyNote(stickyNote, page, onSave, onDelete) {
onSave();
}, 250);
});

// Persist size on resize
/** @type {ReturnType<typeof setTimeout>|undefined} */
let resizeTimeout;
const resizeObserver = new ResizeObserver(() => {
stickyNote.width = textarea.offsetWidth;
stickyNote.height = textarea.offsetHeight;
if (resizeTimeout) {
clearTimeout(resizeTimeout);
}
resizeTimeout = setTimeout(() => {
onSave();
}, 250);
});
resizeObserver.observe(textarea);
}

// On window resize
Expand Down