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, zoom in, & zoom out shortcuts #122

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
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: 2 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@
<script src="tags/settings-window.tag.html" type="riot/tag"></script>
<script src="tags/label-panel.tag.html" type="riot/tag"></script>
<script src="tags/attributes-list.tag.html" type="riot/tag"></script>
<script src="js/common-actions.js" type="riot/tag"></script>

<script src="tags/actions/lightbulb-action.tag.html" type="riot/tag"></script>
<script src="tags/actions/landmark-action.tag.html" type="riot/tag"></script>
Expand Down Expand Up @@ -167,6 +168,7 @@
<script src="js/app.js"></script>
<script src="js/nimnObjStructure.js"></script>


<script src="dataformaters/coco.js"></script>
<script src="dataformaters/pascal_voc.js"></script>
</body>
Expand Down
17 changes: 17 additions & 0 deletions js/common-actions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
document.addEventListener('keydown', e=>{

if (e.key == '≠') {//Zoom in
$("#tool-zoom").click();
$("[data-zoom-type='in']").click();
e.preventDefault();
e.stopPropagation();
}

if (e.key == '–') {//Zoom out
$("#tool-zoom").click();
$("[data-zoom-type='out']").click();
e.preventDefault();
e.stopPropagation();
}
});

4 changes: 4 additions & 0 deletions tags/actions/zoom-action.tag.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
<div class="tool-icon icon-cw" data-zoom-type="reset" onclick={ zoom }/>
</div>
</div>

<script>
var tag = this;
tag.zoom = function (e){
Expand Down Expand Up @@ -67,6 +68,9 @@
rescaleImage();
}




this.on('mount', function () {
//reset the input box's value according to image scale
if(imgSelected) $("#zoom-scale").val(Math.round(imgSelected.size.imageScale*100)+'%');
Expand Down
3 changes: 2 additions & 1 deletion tags/shortcuts.tag.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
<tr><td><kbd>Alt</kbd> + <kbd>p</kbd></td><td> Polygon<td></tr>
<tr><td><kbd>Alt</kbd> + <kbd>w</kbd></td><td> Magic wand<td></tr>
<tr><td><kbd>Alt</kbd> + <kbd>m</kbd></td><td> Move<td></tr>
<tr><td><kbd>Alt</kbd> + <kbd>+</kbd></td><td> Zoom<td></tr>
<tr><td><kbd>Alt</kbd> + <kbd>+</kbd></td><td> Zoom in<td></tr>
<tr><td><kbd>Alt</kbd> + <kbd>-</kbd></td><td> Zoom out<td></tr>
<tr><td><kbd>Alt</kbd> + <kbd>l</kbd></td><td> Light<td></tr>
</table>
`,
Expand Down
10 changes: 8 additions & 2 deletions tags/toolbox.tag.html
Original file line number Diff line number Diff line change
Expand Up @@ -66,18 +66,24 @@
e.stopPropagation()
} */

if (e.key == 'm' && e.altKey){//Magic wand
if (e.key == 'm' && e.altKey){//Move
$("#tool-move").click();
e.preventDefault();
e.stopPropagation()
}

if (e.key == 'l' && e.altKey){//Magic wand
if (e.key == 'l' && e.altKey){//Light
$("#tool-light").click();
e.preventDefault();
e.stopPropagation()
}

if (e.key == 'Ω'){//Zoom
$("#tool-zoom").click();
e.preventDefault();
e.stopPropagation()
}

});
});

Expand Down