Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add zoom command. #2978

Closed
wants to merge 1 commit into from

Conversation

smblott-github
Copy link
Collaborator

Examples:

map = zoom in factor=1.1
map - zoom in factor=1.1

map = zoom factor=1.1
map - zoom factor=0.90909

Fixes #1866.

Examples:

    map = zoom in factor=1.1
    map - zoom in factor=1.1

    map = zoom factor=1.1
    map - zoom factor=0.90909
@ghost
Copy link

ghost commented Jun 28, 2018

Please merge 😻

@NightMachinery
Copy link

Please merge.

@maxim-danilov
Copy link

It's a very useful feature. I use zooming on every site. Please add support:

map q zoomIn
map w zoomOut

Or just merge the commit.

@Monirzadeh
Copy link

please merge

@alfozan
Copy link

alfozan commented May 17, 2019

+1

@philc
Copy link
Owner

philc commented Jan 6, 2020

@smblott-github we used to have a zoom command in the early days of Vimium. Here's the initial commit (d367e58). We even saved the preference per domain, and had a configurable default zoom level (6042b7f) in Vimium.

I removed (dc114c1) this command because setting document.body.style.zoom doesn't work the same as whatever Chrome is doing when you use Chrome's native zoom. In particular, text would start unexpectedly wrapping on some pages based on the zoom level, which never happens with Chrome's native zoom.

See git log --grep=zoom for all related commits and for some of the complexity this feature caused.

If we rework this to use Chrome's native zoom API rather than document.body.style.zoom, that should solve the zoom robustness piece.

To make this feature more robust, we could then add:

  1. Remembering the setting for the given domain as Chrome does (assuming use of the zoom settings API doesn't already do that by default; requires further investigation).
  2. Implement a default zoom level setting, as Chrome has. That way, we will start zooming or unzooming from the user's default, rather than from 100%. For my use case, I wanted every page to be zoomed to 120% by default, and wanted a command to increase or decrease it from there. Chrome's default functionality implements this well.

I would argue that this command is not acceptable without adding #1, because our zoom is inferior to Chrome's native zoom in a really annoying way (i.e. it has a hidden sharp edge). I could see people navigating to reddit.com, zooming in, and the next time they navigate there, zooming in again because their settings weren't saved, and doing that every time they load the page. With Chrome's native zoom functionality, they would only have to zoom once.

EDIT: fixed commit IDs.

@j-cr
Copy link

j-cr commented Oct 27, 2020

Saka key has this feature:
https://github.com/lusakasa/saka-key/blob/3ec7984c1a1d630f6c1eb5b9a6932678cf6a21a3/src/modes/command/background/commands/tab.js#L161

const zoomStep = 10 // for 10%

/** Zoom in the active tab of the current window */
export async function zoomIn () {
  const [tab] = await browser.tabs.query({ currentWindow: true, active: true })
  const zoomFactor = await browser.tabs.getZoom()
  await browser.tabs.setZoom(tab.id, Math.min(zoomFactor + zoomStep / 100, 3.0))
}

/** Zoom out the active tab of the current window */
export async function zoomOut () {
  const [tab] = await browser.tabs.query({ currentWindow: true, active: true })
  const zoomFactor = await browser.tabs.getZoom()
  await browser.tabs.setZoom(tab.id, Math.max(zoomFactor - zoomStep / 100, 0.3))
}

/** Reset the zoom of the active tab of the current window */
export async function zoomReset () {
  const [tab] = await browser.tabs.query({ currentWindow: true, active: true })
  await browser.tabs.setZoom(tab.id, 0)
}

Seems straightforward?

(1) and (2) from the comment above already work as expected in saka key.

EDIT: reopen #1866 since this PR is in coffeescript?

@philc
Copy link
Owner

philc commented Jul 10, 2021

Closing this PR because it's outdated, but I've reopened #1866 to track the feature request.

@philc philc closed this Jul 10, 2021
@chjj chjj mentioned this pull request Nov 19, 2023
@UncleSnail UncleSnail mentioned this pull request Jun 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature Request - Adjust zoom/fontsize via keypress
7 participants