Skip to content

Commit

Permalink
Add 'F' hotkey for fullscreen toggle in lightbox
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmz committed Jan 13, 2024
1 parent 7dce987 commit 1b121f8
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/services/lightbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { Icon } from '../components/fontawesome-icons';

const prevHotKeys = ['a', 'ф', 'h', 'р', '4'];
const nextHotKeys = ['d', 'в', 'k', 'л', '6'];
const fullScreenHotKeys = ['f', 'а'];

export function openLightbox(index, dataSource) {
initLightbox().loadAndOpen(index, dataSource);
Expand Down Expand Up @@ -90,10 +91,12 @@ function initLightbox() {
lightbox.on('beforeOpen', () => {
Mousetrap.bind(prevHotKeys, () => lightbox.pswp.prev());
Mousetrap.bind(nextHotKeys, () => lightbox.pswp.next());
Mousetrap.bind(fullScreenHotKeys, () => document.querySelector('.pswp__button--fs')?.click());
});
lightbox.on('destroy', () => {
Mousetrap.unbind(prevHotKeys);
Mousetrap.unbind(nextHotKeys);
Mousetrap.unbind(fullScreenHotKeys);
});

// Fix dimensions for images without known width/height
Expand Down

0 comments on commit 1b121f8

Please sign in to comment.