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.setCustomLightbox(true); to declare you are using your own lightboxmfpanzoom-lightbox and a sub-element with class containerphp
This should still use images from a gallery with the class mfpanzoom-gallery and with the structure of <div class='mfpanzoom-gallery'><img src='...'><img src='...'>...<
_mfpanzoom.init(); to initialise the lightbox popup_mfpanzoom.setLightbox(qs('.mfpanzoom-lightbox')); to point to your custom box structure_mfpanzoom.setCurrentImage(imgElem); to extract your chosen gallery image and put it into the lightbox_mfpanzoom.doSwipe('prev', lightboxImgElem, _mfpanzoom.getPrevGalleryImg()); and _mfpanzoom.doSwipe('next', lightboxImgElem, _mfpanzoom.getNextGalleryImg());_mfpanzoom.applyInitialPosition(lightboxImgElem)_mfpanzoom.restoreCurrentImage(); on closing the lightbox, to put the lightbox element back into the galleryAlso see
articles/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