首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无需双重动画即可重新打开SqueezeBox

无需双重动画即可重新打开SqueezeBox
EN

Stack Overflow用户
提问于 2013-01-30 03:17:18
回答 1查看 556关注 0票数 1

我有一个打开的SqueezeBox在屏幕上,并想重新打开它与不同的网址,以回应点击框内的链接。我正在尝试各种方法来以新的(不同的)大小打开新的URL,这样动画就会很流畅并且只运行一次。不幸的是,标准方法( open方法)似乎会执行两次动画(或者运行“故障”的毫无意义的动画)。

作为另一种选择,我尝试使用setContent,但这似乎没有提供一种设置选项的方法,而且据我所知,一旦设置了选项,SqueezeBox.initialize就不会做任何事情。

代码语言:javascript
复制
    // (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

see here建议切换到另一个模式的lightbox插件,但离开SB并不是一个真正的选择,我也不想同时运行这两个插件。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-01-30 19:11:10

啊哈,这里有一个解决方案--避免SqueezeBox调用!相反,我使用标准的MooTools AJAX调用手动加载内容。这不会打开通常的等待微调,但我希望它可以被修复。

代码语言:javascript
复制
// Let's load page in AJAX manually; reopening with open() or
// setContents() appears to cause double or glitchy animations.
var myRequest = new Request.HTML(
    {
        url: url,
        method: 'get',
        evalScripts: true,
        update: $( 'sbox-content' )
    }
).send();

// @todo If no size change is needed don't run this
// to avoid glitchy animation
SqueezeBox.resize(
    { x: 500, y: 500 },
    false
);

请注意,我使用的是evalScripts: true,因此可加载代码段中的任何JavaScript都可以像使用SqueezeBox.open()一样运行。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/14590522

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档