我正在尝试通过使用 jQuery 为多个堆叠图像按顺序制作动画来重新创建地图的放大效果,以实现跨域目的。
到目前为止,我通过对每个图像使用延迟和两个单个动画(A 和 B 日志)对动画进行排队,以便通过缩放生成图像之间的平滑过渡,并在下一个图像上淡化它们。
$('img:not(:last-child)') /* All images but farest zoom */
.reverse() /* From last to first */
.each(function (index) {
    $(this).css( /* From half size… */ {
        'width': 584,
        'height': 336,
        'margin-left': -292,
        'margin-top': -168
    });
    $(this).delay(index * 300).animate( /* …to actual size */ {
        'width': 1168,
        'height': 673,
        'margin-left': -584,
        'margin-top': -336
    }, {
        duration: 300,
        easing: 'linear',
        done: function () {
            console.log('A:', index, new Date().getTime() - timestamp);
        }
    });
});
$('img:not(:first-child)') /* All images but closest zoom */
.reverse() /* From last to first */
.each(function (index) {
    $(this).animate( /* Animate to double size */ {
        'width': 2336,
        'height': 1346,
        'margin-left': -1168,
        'margin-top': -673,
        'opacity': 0
    }, {
        duration: 300,
        easing: 'linear',
        done: function () {
            console.log('B:', index, new Date().getTime() - timestamp);
            $(this).remove(); /* Remove the elment once completed */
        }
    });
});
众所周知,jQuery 缺乏对单个队列中不同 DOM 元素的队列动画的支持,这导致了这种复杂的解决方案。
请检查这个小提琴。
如您所见,一旦图像完全加载并在地图中单击,动画队列就会启动。但它远非完美。过渡根本不流畅,导致动画之间有一点停顿,这会破坏结果。我已经尝试了几个小时,玩超时,重新考虑算法,强制线性转换,但没有结果。
我的主要目标是实现流畅的动画,然后为整个动画重新创建像“摇摆”这样的全局缓动效果,随着中间图像的动画效果逐渐加快。