Impress.js 和使用 HTML5 数据属性代替 CSS 转换
我一直在使用 Impress.js 制作演示文稿,并正在考虑对其进行调整在 iPad 上使用。但我担心 Impress 如何将变换应用于每张幻灯片。不只是使用 CSS,而是将转换作为数据属性放入 HTML 中,然后使用 Javascript 进行应用。
我觉得这是一种过于复杂和困难的做事方式。不过,我在处理数据属性方面没有太多经验,所以我想就此获得一些意见。正常编写 CSS 会更好,还是使用数据属性的好处大于麻烦?
I've been working on a presentation using Impress.js, and was thinking of adapting it for use on iPads. But I'm concerned about how Impress applies transforms to each slide. Instead of just using CSS, transforms are put in the HTML as data attributes, then applied with Javascript.
This strikes me as an overly complicated and difficult way of doing things. I don't have a lot of experience working with data attributes, though, so I wanted to get some opinions on this. Would it be better to just write CSS normally, or do the benefits of using data attributes outweigh the hassle?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
原因很简单:如果您设置了 CSS 转换(通过 javascript 或 CSS),当您尝试获取它时,它会返回一个矩阵转换。假设你做了一些简单的事情,例如...
transform
不会是translate3d(10px,0,0)
,它将是matrix3d(10px,0, 0,[...])
。要获取这些值,您需要解析矩阵,例如...这与 data-attr 的代码相同:
您可以在此处使用 3D CSS 矩阵:
http://jsfiddle.net/F8xLv/
The reason is simple: if you set a CSS transformation—either through javascript or CSS—when you try to get it it returns a matrix transformation. So say you do something simple like...
transform
won't betranslate3d(10px,0,0)
, it will bematrix3d(10px,0,0,[...])
. To get these values you'd need to parse the matrix such as...This is the same code with data-attr:
You can play around with the 3D CSS Matrix here:
http://jsfiddle.net/F8xLv/