imglab icon indicating copy to clipboard operation
imglab copied to clipboard

Add zoom, zoom in, & zoom out shortcuts

Open bonez0607 opened this issue 5 years ago • 17 comments

Purpose / Goal

Added zoom shortcuts specified in issue #107

Hello,

This is my first real PR - so I hope I'm doing things correctly...

I added a shortcut to 'click' the zoom button. From there the user can then use shortcuts to zoom in or out. I assumed this was the desired effect since the buttons aren't mounted until the zoom button is clicked, correct?

I'm on a mac and was having issues (even with existing shortcuts) with e.key == [appropriate key] && e.altKey working. However when I used the symbol created when pressing both alt and the event key it worked as expected.

For example e.key == '=' && e.altKey didn't work but e.key == '≠' did for the alt + '+' shortcut.

If I need to change to the previous formatting of e.key && e.altKey let me know and I can change back. I checked the shortcuts in Chrome, Firefox and Safari.

There were also a couple of quick mis commented items that I fixed.

Type

Please mention the type of PR

  • [ ] Bug Fix
  • [ ] Refactoring / Technology upgrade
  • [X] New Feature
  • [ ] Documentation
  • [ ] Other : | Please Specify |

bonez0607 avatar Oct 15 '18 04:10 bonez0607

I added a shortcut to 'click' the zoom button. From there the user can then use shortcuts to zoom in or out. I assumed this was the desired effect since the buttons aren't mounted until the zoom button is clicked, correct?

Good point. I didn't think about that. We can probably move zoom in/out buttons to js functions. And the buttons in zoom-action.tag.html can just call those functions. In this way, a user needs not to open the zoom action bar to use the shortcuts.

For example e.key == '=' && e.altKey didn't work but e.key == '≠' did for the alt + '+' shortcut.

Need to be cross-checked but great if it works.

amitguptagwl avatar Oct 15 '18 05:10 amitguptagwl

That makes sense in regard to having them work without needing the action bar open. I can update it to reflect that.

Is there a specific js file you’d like the script to be in?

Lastly, would I need to open up a new PR or just amend this one?

bonez0607 avatar Oct 15 '18 23:10 bonez0607

Is there a specific js file you’d like the script to be in?

Probably common-actions.js

Lastly, would I need to open up a new PR or just amend this one?

this PR would be fine. I'll squash the changes before merging.

Important: Please check following once you complete the PR

  1. Import 2 images.
  2. Label 1st image. and zoom in/out
  3. again label it and zoom in/out
  4. check console if there is no error
  5. check if there is any change in labels position when zoom in/out

In case of confusion, you can share the screenshot or GIF for clear understanding.

amitguptagwl avatar Oct 16 '18 01:10 amitguptagwl

Alright I think I got everything working how it's supposed to. Just want to clarify some things.

  • [x] 1. Import 2 images.

  • [x] 2. Label 1st image. and zoom in/out

  1. again label it and zoom in/out

Just want to clarify that the tags are supposed to scale with the image, correct?

  • [x] 4. check console if there is no error

No errors show in console

  1. check if there is any change in labels position when zoom in/out label scales with image and maintains position - See gif

imglab - image annotation tool 2

bonez0607 avatar Oct 18 '18 04:10 bonez0607

Yes! the labeled shapes are supposed to scale along with the image. But we've previously noticed that (due to a bug which is fixed now) if you label an image, change the zoom level, relabel and zoom again then the positions of label gets changed.

amitguptagwl avatar Oct 18 '18 05:10 amitguptagwl

Ok, the zoom functions have been added to a file called js/common-actions.js. And cleaned up from the other files.

bonez0607 avatar Oct 21 '18 14:10 bonez0607

So keyboard shortcuts along with direct button click are working fine?

amitguptagwl avatar Oct 22 '18 04:10 amitguptagwl

Thanks. So keyboard shortcuts along with direct button click are working fine?

On Sun, 21 Oct 2018 at 20:02, Joe B. [email protected] wrote:

Ok, the zoom functions have been added to a file called common-actions.js. And cleaned up from the other files.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/NaturalIntelligence/imglab/pull/122#issuecomment-431673816, or mute the thread https://github.com/notifications/unsubscribe-auth/AHVgKNnnZDpR8xbi4WZVjaXTp0wLK_CFks5unIVogaJpZM4Xbki4 .

-- Cheers Amit Gupta

amitguptagwl avatar Oct 22 '18 16:10 amitguptagwl

@bonez0607 Have you get the chance to test it from buttons as well as from shortcuts?

amitguptagwl avatar Oct 27 '18 04:10 amitguptagwl

Sorry, it's was a busy weekend. I can take a look to double check tomorrow night.

bonez0607 avatar Oct 30 '18 02:10 bonez0607

Sure no problem.

amitguptagwl avatar Oct 30 '18 02:10 amitguptagwl

So the zoom shortcuts work and the buttons work w/out an error. However, when using the keyboard shortcut the percentage increments/decrements by 20% rather than the 10% change when using the buttons. I checked to make sure nothing was being called twice, as that seemed like a potential culprit.

bonez0607 avatar Nov 06 '18 05:11 bonez0607

I hope you must have console log to check if that function is being called twice. and You must have prevented event propagation.

amitguptagwl avatar Nov 06 '18 05:11 amitguptagwl

Was able to track down the offending code. Checked in Chrome, Firefox, and Safari - buttons and keyboard are working.

bonez0607 avatar Nov 06 '18 05:11 bonez0607

great. Now you have to remove the console.log statement from your code. I'll suggest you review your code one more time, just to avoid any bug in future.

amitguptagwl avatar Nov 06 '18 07:11 amitguptagwl

Doh! ok - should be good.

bonez0607 avatar Nov 07 '18 00:11 bonez0607

Thanks for the changes. I'll separately check your changes after 2 days before merge.

amitguptagwl avatar Nov 07 '18 02:11 amitguptagwl