- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我在一个使用 Mootools 的网站上工作,并且在该网站上添加了一个旋转木马,该网站取自此处 - http://developer.yahoo.com/yui/examples/carousel/carousel-ariaplugin_source.html
问题是轮播在某种程度上不能很好地与 Mootools 配合使用。使用 Mootools 时,它不起作用,当我删除 Mootools 时,它开始工作。当启用 Mootools 时,Firebug 也不会在控制台中显示任何 JS 错误或冲突。
我设置了几个 jsfiddle 来演示这个问题。
HTML
<div class="yui-skin-sam">
<h1 id="my-carousel-label">Expert Health Advice</h1>
<div id="container">
<ol id="carousel">
<li class="item"> <a title="View Author's Biography" class="authimg" href="http://health.yahoo.com/experts/skintype/bio/leslie-baumann/"><img width="125" height="154" alt="Leslie Baumann, M.D." src="http://l.yimg.com/fz/ls/he/blogs/carousel/LeslieBaumann_carousel.png"/></a>
<h3><a href="http://health.yahoo.com/experts/skintype/bio/leslie-baumann/">Leslie Baumann, M.D.</a></h3>
<h4><a href="http://health.yahoo.com/experts/skintype/12135/skin-treatments-for-brides-to-be/">Skin Treatments for‰</a></h4>
<cite>Posted Thu 5.1.08</cite>
<p class="all"><a href="http://health.yahoo.com/experts/skintype/">View All Posts »</a>
</p>
</li>
<li class="item"> <a title="View Author's Biography" class="authimg" href="http://health.yahoo.com/experts/deepak/bio/deepak-chopra/"><img width="125" height="154" alt="Deepak Chopra, M.D." src="http://l.yimg.com/fz/ls/he/blogs/carousel/DeepakChopra_carousel.png"/></a>
<h3><a href="http://health.yahoo.com/experts/deepak/bio/deepak-chopra/">Deepak Chopra, M.D.</a></h3>
<h4><a href="http://health.yahoo.com/experts/deepak/2689/how-you-think-about-illness-affects-your-recovery/">How You Think About Illness‰</a></h4>
<cite>Posted Thu 5.1.08</cite>
<p class="all"><a href="http://health.yahoo.com/experts/deepak/">View All Posts »</a>
</p>
</li>
<li class="item"> <a title="View Author's Biography" class="authimg" href="http://health.yahoo.com/experts/nutrition/bio/christine-mckinney-nutrition/"><img width="125" height="154" class="lz" alt="Christine McKinney, M.S., R.D., C.D.E." src="http://l.yimg.com/fz/ls/he/blogs/carousel/ChristineMcKinney_carousel.png"/></a>
<h3><a href="http://health.yahoo.com/experts/nutrition/bio/christine-mckinney-nutrition/">Christine McKinney, M.S., R.D., C.D.E.</a></h3>
<h4><a href="http://health.yahoo.com/experts/nutrition/12067/fat-how-much-is-enough-of-a-good-thing/">Fat: How Much Is Enough of a‰</a></h4>
<cite>Posted Thu 5.1.08</cite>
<p class="all"><a href="http://health.yahoo.com/experts/nutrition/">View All Posts »</a>
</p>
</li>
<li class="item"> <a title="View Author's Biography" class="authimg" href="http://health.yahoo.com/experts/drmao/bio/maoshing-ni/"><img width="125" height="154" class="lz" alt="Dr. Maoshing Ni" src="http://l.yimg.com/fz/ls/he/blogs/carousel/MaoshingNi_carousel.png"/></a>
<h3><a href="http://health.yahoo.com/experts/drmao/bio/maoshing-ni/">Dr. Maoshing Ni</a></h3>
<h4><a href="http://health.yahoo.com/experts/drmao/13738/centenarian-tips-for-a-long-life/">Centenarian Tips for a Long‰</a></h4>
<cite>Posted Tue 4.29.08</cite>
<p class="all"><a href="http://health.yahoo.com/experts/drmao/">View All Posts »</a>
</p>
</li>
<li class="item"> <a title="View Author's Biography" class="authimg" href="http://health.yahoo.com/experts/breastcancer/bio/lillie-shockney/"><img width="125" height="154" class="lz" alt="Lillie Shockney, R.N., M.A.S." src="http://l.yimg.com/fz/ls/he/blogs/carousel/LillieShockney_carousel.png"/></a>
<h3><a href="http://health.yahoo.com/experts/breastcancer/bio/lillie-shockney/">
Lillie Shockney, R.N., M.A.S.</a></h3>
<h4><a href="http://health.yahoo.com/experts/breastcancer/5673/are-you-being-over-or-undertreated/">Are You Being Over- or‰</a></h4>
<cite>Posted Tue 4.29.08</cite>
<p class="all"><a href="http://health.yahoo.com/experts/breastcancer/">View All Posts »</a>
</p>
</li>
<li class="item"> <a title="View Author's Biography" class="authimg" href="http://health.yahoo.com/experts/depression/bio/david-neubauer/"><img width="125" height="154" class="lz" alt="David Neubauer, M.D." src="http://l.yimg.com/fz/ls/he/blogs/carousel/DavidNeubauer_carousel.png"/></a>
<h3><a href="http://health.yahoo.com/experts/depression/bio/david-neubauer/">David Neubauer, M.D.</a></h3>
<h4><a href="http://health.yahoo.com/experts/depression/12445/could-a-breast-cancer-treatment-help-bipolar-disorder/">Could a Breast Cancer‰</a></h4>
<cite>Posted Tue 4.29.08</cite>
<p class="all"><a href="http://health.yahoo.com/experts/depression/">View All Posts »</a>
</p>
</li>
<li class="item"> <a title="View Author's Biography" class="authimg" href="http://health.yahoo.com/experts/capessa/bio/capessa/"><img width="125" height="154" class="lz" alt="Jennifer Tuma-Young" src="http://l.yimg.com/fz/ls/he/blogs/carousel/Capessa_carousel.png"/></a>
<h3><a href="http://health.yahoo.com/experts/capessa/bio/capessa/">Jennifer Tuma-Young</a></h3>
<h4><a href="http://health.yahoo.com/experts/capessa/3473/relieve-stress-with-your-senses/">Relieve Stress With Your‰</a></h4>
<cite>Posted Mon 4.28.08</cite>
<p class="all"><a href="http://health.yahoo.com/experts/capessa/">View All Posts »</a>
</p>
</li>
<li class="item"> <a title="View Author's Biography" class="authimg" href="http://health.yahoo.com/experts/healthieryou/bio/lucydanziger/"><img width="125" height="154" class="lz" alt="Lucy Danziger, SELF Edit" src="http://l.yimg.com/fz/ls/he/blogs/carousel/LucyDanziger_carousel.png"/></a>
<h3><a href="http://health.yahoo.com/experts/healthieryou/bio/lucydanziger/">Lucy Danziger, SELF Edit</a></h3>
<h4><a href="http://health.yahoo.com/experts/healthieryou/2639/de-stress-in-mere-minutes/">De-Stress in Mere Minutes</a></h4>
<cite>Posted Mon 4.28.08</cite>
<p class="all"><a href="http://health.yahoo.com/experts/healthieryou/">View All Posts »</a>
</p>
</li>
<li class="item"> <a title="View Author's Biography" class="authimg" href="http://health.yahoo.com/experts/healthnews/bio/simeon-margolis/"><img width="125" height="154" class="lz" alt="Simeon Margolis, M.D., Ph.D." src="http://l.yimg.com/fz/ls/he/blogs/carousel/SimeonMargolis_carousel.png"/></a>
<h3><a href="http://health.yahoo.com/experts/healthnews/bio/simeon-margolis/">Simeon Margolis, M.D., Ph.D.</a></h3>
<h4><a href="http://health.yahoo.com/experts/healthnews/13879/alzheimer-s-and-dementia-will-you-be-affected/">Alzheimer's and Dementia: Will‰</a></h4>
<cite>Posted Mon 4.28.08</cite>
<p class="all"><a href="http://health.yahoo.com/experts/healthnews/">View All Posts »</a>
</p>
</li>
<li class="item"> <a title="View Author's Biography" class="authimg" href="http://health.yahoo.com/experts/intentblog/bio/intentblog/"><img width="125" height="154" class="lz" alt="Mallika Chopra, IntentBlog" src="http://l.yimg.com/fz/ls/he/blogs/carousel/Intentblog_carousel.png"/></a>
<h3><a href="http://health.yahoo.com/experts/intentblog/bio/intentblog/">Mallika Chopra, IntentBlog</a></h3>
<h4><a href="http://health.yahoo.com/experts/intentblog/2919/treating-a-sore-throat/">Treating a Sore Throat</a></h4>
<cite>Posted Mon 4.28.08</cite>
<p class="all"><a href="http://health.yahoo.com/experts/intentblog/">View All Posts »</a>
</p>
</li>
</ol>
</div>
</div>
Javascript
window.onload=function(){
(function () {
var carousel;
YAHOO.util.Event.onDOMReady(function (ev) {
var carousel = new YAHOO.widget.Carousel("container", {
animation: { speed: 0.5 },
describedby: "my-carousel-label"
});
carousel.render(); // get ready for rendering the widget
carousel.show(); // display the widget
});
})();
}
如有任何帮助,我们将不胜感激。
最佳答案
如上所述,我认为最好的选择是使用基于 Mootools 的 Carousel。
如果那是你想要的方式,我会为此做出贡献:
(使用您的 CSS 文件和布局)
CSS(额外的,除了你的文件):
ol {
list-style: none;
overflow-y: hidden;
overflow-x: visible;
position: relative;
padding:0px;
height:320px;
width:10000px;
}
ol#carousel li.item {
float: left;
width:471px;
}
#container {
height:400px;
width:471px;
}
Mootools
var items = document.getElements('li.item');
var carousel = $('carousel');
/**************************************
Caroussel functions
**************************************/
var li_index = 0;
function gotoSlide(ind) {
li_index = ind;
var pos = items[ind].getPosition().x - carousel.getPosition().x;
li_thumbs.each(function (e, i) {
e.removeClass('yui-carousel-nav-page-selected');
if (ind == i) e.addClass('yui-carousel-nav-page-selected');
});
carousel.morph({
'margin-left': -pos
});
};
/**************************************
Create rest of markup
**************************************/
var container = document.id('container');
container.addClass('yui-carousel-visible yui-carousel-horizontal yui-carousel');
var nav = new Element('div', {
'class': 'yui-carousel-nav'
});
var li = new Element('li');
var ul = new Element('ul');
var span0 = new Element('span', {
'class': 'yui-carousel-button'
});
var span1 = new Element('span', {
'class': 'yui-carousel-button'
});
var btn = new Element('button');
var div_content = new Element('div', {
'class': 'yui-carousel-content'
});
btn.clone().set('id', 'yui-gen10').inject(span0);
span0.addClass('yui-carousel-first-button').inject(nav);
btn.clone().set('id', 'yui-gen11').inject(span1);
span1.addClass('yui-carousel-next-button').inject(nav);
items.each(function (ele, ind) {
li.clone().set('id', 'nav_button_' + ind).addEvent('click', function () {
li_index = ind;
gotoSlide(ind);
}).inject(ul);
});
ul.getElement('li').addClass('yui-carousel-nav-page-selected');
ul.inject(nav);
div_content.inject(container);
nav.inject(container, 'top');
div_content.wraps(carousel);
document.getElements('.yui-carousel-button button').addEvent('click', function () {
var ind = (this.id).split('yui-gen1')[1] == 0 ? li_index - 1 : li_index + 1;
if (ind < 0 || ind > items.length - 1) return false;
gotoSlide(ind);
});
var li_thumbs = $$('.yui-carousel-nav ul li');
关于javascript - Mootools 和 YUI 轮播问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19180550/
我试图在Mootools [1.11版]中匹配多个CSS属性,如以下元素所示: 我想匹配具有type ='radio'和value ='dev'属性的元素。尝试了这个,但这不起作用 $$('inpu
问题:是否有到 mootools 核心及更多库的可靠/永久链接? 我升级了 mootools 幻灯片并使其可用 online如果有人需要的话。但希望有一个谷歌链接 对于 javascript 库,但没
我正在使用 MooTools 1.12 如何在悬停时将类添加到 a 元素? 例如 我有这个 Some text Some text Some text Some text anf 当鼠标悬停在链接上时
我继承了一个网站项目,其中大部分脚本都包含 mootools.js(大约 40k)。但是,凭直觉,我还没有看到它在哪里使用,考虑到这个项目的性质,咳咳,我认为它可能根本没有被使用! 今晚我“迫于压力”
我在 Google map 应用程序中使用 Mootools 来做一些事情,例如 bumpboxes 和其他东西。在我添加 Mootools 脚本之前,一切都 100% 正常工作,无论我是在声明我的全
如何使用 Mootools 通过 id 检查元素的存在 最佳答案 html: some content javascript var foo = document.id('foo'); // or $
我正在尝试将大约 200 行 jQuery 代码转换为 MooTools,以避免在现有站点上包含两个库。我只有一行有问题: new Element('span', {text: ' » '
Please select product ... 我尝试使用 Firefox 并且它工作正常 $('selectId').innertHTML = 'Test test' 但在 ie 上,它不
我有 5 个 a 元素需要注入(inject)额外的 span ,而不是创建新元素 5 次我怎么能只做一次呢?我试过了 var holders= $$('.holders'); holders.eac
我有 5 个 a 元素需要注入(inject)额外的 span ,而不是创建新元素 5 次我怎么能只做一次呢?我试过了 var holders= $$('.holders'); holders.eac
有人有在同一页面中使用 Closure js lib 和 Mootools 的经验吗? 有冲突还是工作正常? 最佳答案 根据谷歌: The names of all Closure Library f
我试图让 SqueezeBox 弹出窗口在打开页面时自动打开,但我使用的代码打开了弹出窗口,但弹出内容未加载。 我不太熟悉,因此我需要一些帮助来了解我做错了什么 window.addEvent('do
我正在学习 mootools。我有一个以下格式的数组。我想在 for 循环中遍历它,但不知道该怎么做。 {'apple' : { 'prize' : 10 , 'color' : 'Red' } ,
要在我的网站上设置元素的 html,我主要使用 $('elementId').innerHTML = "text"; 浏览 mootools 文档,我发现给出了这个例子: $('myElement')
我这里有一个 Mootools 1.1 类,我想将其在 Mootools 1.3 中运行。onComplete 函数不知何故无法将“数据”结果发送到 processResults 函数。 Ajax 调
我有这个 Mootools 1.11 脚本,它在提交表单后更新 div,表单将数据发送到“form.php”文件并返回类似“表单已发送”的消息。 我想把它转换成 mootools 1.4.1 Moot
我正在从服务器检索一些数据并更新 div 的 html 内容,如下所示: var req = new Request.JSON({ method: 'get', url: 'index
我看到了用 jquery 获取第二类名称的方法,但是如何在 mootools 中做到这一点,我的元素是 我需要匹配完整的类名,例如 li.parent.active 并调整高度(如果我尝试过该类存在
我正在使用 MooTools,但我似乎无法执行以下代码。我期望它将 #bar 元素的宽度增加到 50px,然后 alert() 带有“hi!”,并且然后继续将#bar的宽度增加到200px。不管出于什
我有一个当前正在调用 .hide() 的 Element 对象。相反,我想将整个元素(及其子元素)的不透明度淡出到 100%(隐藏),作为可能超过 500 毫秒或 1000 毫秒的过渡效果。 Fx.T
我是一名优秀的程序员,十分优秀!