JS/jQuery 中的缩放幻灯片

发布于 2024-11-27 00:20:10 字数 358 浏览 1 评论 0原文

在当前的项目中,我们希望在起始页上播放幻灯片,稳定地循环浏览图像。到目前为止,一切都很好。

但客户还要求在转换之间缓慢缩放图像。它在 Flash 中可用,并且已经使用了相当长一段时间,示例如下链接:

http: //activeden.net/item/xml-zooming-slideshow/9577

但我想在 JS/jQuery 中实现这个。有谁知道有一个插件可以做到这一点,或者之前写过一个插件可以帮助我们开始了?

感谢所有帮助!

此致 尼克拉斯

On a current project, we want a slideshow on the start page, cycling through the images on a steady pase. So far so good.

But the customer requests a slow zoom on the images between the transitions as well. It's available in Flash and has been used for quite some time, example on the link below:

http://activeden.net/item/xml-zooming-slideshow/9577

But I want this in JS/jQuery.. Does anyone know of a plugin that will do this, or has written one before that could get us started?

All help appreciated!

Best regards
Niclas

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

野生奥特曼 2024-12-04 00:20:10

这就是所谓的“肯·伯恩斯效应”

请参阅:http://tobia.github.com/CrossSlide/

我不建议使用任何此效果的 JavaScript 实现 - 它们在某些浏览器中都会出现令人不愉快的“摆动”。

That's called the "Ken Burns effect".

See: http://tobia.github.com/CrossSlide/

I don't recommend using any JavaScript implementation of this effect - they all appear to "wobble" unpleasantly in certain browsers.

撧情箌佬 2024-12-04 00:20:10

我认为 javascript/jquery 路线是错误的方法。 CSS 是一个更好的方法。我改编了在此页面找到的解决方案: https://www.cssscript.com/pure-css-css3-slideshow-with-image-panning-and-zooming-effect/#:~:text=A%20pure%20HTML%20/%20CSS% 20background%20slideshow

并在我的 React SPA 中使用了它。效果真的很好。
我的 CSS(在您的 tsx 文件中导入 './screensaver.css' //)

figure.screensaver-figure {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    background-size: cover;
    margin:0;
    padding:0;
}

@keyframes slideShow {
    0% {
        opacity: 0;
        transform: scale(1);
        -ms-transform: scale(1);
    }

    5% {
        opacity: 1
    }

    25% {
        opacity: 1;
    }

    30% {
        opacity: 0;
        transform: scale(1.2);
        -ms-transform: scale(1.2);
    }

    100% {
        opacity: 0;
        transform: scale(1);
        -ms-transformm: scale(1);
    }
}

然后在组件内部(根据您的文件类型进行调整):

<div style={{ position: 'absolute', width: '100%', height: '100%', overflow: 'hidden' }}>
                {stores.photoStore.files.map((x, i) => (
                    <figure className='screensaver-figure' style={{
                        animationName: 'slideShow',
                        animationDuration: `${animationDelayEvery * 4}s`,
                        animationTimingFunction: 'linear',
                        animationIterationCount: 'infinite',
                        backgroundImage: `url('${x['@microsoft.graph.downloadUrl']}')`,
                        backgroundRepeat: 'no-repeat',
                        backgroundPositionX: 'center',
                        backgroundPositionY: 'center',
                        backgroundSize: 'cover',
                        animationDelay: `${i * animationDelayEvery}s`
                    }} key={x.id} ></figure>
                ))}
            </div>

I think the javascript/jquery route is the wrong way to go for this. CSS is a better way. I adapted the solution found at this page: https://www.cssscript.com/pure-css-css3-slideshow-with-image-panning-and-zooming-effect/#:~:text=A%20pure%20HTML%20/%20CSS%20background%20slideshow

And used it in my React SPA. It works really well.
My CSS (import './screensaver.css' // in your tsx file)

figure.screensaver-figure {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    background-size: cover;
    margin:0;
    padding:0;
}

@keyframes slideShow {
    0% {
        opacity: 0;
        transform: scale(1);
        -ms-transform: scale(1);
    }

    5% {
        opacity: 1
    }

    25% {
        opacity: 1;
    }

    30% {
        opacity: 0;
        transform: scale(1.2);
        -ms-transform: scale(1.2);
    }

    100% {
        opacity: 0;
        transform: scale(1);
        -ms-transformm: scale(1);
    }
}

Then inside the component (adjust for your kind of files):

<div style={{ position: 'absolute', width: '100%', height: '100%', overflow: 'hidden' }}>
                {stores.photoStore.files.map((x, i) => (
                    <figure className='screensaver-figure' style={{
                        animationName: 'slideShow',
                        animationDuration: `${animationDelayEvery * 4}s`,
                        animationTimingFunction: 'linear',
                        animationIterationCount: 'infinite',
                        backgroundImage: `url('${x['@microsoft.graph.downloadUrl']}')`,
                        backgroundRepeat: 'no-repeat',
                        backgroundPositionX: 'center',
                        backgroundPositionY: 'center',
                        backgroundSize: 'cover',
                        animationDelay: `${i * animationDelayEvery}s`
                    }} key={x.id} ></figure>
                ))}
            </div>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文