如何滑动整个网页?

发布于 2024-12-23 06:15:52 字数 1314 浏览 5 评论 0原文

例如 - http://www.tumblr.com

注销并尝试单击按钮“登录”、“注册”、“您会喜欢 Tumblr 的 30 个理由”(特别有趣)。

如何制作这种幻灯片效果?

PS:我不要求提供工作代码,只是指南和建议。

UP:似乎我找到了可能的解决方案。来自 tumblr js 文件的代码。

return new Effect.Move(element, {
x: initialMoveX,
y: initialMoveY,
duration: 0.01,
beforeSetup: function(effect) {
  effect.element.hide().makeClipping().makePositioned();
},
afterFinishInternal: function(effect) {
  new Effect.Parallel(
    [ new Effect.Opacity(effect.element, { sync: true, to: 1.0, from: 0.0, transition: options.opacityTransition }),
      new Effect.Move(effect.element, { x: moveX, y: moveY, sync: true, transition: options.moveTransition }),
      new Effect.Scale(effect.element, 100, {
        scaleMode: { originalHeight: dims.height, originalWidth: dims.width },
        sync: true, scaleFrom: window.opera ? 1 : 0, transition: options.scaleTransition, restoreAfterFinish: true})
    ], Object.extend({
         beforeSetup: function(effect) {
           effect.effects[0].element.setStyle({height: '0px'}).show();
         },
         afterFinishInternal: function(effect) {
           effect.effects[0].element.undoClipping().undoPositioned().setStyle(oldStyle);
         }
       }, options)
  );
}

For example - http://www.tumblr.com

Log out and try to click buttons "Log In", "Sign up", "30 reasons why you'll love Tumblr" (especially interesting).

How to create this slide effect?

P.S: i'm not asking for provide me working code, just guidelines and advices.

UP: seems like i found the possible solution. Code from tumblr js files.

return new Effect.Move(element, {
x: initialMoveX,
y: initialMoveY,
duration: 0.01,
beforeSetup: function(effect) {
  effect.element.hide().makeClipping().makePositioned();
},
afterFinishInternal: function(effect) {
  new Effect.Parallel(
    [ new Effect.Opacity(effect.element, { sync: true, to: 1.0, from: 0.0, transition: options.opacityTransition }),
      new Effect.Move(effect.element, { x: moveX, y: moveY, sync: true, transition: options.moveTransition }),
      new Effect.Scale(effect.element, 100, {
        scaleMode: { originalHeight: dims.height, originalWidth: dims.width },
        sync: true, scaleFrom: window.opera ? 1 : 0, transition: options.scaleTransition, restoreAfterFinish: true})
    ], Object.extend({
         beforeSetup: function(effect) {
           effect.effects[0].element.setStyle({height: '0px'}).show();
         },
         afterFinishInternal: function(effect) {
           effect.effects[0].element.undoClipping().undoPositioned().setStyle(oldStyle);
         }
       }, options)
  );
}

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

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

发布评论

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

评论(3

呆头 2024-12-30 06:15:52

您可以在这里找到全页幻灯片的工作演示:http://acarna.com/ full-page-slide.php

查看源代码和 CSS,因为这两者都是此工作所必需的。需要注意的主要关键是...

  • 您需要一个容器,其中包含 2 个(或更多)屏幕大小的页面(我的演示中的#wrapper)
  • 此容器需要将其溢出属性设置为隐藏
  • 您必须检测屏幕高度每次运行动画时(如果窗口大小发生变化)

You'll find a working demo of a full-page slide here: http://acarna.com/full-page-slide.php

View the source and the CSS as both are requird for this to work. The main keys to note are...

  • You need a container in which 2 (or more) screen-sized pages are held (#wrapper in my demo)
  • This container needs to have its overflow property set to hidden
  • You must detect the screen height each time you run the animation (in case the window size has changed)
冬天旳寂寞 2024-12-30 06:15:52

您检查过他们在页面中使用的脚本和 CSS 吗?
只要检查一下,您就会得到如何做的线索。

Have you check out the scripts and css they have used in their pages?
just check it out you will get the clue how to do it.

迷离° 2024-12-30 06:15:52

我也在自己的网站上制作了这个效果。我不知道 tumblr 是怎么做到的,但我已经想出了自己的方法(以 tumblr 的效果为例):

步骤 1. 在重定向到新网址之前,将当前页面的底部部分向上滑动
步骤2.当新的url document.ready 时向下滑动顶部部分


几年后更新:

由于我刚刚获得新的投票,我发现了这个旧答案,现在有点过时了。

使用现代 JavaScript,您只需要使用 history.pushstate,所有效果都在一个页面中执行。用js改变页面内容后,可以使用pushstate改变url,这就像是用效果导航一样。

要了解有关 Pushstate 的更多信息,请参阅 https://developer .mozilla.org/en-US/docs/Web/Guide/API/DOM/Manipulated_the_browser_history

I made this effect on my own site too. I don't know how tumblr did that, but I have figured out my own way to do this(for tumblr's effect as an example):

step 1. before redirect to a new url, slide the bottom section up of current page
step 2. slide down the top section when the new url document.ready


Update years later:

Since I just got a new vote-up, I discovered this old answer which is now a little bit outdated.

With modern javascript, you just need to use history.pushstate, all effects are performed in one page. After changing the page content with js, you can use pushstate to change the url, which makes it like navigating with effects.

To read more about pushstate, please refer https://developer.mozilla.org/en-US/docs/Web/Guide/API/DOM/Manipulating_the_browser_history

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文