vinhne / cropzoom

Automatically exported from code.google.com/p/cropzoom
0 stars 0 forks source link

Zoom issue #14

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I have a problem when using minZoom, maxZoom and startZoom options to configure 
the zoom slider. The calculation it applies to resize the image is wrong.

Here is original code:

$slider
                                .slider({
                                    orientation : ($options.expose.zoomElement != '' ? $options.expose.slidersOrientation
                                            : 'vertical'),
                                    value : ($options.image.startZoom != 0 ? $options.image.startZoom
                                            : getPercentOfZoom(getData('image'))),
                                    min : ($options.image.useStartZoomAsMinZoom ? $options.image.startZoom
                                            : $options.image.minZoom),
                                    max : $options.image.maxZoom,
                                    step : (($options.zoomSteps > $options.image.maxZoom || $options.zoomSteps < 0) ? 1
                                            : $options.zoomSteps),
                                    slide : function(event, ui) {
                                        var value = ($options.expose.slidersOrientation == 'vertical' ? ($options.image.maxZoom - ui.value)
                                                : ui.value);
(...)

Here is the code that works for me (haven't done much testing, I mean, it might 
work just for me).

$slider
                                .slider({
                                    orientation : ($options.expose.zoomElement != '' ? $options.expose.slidersOrientation
                                            : 'vertical'),
                                    value : ($options.image.startZoom != 0 ? ($options.image.maxZoom - $options.image.startZoom + $options.image.minZoom)
                                            : getPercentOfZoom(getData('image'))),
                                    min : ($options.image.useStartZoomAsMinZoom ? $options.image.startZoom
                                            : $options.image.minZoom),
                                    max : $options.image.maxZoom,
                                    step : (($options.zoomSteps > $options.image.maxZoom || $options.zoomSteps < 0) ? 1
                                            : $options.zoomSteps),
                                    slide : function(event, ui) {
                                        var value = ($options.expose.slidersOrientation == 'vertical' ? ($options.image.maxZoom - ui.value + $options.image.minZoom)
                                                : ui.value);

I just changed how 'value' is calculated. 

Original issue reported on code.google.com by davidcas...@gmail.com on 18 May 2012 at 10:47