IE 中 jQuery fadeTo 错误的变体
受到我昨天读到的一篇文章的启发,我正在努力将 Konami 代码引发的复活节彩蛋添加到 我的投资组合网站。一开始有点有趣,但是当 IE 介入时,一个看似简单的任务就变得很痛苦!
使用优秀的 jqPuzzle 插件,其想法是,在用户输入代码时页面内容淡出并被以前不可见的交互式滑块拼图所取代。我正在使用的插件通过类值将自身应用于页面上的图像。这就是它开始变得棘手的地方:(大概)因为插件需要一些时间来加载,并且因为插件仅在图像可见时加载,所以我将以下 jQuery 放在一起以首先隐藏图像,fade它在不知不觉中给了插件一个机会加载,然后再次淡出图像:
<div id="eegg">
<img src="images/photo_name.jpg" />
</div>
...
<script type="text/javascript">
$( init );
function init() {
$('#eegg img').addClass( 'jqPuzzle jqp-r3-c4-NC' ); //Puzzle settings
$('#eegg').hide().fadeTo( 'slow', 0.000001 ).fadeOut( 'slow' );
$('#eegg img').addClass( 'positioned' ); //Centres puzzle in browser
}
唉,虽然这个小解决方法在 Firefox 和 Chrome 中很好地达到了目的,但 IE 7 和 8 忽略了淡入淡出的说明,只是简单地删除了图像完全不透明,稍后将其删除。真气人!
谁能指导我如何哄 IE 消除这个谜题?
或者,是否有更好的方法来强制滑块 JS“隐形”加载?
Inspired by an article which I read yesterday, I am striving to add a Konami code-induced Easter egg to my portfolio website. It started out as a bit of fun but, as can be the case when IE gets involved, a seemingly quite simple task has become something of a misery!
Using the excellent jqPuzzle plugin, the idea is that upon the user entering the code the page content fades out and is replaced by a previously invisible interactive slider puzzle. The plugin which I'm using applies itself to an image on the page via a class value. Here's where it starts to get tricky: (presumably) because it takes a moment for the plugin to load, and because the plugin only loads when the image is visible, I've put together the following jQuery to hide the image at first, fade it in imperceptibly to give the plugin a chance to load, and then fade the image out again:
<div id="eegg">
<img src="images/photo_name.jpg" />
</div>
...
<script type="text/javascript">
$( init );
function init() {
$('#eegg img').addClass( 'jqPuzzle jqp-r3-c4-NC' ); //Puzzle settings
$('#eegg').hide().fadeTo( 'slow', 0.000001 ).fadeOut( 'slow' );
$('#eegg img').addClass( 'positioned' ); //Centres puzzle in browser
}
Alas, whilst this little workaround serves its purpose very nicely in Firefox and Chrome, IE 7 and 8 ignore the instructions to fade and simply drops the image in at full opacity, before removing it a moment later. Infuriating!
Can anyone offer me any guidance as to how to coax IE into fading the puzzle?
Alternatively, is there a better way to force the slider JS to load 'invisibly'?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您所需要做的就是添加此选项以立即随机播放:
shuffle: true
All you need to is add this option to shuffle it immediately:
shuffle: true
你是一个失败者,设置类名,并等待插件接受它。你最好只使用 jQuery 语法来解决这个难题:
如果你不需要用它来做淡入淡出,我不会感到惊讶。
You're on a loser, setting the classname, and waiting for the plugin to pick up on it. You'd do better just to use the jQuery syntax for the puzzle:
It wouldn't surprise me if you didn't need to do the fading with this.