我在屏幕上有一个打开的SqueezeBox,并希望使用不同的 URL 重新打开它,以响应单击框中的链接。我正在尝试各种方法以新(不同)大小打开新 URL,以便动画流畅且只运行一次。不幸的是,标准方法(open
方法)似乎动画两次(或运行无意义的“故障”动画)。
作为替代方案,我正在尝试setContent
,但这似乎没有提供设置选项的方法,并且从我在源代码中可以看出,一旦设置了选项,SqueezeBox.initialize
它就不会做任何事情。
// (Attempt 1)
// This animation is a bit glitchy, have tried resetting resizeFx
// and sizeLoading to reduce bounce. Ideally want it to morph from
// current size to size{} without shrinking to sizeLoading{} first.
if ( false ) {
SqueezeBox.open(
url,
{
size: { x: 500, y: 500 },
sizeLoading: { x: 500, y: 500 },
resizeFx: {
duration: 0
}
}
);
}
// (Attempt 2)
// Empty SqueezeBox then reset its contents
$( 'sbox-content' ).empty();
// Unfortunately here there appears no way to reset the size with
// the ajax method,
// and the call to initialize is ignored.
SqueezeBox.initialize(
{
size: { x: 100, y: 400 },
/* Set the loading size to the current size? */
sizeLoading: { x: 700, y: 700 }
}
);
// Load the new content in via ajax
SqueezeBox.setContent( 'ajax', url );
// So, I would need to call resize() here, causing a second animation
我在这里看到了切换到另一个模态灯箱插件的建议,但是离开 SB 并不是一个真正的选择,而且我并不热衷于同时运行这两个插件。