Having spent some time investigating image zooming, I had been using the anavaka panzoom from GitHub but decided it was just too painful and the support
The aim was to provide a light weight mouse
Mouse & Touch capable (as of release 1.0)
Key Features
The class also manages the understanding that galleries might show thumbnails, but the lightbox behind each will want to show the full-sized image.
Implementation requires the .js and .css files to be included
html
Then all that is needed is for any <img> you wish to be managed to include the mfpanzoom class.
html
When the .js file loads, it will create the _mfpanzoom global, and automatically calls _mfpanzoom.init() to initialise the images on the page.
Any <img> within a .mfpanzoom-gallery class will be presented as a gallery thumbnail with click to view functionality.
html
If you are wishing to show the gallery with thumbnails, but lightbox the full sized image then you can use _mfpanzoom.setOption('fullsizeAttrArr', ['data-alt-src']); with your chosen alt-src attribute:
html
js
To include a caption against each <img> as you lightbox view them, you can include a data-caption attribute:
html
Outside of the .mfpanzoom-gallery, any <img> with the class .mfpanzoom will support panzoom from the existing position; to do this it will add a container around those images to support the zooming.
By default, the images will be presented centered and fitting the container space. To adjust this you can call
js
To configure a boundary space around the zoomed image:
js
To turn on or off drifting after a pan move
js
If you want to capture swipe leftswipeLeftRight option, e.g.
js
This is also called on first view in the lightbox; direction arguments include:
To add in an hourglass when a large image is being loaded, you can use hourglassShowCB and hourglassRemoveCB, e.g.
html
...and...
js
If you want to implement your own lighbox instead of the out-of-the-box mfpanzoom lightbox, then you can but there are some steps:
_mfpanzoom.setOption('showlightboxCB',function (lightbox, currentImg, originalPlaceholderStub) {_mfpanzoom.setOption('swipeLeftRightCB', function (direction, newImgElem) { to handle next_mfpanzoom.setOption('fullsizeAttrArr', ['data-lazy-src']); to counter lazy image effortsIf you want to implement a single image lightbox then you can use showPanZoomPopupSolo() on click, e.g.
html
Also see
articles/How-to-format-html-ready-for-console.logsquarearticles/Implementing-a-Monaco-Editorsquarearticles/iConnectionTestsquarearticles/imagick-fiddlesquarearticles/javascript-camerasquarearticles/list-editsquarearticles/minifierssquarearticles/opayosquarearticles/table-drag-sortersquarearticles/typewatchsquareprojects/MFCalculatorPopupsquareprojects/MFCalendarPopupsquareprojects/MFChartColumnsquareprojects/MFColorPickersquareprojects/MFColorPickerBasicsquareprojects/MFColumnDataBarsquareprojects/MFColumnGradientsquareprojects/MFCropCornerUIsquareprojects/MFFloatawayMsgsquareprojects/MFHourglasssquareprojects/MFLazyImagessquareprojects/MFPanZoomsquareprojects/MFPanelssquareprojects/MFScrollIndicatorssquareprojects/MFSelectorsquareprojects/MFShowConsolesquareprojects/MFTableCellSummingsquare