0

如何将初始缩放值更改为最大缩小值?目前,我将其设置为接近中点。

var init_map = function() {
    var full = 3000;
    var vmax = $map.innerWidth() > $map.innerHeight() ? $map.innerWidth() : $map.innerHeight();
    var s_min = (vmax / full) + .01;
    var s_init = $window.width() < 768 ? s_min + .14 : s_min + .1;
    var s_init = $body.hasClass('is-ipad') ? s_min + .3 : s_init;
    var s_min = parseFloat(s_min.toFixed(2));
    var s_init = parseFloat(s_init.toFixed(2));
    var s_inc = parseFloat(((s_init - s_min) / 4).toFixed(2));
    var s_max = parseFloat(s_init + (s_inc * 4));

    var y_offset = -72;
    var x_offset = ((full / 2) - ($window.width() / 2)) / 1.08;
    var s_trans = 'translate3d(-' + x_offset + 'px,' + y_offset + 'px,0) scale(' + s_init + ')';

    var options = {
      startTransform: s_trans,
      minScale: s_min,
      maxScale: s_max,
      increment: s_inc,
      exponential: false,
      duration: 350,
      easing: 'ease',
      cursor: 'drag',
      contain: 'automatic',
    };

    $map_canvas.panzoom(options);
4

1 回答 1

0

比我最初想象的要简单得多。刚刚使用s_min并移除了额外的定位量x_offset

var x_offset = ((full/2) - ($window.width()/2));
var s_trans  = 'translate3d(-'+x_offset+'px,'+y_offset+'px,0) scale('+s_min+')';

不过,不知何故,我觉得我在这里偷工减料了。

于 2019-03-19T15:57:14.550 回答