Bonjour,

J'ai un soucis avec un système de newsticker. Lorsque je clique sur la flèche gauche c'est quand même la news d'après qui s'affiche et non celle d'avant.

En plus il y a un effet blanc qu'il n'y a pas quand on clique sur la flèche de droite. Bref je galère un peu, merci de votre aide smile

Voici mon fichier javascript newsticker.js

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
var Ticker = new Class({
    timer: null,
    initialize: function(el,options){
        this.setOptions(options);
        this.el = $(el);
        this.items = this.el.getElements('li');
        var w = 0;
        var h = 0;
 
        if(this.options.direction.toLowerCase()=='horizontal') {
            h = this.el.getSize().y;
                this.items.each(function(li,index) {
                w += li.getSize().x;
            });
        } else if(this.options.direction.toLowerCase()=='vertical') {
            w = this.el.getSize().x;
            this.items.each(function(li,index) {
                h += li.getSize().y;
            });
        }
        else {
            w = this.el.getSize().x;
            h = this.el.getSize().y;
            this.items.setStyles({
                position: 'absolute',
                top: 0,
                opacity: 0
            });
        }
 
        this.el.setStyles({
            position: 'absolute',
            top: 0,
            left: 0,
            width: w,
            height: h
        });
 
        if (this.options.direction.toLowerCase()=='fade')
        {
            this.fx = new Fx.Tween(this.items[0], {property:'opacity', duration  decu this.options.speed/2), transition: this.options.transition}).set(1);
        }
        else
        {
            this.fx = new Fx.Morph(this.el, {duration:this.options.speed, transition: this.options.transition, onComplete:function() {
                var i = (this.current==0) ? this.items.length : this.current;
                this.items[i-1].injectInside(this.el);
                this.el.setStyles({
                    left:0,
                    top:0
                });
            }.bind(this)});
        }
        this.current = 0;
 
        if (this.options.delay > 0) {
            this.timer = this.next.bind(this).delay(this.options.delay+this.options.speed);
        } else {
            this.next();
        }
    },
 
    pause: function() {
        $clear(this.timer);
        this.timer = null;
    },
    resume: function() {
        if (this.timer == null) {
            this.next();
        }
    },
    next: function() {
        this.current++;
        if (this.current >= this.items.length) this.current = 0;
 
        if (this.options.direction.toLowerCase() == 'fade')
        {
            this.fx.start(1, 0).chain( (function() {
                this.fx = new Fx.Tween(this.items[this.current], {property:'opacity', duration  decu this.options.speed/2), transition: this.options.transition}).start(0, 1).chain((function() {
                    if (this.options.delay == 0)
                        this.next();
                }).bind(this));
            }).bind(this));
        }
        else
        {
            var pos = this.items[this.current];
            this.fx.start({
                top: -pos.offsetTop,
                left: -pos.offsetLeft
            }).chain( (function() {
                // Update css classes
                this.fx.element.getElements('li').each( function(el, i, items)
                {
                    var cls = el.className;
                    cls = cls.replace(/odd|even|first|last/g, '').clean();
 
                    // First element
                    if (i == 0)
                    {
                        cls += ' first';
                    }
 
                    // Last element
                    if (i >= (items.length-1))
                    {
                        cls += ' last';
                    }
 
                    // Odd/even
                    cls += (i%2 == 0) ? ' even' : ' odd';
 
                    // Apply css class
                    el.className = cls.trim();
                });
 
                if (this.options.delay == 0)
                    this.next();
            }).bind(this))
        }
 
        if (this.options.delay > 0) {
            this.timer = this.next.bind(this).delay(this.options.delay+this.options.speed);
        }
    },
    prev: function() {
            this.current++;
        if (this.current >= this.items.length) this.current = 0;
 
        if (this.options.direction.toLowerCase() == 'fade')
        {
            this.fx.start(1, 0).chain( (function() {
                this.fx = new Fx.Tween(this.items[this.current], {property:'opacity', duration  decu this.options.speed/2), transition: this.options.transition}).start(0, 1).chain((function() {
                    if (this.options.delay == 0)
                        this.next();
                }).bind(this));
            }).bind(this));
        }
        else
        {
            var pos = this.items[this.current];
            this.fx.start({
                top: +pos.offsetTop,
                left: +pos.offsetLeft
            }).chain( (function() {
                // Update css classes
                this.fx.element.getElements('li').each( function(el, i, items)
                {
                    var cls = el.className;
                    cls = cls.replace(/odd|even|first|last/g, '').clean();
 
                    // First element
                    if (i == 0)
                    {
                        cls += ' first';
                    }
 
                    // Last element
                    if (i >= (items.length-1))
                    {
                        cls += ' last';
                    }
 
                    // Odd/even
                    cls += (i%2 == 0) ? ' even' : ' odd';
 
                    // Apply css class
                    el.className = cls.trim();
                });
 
                if (this.options.delay == 0)
                    this.next();
            }).bind(this))
        }
 
        if (this.options.delay > 0) {
            this.timer = this.next.bind(this).delay(this.options.delay+this.options.speed);
        }
    }
});
 
Ticker.implement(new Options);
et le code de mon fichier .tpl correspondant

Code php : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<div class="<?php echo $this->class; ?> block"<?php echo $this->cssID; ?><?php if ($this->style): ?> style="<?php echo $this->style; ?>"<?php endif; ?>>
<?php if ($this->headline): ?>
 
<<?php echo $this->hl; ?>><?php echo $this->headline; ?></<?php echo $this->hl; ?>>
<?php endif; ?>
 
<?php if ($this->controls): ?>
 
<div id="controls-events">
 
   <div id="ticker_next_<?php echo $this->strId; ?>" class="ticker_next"><a><img src="css/arrow-right.png" width="22" height="28" alt="" /></a> </div>      
   <div id="ticker_prev_<?php echo $this->strId; ?>" class="ticker_prev"><a><img src="css/arrow-left.png" width="22" height="28" alt="" /></a> </div>   
</div>
 
<?php endif; ?>
<div class="ticker <?php echo $this->direction; ?>" style="height: <?php echo $this->height; ?>px">
   <ul class="ticker" id="ticker_<?php echo $this->strId; ?>" style="width: <?php echo $this->width; ?>px">
 
<?php foreach($this->articles as $article) echo $article; ?>
 
   </ul>
</div>
 
</div>
<?php if (count($this->articles) > 1): ?>
<!-- indexer::stop -->
<script type="text/javascript">
<!--//--><![CDATA[//><!--
window.addEvent('domready', function() {
   var ticker_<?php echo $this->strId; ?> = new Ticker('ticker_<?php echo $this->strId; ?>', {
      speed: <?php echo $this->speed; ?>,
      delay: <?php echo $this->delay; ?>,
      direction: '<?php echo $this->direction; ?>',
      transition: <?php echo $this->transition; ?>
   });
 
<?php if ($this->controls): ?>
    $$('#ticker_prev_<?php echo $this->strId; ?> a').addEvent('click', function() {
      ticker_<?php echo $this->strId; ?>.prev();
   });
    $$('#ticker_next_<?php echo $this->strId; ?> a').addEvent('click', function() {
      ticker_<?php echo $this->strId; ?>.next();
   });
 
<?php endif; ?>
 
 
});
 
//--><!]]>
</script>
<!-- indexer::continue -->
<?php endif; ?>

Et une démo en ligne ici

Merci d'avance !