scribd如何实现缩放?
Scribd 的缩放功能非常令人印象深刻。当您单击 + 和 - 按钮时,所有页面内容(包括图像和文本)都会按比例缩放。
例如,请在 http://www.scribd.com/html5 上尝试。
他们是如何做到这一点的?它似乎不像控制浏览器缩放那么简单(尽管控制浏览器缩放本身并不简单,如果根本不可能!)
一个相关的问题是他们如何实现“全屏模式”。这个问题之前被问过,但那是两年前的事了,当时他们仍在使用Flash。
Scribd's zooming functionality is very impressive. All the page content including images and text are zoomed proportionally when you click on their + and - buttons.
For example, try it on http://www.scribd.com/html5.
How do they do this? It doesn't seem to be as simple as controlling the browser zoom (although controlling browser zoom itself is not simple if not possible at all!)
A related question would be how they implement their 'full screen mode'. This question was asked before but that was two years ago when they were still using Flash.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我建议这可能是 canvas 元素,但查看其来源,情况似乎并非如此。
相反,它看起来像“放大”功能只影响页面上的
img
标签,所以我想说它们可能只是动态修改width
和 <这些标签的 code>height 属性。这不是一种非常复杂的方法,并且当然不依赖于 HTML5 中引入的任何内容。编辑:
Chrome 的开发者工具非常棒。如果您观察缩放之间的 DOM,就很容易查明效果是如何实现的。这是页面默认状态下标记的样子:
...以及缩小一次之后:
...以及再次缩小之后:
因此看来他们通过做两件事来实现缩放效果:
容器 div 的宽度
和高度
。I'd suggest that it might be a simple transformation of a canvas element, but looking at their source this does not appear to be the case.
Instead, it looks like the "Zoom In" function only affects the
img
tags on the page, so I'd say that probably they are just dynamically modifying thewidth
andheight
attributes for those tags. It's not a very sophisticated approach, and certainly doesn't rely on anything introduced in HTML5.Edit:
Chrome's developer tools are excellent. If you observe the DOM between zooms, it's easy to pinpoint how the effect is being implemented. Here's what the markup looks like in the page's default state:
...and after zooming out once:
...and after zooming out again:
So it appears that they have implemented their zoom effect by doing two things:
width
andheight
of the container div.