I am looking for a good plugin to easily scale and pan an existing SVG image. I already use a plugin called Jquery.panzoom and it works well, but when scaling SVG loses clarity and becomes blurry. Not sure if anyone can direct me in the right direction on this?
Here is my jQuery -
(function ($) { var $parent = $('#floor_plan'); if($parent.length) { // set-up panzoom var $panzoom = $parent.find('.panzoom').panzoom({ increment : 0.5, minScale : 1, maxScale : 8, startTransform : 'scale(4.0)', $zoomIn : $parent.find('A[href=#zoom_in]'), $zoomOut : $parent.find('A[href=#zoom_out]'), contain : 'invert' }).panzoom('zoom', true); // handle scrolling in and out $panzoom.parent().on('mousewheel.focal', function (e) { e.preventDefault(); var delta = e.delta || e.originalEvent.wheelDelta; var zoomOut = delta ? delta < 0 : e.originalEvent.deltaY > 0; $panzoom.panzoom('zoom', zoomOut, { increment : 0.1, animate : false, focal : e }); }); } })(jQuery);
And HTML -
<div id="floor_plan" class="hidden-xs hidden-sm"> <div class="zoom-control"> <a href="#zoom_in"><i class="fa fa-fw fa-plus-square-o"></i></a> <a href="#zoom_out"><i class="fa fa-fw fa-minus-square-o"></i></a> </div> <div class="close"> <a href="#close_floor_plan"><i class="fa fa-fw fa-times"></i></a> </div> <div class="panzoom"> <img src="http://blog.millermedeiros.com/wp-content/uploads/2010/04/awesome_tiger.svg" alt="Floor Plan" style="width: 100%; height: auto; display: block" /> </div> </div>
JSFiddle example here - http://jsfiddle.net/576a4qeh/1/
Original demo here (bottom of page) - http://timmywil.imtqy.com/jquery.panzoom/demo/
Try zooming in (using the mouse wheel over the image) and you will notice that it is blurry. Resize the window and it will return to quality.
Look forward to your thoughts and help.
Thanks!
source share