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

Sidebar doesn't unfold when zoomed in #298

Closed
sanderd17 opened this issue Oct 27, 2018 · 3 comments
Closed

Sidebar doesn't unfold when zoomed in #298

sanderd17 opened this issue Oct 27, 2018 · 3 comments

Comments

@sanderd17
Copy link

sanderd17 commented Oct 27, 2018

When zoomed in, clicking on the "Layers" button doesn't open the sidebar.

To Reproduce
Steps to reproduce the behavior:

  • Open the editor
  • Zoom in using CTRL++ to 110% or more
  • Click on the "LAYERS" button
  • The sidebar doesn't unfold

Expected behavior
The sidebar should open and show the layer settings.

SVG-Edit environment

  • File for SVG-Edit: svg-editor-es.html
  • Versions tested: 3.0.0 and master
  • Protocols: http and file

Desktop:

  • OS: Linux
  • Browser Firefox
  • Version 62

Additional context

Reason is that the pixes are zoomed in, $('#sidepanels').width() returns 2.25, while the check is done on 2.

See svg-editor.js line 4977

const toggleSidePanel = function (close) {
   const w = $('#sidepanels').width();
   const deltaX = (w > 2 || close ? 2 : SIDEPANEL_OPENWIDTH) - w;
   changeSidePanelWidth(deltaX);
};

I don't know enough about the code structure on where to keep the state (whether the bar is considered open or not). Apparently deducing it from the HTML style doesn't always work.

@brettz9
Copy link
Contributor

brettz9 commented Oct 27, 2018

Thank you for the report. There is a reason we have the bug report template, however, as it helps us to confirm, debug, etc., knowing what version you are using, etc. If you need help finding the information, let us know.

@sanderd17
Copy link
Author

I updated the post with the requested info.

@brettz9 brettz9 added the bug label Oct 27, 2018
@brettz9
Copy link
Contributor

brettz9 commented Oct 28, 2018

Thanks!

I get decent-seeming behavior (including for zoom less than 100%) when changing to this to take into account the zoom through window.devicePixelRatio:

const toggleSidePanel = function (close) {
    const dpr = window.devicePixelRatio || 1;
    const w = $('#sidepanels').width();
    const isOpened = (dpr < 1 ? w : w / dpr) > 2;
    const zoomAdjustedSidepanelWidth = (dpr < 1 ? 1 : dpr) * SIDEPANEL_OPENWIDTH;
    const deltaX = (isOpened || close ? 0 : zoomAdjustedSidepanelWidth) - w;
    changeSidePanelWidth(deltaX);
  };

I changed the 2nd "2" to "0" as I don't see why we should be changing the value at all if we determined it is already open/closed, and it seems fine.

Let me know if these changes work for you...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants