0

我对 mootools 不太熟悉,但我正在实现一个图像滑块,我想在其上添加一些标题。到目前为止,这是可行的,但是当图像滑开时,标题仍然存在……如果下一张图片与新标题一起滑动,则标题会滑过前一张……这是隐藏图像的代码段,并且我想我也可以在哪里隐藏字幕......

initialize: function(menu, images, loader, options){
this.parent(menu, options);
this.images = $(images);
this.imagesitems = this.images.getChildren().fade('hide');
$(loader).fade('in');
new Asset.images(this.images.getElements('img').map(function(el) { return el.setStyle('display', 'none').get('src'); }), { onComplete: function() {
  this.loaded = true;      
  $(loader).fade('out');
  if (this.current) this.show(this.items.indexOf(this.current));
  else if (this.options.auto && this.options.autostart) this.progress();
}.bind(this) });
if ($type(this.options.transition) != 'function') this.options.transition = $lambda(this.options.transition);
},

//And here is the HTML (and PHP-Codeigniter):

<li class="relative">
<p class="slogan"><span class="highlight"><?=$latestItem->slogan?><br/><a href="#">Lees meer &raquo;</a></span></p>
<img src="<?= $latestItem->picture ?>" alt="<?=$latestItem->title ?>" title="<?=$latestItem->title ?>" />
</li>

谁能帮我弄清楚如何让字幕与相应的图像一起消失?

4

1 回答 1

0
var foo = new Class({
    initialize: function(menu, images, loader, options) {
        this.parent(menu, options);
        this.images = $(images);
        this.imagesitems = this.images.getChildren().fade('hide');
        $(loader).fade('in');
        new Asset.images(this.images.getElements('img').map(function(el) {
            el.getPevious().setStyle("display", "none");
            return el.setStyle('display', 'none').get('src');
        }), {
            onComplete: function() {
                this.loaded = true;
                $(loader).fade('out');
                if (this.current) this.show(this.items.indexOf(this.current));
                else if (this.options.auto && this.options.autostart) this.progress();
            }.bind(this)
        });
        if ($type(this.options.transition) != 'function') this.options.transition = $lambda(this.options.transition);
    }
});

在您的标记中,标题是<p>紧接在图像之前的标签,因此el.getPrevious()在您的回调中将引用该标签-做最坏的事情:)

ps尝试更好地格式化您的问题

于 2011-05-03T12:07:49.843 回答