Précédent   Forum des professionnels en informatique > Webmasters - Développement Web > JavaScript > Bibliothèques & Frameworks > Mootools
Mootools Forum d'entraide sur le framework MooTools. Avant de poster : Tutoriels Mootools, FAQ MooTools, Toutes les FAQ JavaScript
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 01/08/2011, 18h18   #1
Invité de passage
 
Femme
Étudiant
Inscription : août 2011
Messages : 2
Détails du profil
Informations personnelles :
Sexe : Femme
Localisation : France, Aisne (Picardie)

Informations professionnelles :
Activité : Étudiant
Secteur : High Tech - Multimédia et Internet

Informations forums :
Inscription : août 2011
Messages : 2
Points : 0
Points : 0
Par défaut Slider qui n'apparaît pas dans galerie MooFlow

Bonjour!

Je suis débutante en développement web, et encore plus en Javascript. Je veux installer une galerie Mooflow sur un site que je veux mettre en ligne le plus rapidement possible.
J'ai construit ma page et ma galerie s'affiche bien, les images sont présentes en miniature et en plus grand, les commentaires aussi. Par contre, aucune trace du slider... J'arrive à faire défiler mes images au clavier mais pas à la souris... Par contre un clic de souris parvient bien à les agrandir.
J'ai été voir dans mon script MooFlow.js, mais je ne trouve pas mon erreur.
Quelqu'un pourrait m'aider à identifier le problème?

Violà le code dans le head de ma page:
Code html :
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
 <!--  la partie css -->
  <link rel="stylesheet" type="text/css" href="galerieMooFlow/cssMooFlow/MooFlow.css" />
  <link rel="stylesheet" type="text/css" href="galerieMooFlow/cssMooFlow/milkbox.css" />
 
  <!--  la partie js -->
  <script type="text/javascript" src="galerieMooFlow/jsMooFlow/mootools-1.2-core.js"></script>
  <script type="text/javascript" src="galerieMooFlow/jsMooFlow/mootools-1.2-more.js"></script>
  <script type="text/javascript" src="galerieMooFlow/jsMooFlow/MooFlow.js"></script>
  <script type="text/javascript" src="galerieMooFlow/jsMooFlow/milkbox.js"></script>
 
<script type="text/javascript">
var myMooFlowPage = {
    start: function(){
        /* MooFlow instance with the Milkbox Viewer */
        var mf = new MooFlow($('MooFlow'), {
            useSlider: true,
            useCaption: true,
            useMouseWheel: true,
            useKeyInput: true,
            useViewer: true,
            onClickView: function(obj){
                Milkbox.showThisImage(obj.href, obj.title + ' - ' + obj.alt);
            }
        });    
    }        
};
window.addEvent('domready', myMooFlowPage.start);
</script>
Et voilà mon Mooflow.js (désolée, c'est super long )
Code :
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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
/**
 * MooFlow - Image gallery
 *
 * Dependencies: MooTools 1.2
 *
 * @version            0.2.1
 *
 * @license            MIT-style license
 * @author            Tobias Wetzel <info [at] outcut.de>
 * @copyright        Author
 * @docmentation    <a href="http://outcut.de/MooFlow/Docmentation.html" target="_blank">http://outcut.de/MooFlow/Docmentation.html</a>
 */ 
 
var MooFlow = new Class({
 
    Implements: [Events, Options],
 
    options: {
        onStart: $empty,
        onClickView: $empty,
        onAutoPlay: $empty,
        onAutoStop: $empty,
        onRequest: $empty,
        onResized: $empty,
        onEmptyinit: $empty,
        reflection: 0.4,
        heightRatio: 0.5,
        offsetY: 0,
        startIndex: 0,
        interval: 3000,
        factor: 115,
        bgColor: '#fff',
        useCaption: true,
        useResize: true,
        useSlider: true,
        useWindowResize: true,
        useMouseWheel: true,
        useKeyInput: true,
        useViewer: true
    },
 
    initialize: function(element, options){
        this.MooFlow = element;
        this.setOptions(options);
        this.foc = 150;
        this.factor = this.options.factor;
        this.offY = this.options.offsetY;
        this.isFull = false;
        this.isAutoPlay = false;
        this.isLoading = false;
        this.inMotion = false;
 
        this.MooFlow.addClass('mf').setStyles({
            'overflow':'hidden',
            'background-color':this.options.bgColor,
            'position':'relative',
            'height':this.MooFlow.getSize().x*this.options.heightRatio,
            'opacity':0
        });
 
        if(this.options.useWindowResize) window.addEvent('resize', this.update.bind(this, 'init'));
        if(this.options.useMouseWheel || this.options.useSlider) this.MooFlow.addEvent('mousewheel', this.wheelTo.bind(this));
        if(this.options.useKeyInput) document.addEvent('keydown', this.keyTo.bind(this));
 
        this.getElements(this.MooFlow);
    },
 
    clearInit: function(){
        this.fireEvent('emptyinit');
    },
 
    getElements: function(el){
        this.master = {'images':[]};
        var els = el.getChildren();
        if(!els.length) {this.clearInit(); return;}
        $$(els).each(function(el){
            var hash = $H(el.getElement('img').getProperties('src','title','alt','longdesc'));
            if(el.get('tag') == 'a') hash.combine(el.getProperties('href','rel','target'));
            this.master['images'].push(hash.getClean());
            el.dispose();
        }, this);
        this.clearMain();
    },
 
    clearMain: function(){
        if(this.cap){this.cap.fade(0);}
        if(this.nav){
            new Fx.Tween(this.nav, {
                'onComplete': function(){
                    this.MooFlow.empty();
                    this.createAniObj();
                }.bind(this)
            }).start('bottom', -50);
        }
        if(!this.nav && !this.cap){
            this.MooFlow.empty();
            this.createAniObj();
        }
    },
 
    getMooFlowElements: function(key){
        var els = [];
        this.master.images.each(function(el){ 
            els.push(el[key]); 
        });
        return els;
    },
 
    createAniObj: function(){
        this.aniFx = new Fx.Value({
            'transition': Fx.Transitions.Expo.easeOut,
            'link': 'cancel',
            'duration': 750,
            onMotion: this.process.bind(this),
            'onStart': this.flowStart.bind(this),
            'onComplete': this.flowComplete.bind(this)
        });
        this.addLoader();
    },
 
    addLoader: function(){
        this.MooFlow.store('height', this.MooFlow.getSize().y);
        this.loader = new Element('div',{'class':'loader'}).inject(this.MooFlow);
        new Fx.Tween(this.MooFlow, {
            'duration': 800,
            'onComplete': this.preloadImg.bind(this)
        }).start('opacity', 1);
    },
 
    preloadImg: function(){
        this.loadedImages = new Asset.images(this.getMooFlowElements('src'), {
            'onComplete': this.loaded.bind(this),
            'onProgress': this.createMooFlowElement.bind(this)
        });
    },
 
    createMooFlowElement: function(counter, i){
        var obj = this.getCurrent(i);
        var img = this.loadedImages[i];
        obj['width'] = img.width;
        obj['height'] = img.height;
        img.removeProperties('width','height');
 
        obj['div'] = new Element('div').setStyles({
            'position':'absolute',
            'display':'none',
            'height': this.MooFlow.getSize().y
        }).inject(this.MooFlow);
        obj['con'] = new Element('div').inject(obj['div']);
        img.setStyles({'vertical-align':'bottom', 'width':'100%', 'height':'50%'});
        img.addEvents({'click': this.clickTo.bind(this, i), 'dblclick': this.viewCallBack.bind(this, i)});
        img.inject(obj['con']);
 
        new Element('div').reflect({ 'img': img,
            'ref': this.options.reflection,
            'height': obj.height,
            'width': obj.width,
            'color': this.options.bgColor
        }).setStyles({'width':'100%','height':'50%','background-color': this.options.bgColor}).inject(obj['con']);
 
        this.loader.set('text', (counter+1) + ' / ' + this.loadedImages.length);
    },
 
    loaded: function(){
        this.index = this.options.startIndex;
        this.iL = this.master.images.length-1;
        new Fx.Tween(this.loader, {
            'duration': 800,
            'onComplete': this.createUI.bind(this)
        }).start('opacity', 0);
    },
 
    createUI: function(){
        this.loader.dispose();
        if(this.options.useCaption){
            this.cap = new Element('div').addClass('caption').set('opacity',0).inject(this.MooFlow);
        }    
        this.nav = new Element('div').addClass('mfNav').setStyle('bottom','-50px');
        this.autoPlayCon = new Element('div').addClass('autoPlayCon');
        this.sliderCon = new Element('div').addClass('sliderCon');
        this.resizeCon = new Element('div').addClass('resizeCon');        
        if(this.options.useAutoPlay){
            this.autoPlayCon.adopt(
                new Element('a',{'class':'stop','events': {'click':this.stop.bind(this)}}), 
                new Element('a',{'class':'play','events': {'click':this.play.bind(this)}})
           &nbsp;);
        }
        if(this.options.useSlider){
            this.sliPrev = new Element('a',{'class':'sliderNext','events': {'click':this.prev.bind(this)}});
            this.sliNext = new Element('a',{'class':'sliderPrev','events': {'click':this.next.bind(this)}});
            this.knob = new Element('div',{'class':'knob'});
            this.knob.adopt(new Element('div',{'class':'knobleft'}));
            this.knob.adopt(new Element('div',{'class':'knobright'}));            
            this.slider = new Element('div',{'class':'slider'}).adopt(this.knob);
            this.sliderCon.adopt(this.sliPrev,this.slider,this.sliNext);
            this.slider.store('parentWidth', this.sliderCon.getSize().x-this.sliPrev.getSize().x-this.sliNext.getSize().x);
        }
        if(this.options.useResize){
            this.resizeCon.adopt(new Element('a',{'class':'resize','events': {'click':this.setScreen.bind(this)}}));
        }        
        this.MooFlow.adopt(this.nav.adopt(this.autoPlayCon, this.sliderCon, this.resizeCon));    
        this.showUI();
    },
 
    showUI: function(){
        if(this.cap) this.cap.fade(1);
        this.nav.tween('bottom', 20);
        this.fireEvent('start');
        this.update();
    },
 
    update: function(e){
        if(e == 'init') return;
        this.oW = this.MooFlow.getSize().x;
        this.sz = this.oW * 0.5;
        if(this.options.useSlider){    
            this.slider.setStyle('width',this.slider.getParent().getSize().x-this.sliPrev.getSize().x-this.sliNext.getSize().x-1);
            this.knob.setStyle('width',(this.slider.getSize().x/this.iL));
            this.sli = new SliderEx(this.slider, this.knob, {steps: this.iL}).set(this.index);
            this.sli.addEvent('onChange', this.glideTo.bind(this));
        }
        this.glideTo(this.index);
        this.isLoading = false;
    },
 
    setScreen: function(){
        if(this.isFull = !this.isFull){
            this.holder = new Element('div').inject(this.MooFlow,'after');
            this.MooFlow.wraps(new Element('div').inject(document.body));
            this.MooFlow.setStyles({'position':'absolute','z-index':'100','top':'0','left':'0','width':window.getSize().x,'height':window.getSize().y});
            if(this.options.useWindowResize){
                this._initResize = this.initResize.bind(this);
                window.addEvent('resize', this._initResize);
            }
        } else {
            this.MooFlow.wraps(this.holder);
            window.removeEvent('resize', this._initResize);
            delete this.holder, this._initResize;
            this.MooFlow.setStyles({'position':'relative','z-index':'','top':'','left':'','width':'','height':this.MooFlow.retrieve('height')});
            this.slider.setStyle('width',this.slider.retrieve('parentWidth'));
        }
        this.fireEvent('resized', this.isFull);
        this.update();
    },
 
    initResize: function(){
        this.MooFlow.setStyles({'width':window.getSize().x,'height':window.getSize().y});
        this.update();
    },
 
    getCurrent: function(index){
        return this.master.images[$chk(index) ? index : this.index];
    },
 
    loadJSON: function(url){
        if(!url || this.isLoading) return;
        this.isLoading = true;
        new Request.JSON({
            'onComplete': function(data){
                if($chk(data)){
                    this.master = data;
                    this.clearMain();
                    this.fireEvent('request', data);
                }
            }.bind(this)
        }, this).get(url);
    },
 
    loadHTML: function(url, filter){
        if(!url || !filter || this.isLoading) return;
        this.isLoading = true;
        new Request.HTML({
            'onSuccess': function(tree, els, htm){
                var result = new Element('div', {'html': htm}).getChildren(filter);
                this.getElements(result);
                this.fireEvent('request', result);
            }.bind(this)
        }, this).get(url);
    },
 
    flowStart: function(){
        this.inMotion = true;
    },
 
    flowComplete: function(){
        this.inMotion = false;
    },
 
    viewCallBack: function(index){
        if(this.index != index || this.inMotion) return;
        var el = $H(this.getCurrent());
        var returnObj = {};
        returnObj['coords'] = el.div.getElement('img').getCoordinates();
        el.each(function(v, k){
            if($type(v) == 'number' || $type(v) == 'string') returnObj[k] = v;
        }, this);
        this.fireEvent('clickView', returnObj);
    },
    prev: function(){
        if(this.index > 0) this.clickTo(this.index-1);
    },
    next: function(){
        if(this.index < this.iL) this.clickTo(this.index+1);
    },
    stop: function(){
        $clear(this.autoPlay);
        this.isAutoPlay = false;
        this.fireEvent('autoStop');
    },
    play: function(){
        this.autoPlay = this.auto.periodical(this.options.interval, this);
        this.isAutoPlay = true;
        this.fireEvent('autoPlay');
    },
    auto: function(){
        if(this.index < this.iL) this.next();
        else if(this.index == this.iL) this.clickTo(0);
    },
    keyTo: function(e){
        switch (e.code){
            case 37: e.stop(); this.prev();    break;
            case 39: e.stop(); this.next();
        }
    },
    wheelTo: function(e){
        if(e.wheel > 0) this.prev();
        if(e.wheel < 0) this.next();
        e.stop().preventDefault();
    },
    clickTo: function(index){
        if(this.index == index) return;
        //this.aniFx.cancel();
        if(this.sli) this.sli.set(index);
        this.glideTo(index);
    },
    glideTo: function(index){
        this.index = index;
        this.aniFx.start(this.aniFx.get(), index*-this.foc);
        if(this.cap) this.cap.set('html', this.getCurrent().title);
    },
    process: function(x){
        var z,W,H,zI=this.iL,foc=this.foc,f=this.factor,sz=this.sz,oW=this.oW,offY=this.offY,div,elh,elw;
        this.master.images.each(function(el){
            div = el.div.style;
            elw = el.width;
            elh = el.height;
            if(x>-foc*6 && x<foc*6){
                with (Math) {
                    z = sqrt(10000 + x * x) + 100;
                    H = round((elh / elw * f) / z * sz);
                    W = round(elw * H / elh);
                    if(H >= elw * 0.5) {W = round(f / z * sz);}
                    div.left = round(((x / z * sz) + sz) - (f * 0.5) / z * sz) + 'px';
                    div.top = round(oW * 0.4 - H) + offY + 'px';
                }    
                el.con.style.height = H*2 + 'px';        
                div.width = W + 'px';
                div.zIndex = x < 0 ? zI++ : zI--;
                div.display = 'block';
            } else {
                div.display = 'none';
            }
            x += foc;
        });
    }
});
 
var SliderEx = new Class({
    Extends: Slider,
    set: function(step){
        this.step = Math.round(step);
        this.fireEvent('tick', this.toPosition(this.step));
        return this;
    },
    clickedElement: function(event){
        var dir = this.range < 0 ? -1 : 1;
        var position = event.page[this.axis] - this.element.getPosition()[this.axis] - this.half;
        position = position.limit(-this.options.offset, this.full -this.options.offset);
        this.step = Math.round(this.min + dir * this.toStep(position));
        this.checkStep();
        this.fireEvent('tick', position);
    }
});
 
Fx.Value = new Class({
    Extends: Fx,
    compute: function(from, to, delta){
        this.value = Fx.compute(from, to, delta);
        this.fireEvent('motion', this.value);
        return this.value;
    },
    get: function(){
        return this.value || 0;
    }
});
 
Element.implement({
    reflect: function(arg){
        i = arg.img.clone();
        if(Browser.Engine.trident){
            i.style.filter = 'flipv progid:DXImageTransform.Microsoft.Alpha(opacity=20, style=1, finishOpacity=0, startx=0, starty=0, finishx=0, finishy='+100*arg.ref+')';
            i.setStyles({'width':'100%', 'height':'100%'});
            return new Element('div').adopt(i);
        } else {
            var can = new Element('canvas').setProperties({'width':arg.width, 'height':arg.height});
            if(can.getContext){
                var ctx = can.getContext("2d");
                ctx.save();
                ctx.translate(0,arg.height-1);
                ctx.scale(1,-1);
                ctx.drawImage(i, 0, 0, arg.width, arg.height);
                ctx.restore();
                ctx.globalCompositeOperation = "destination-out";
                ctx.fillStyle = arg.color;
                ctx.fillRect(0, arg.height*0.5, arg.width, arg.height);
                var gra = ctx.createLinearGradient(0, 0, 0, arg.height*arg.ref);                    
                gra.addColorStop(1, "rgba(255, 255, 255, 1.0)");
                gra.addColorStop(0, "rgba(255, 255, 255, "+(1-arg.ref)+")");
                ctx.fillStyle = gra;
                ctx.rect(0, 0, arg.width, arg.height);
                ctx.fill();
                delete ctx, gra;
            }
            return can;
        }
    }
});
 
window.addEvent('domready', function(){
    $$('.MooFlowieze').each(function(mooflow){
        new MooFlow(mooflow);
    });
});
Si quelqu'un pouvait m'aider, franchement, ce serait génial...

Merci d'avance à ceux qui voudront bien se pencher sur mon cas (désespéré?)
Dzesse est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 01/08/2011, 18h22   #2
Invité de passage
 
Femme
Étudiant
Inscription : août 2011
Messages : 2
Détails du profil
Informations personnelles :
Sexe : Femme
Localisation : France, Aisne (Picardie)

Informations professionnelles :
Activité : Étudiant
Secteur : High Tech - Multimédia et Internet

Informations forums :
Inscription : août 2011
Messages : 2
Points : 0
Points : 0
La version de Mootools que j'ai utlisée n'est pas la dernière mais la version 1.2. Je n'étais pas certaine que le plugin MooFlow fonctionnerait sur la dernière version de Mootools, étant donné qu'il date un peu, du moins dans la version que j'avais trouvé... Est-ce-que ça pourrait être dû à ça?
Dzesse est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 02/08/2011, 07h50   #3
Responsable JavaScript & AJAX

 
Avatar de vermine
 
Inscription : mars 2008
Messages : 2 686
Détails du profil
Informations personnelles :
Âge : 27

Informations forums :
Inscription : mars 2008
Messages : 2 686
Points : 5 755
Points : 5 755
Bonjour,

Je ne pense pas que la version de Mootools soit en cause mais si vous avez une version 1.x, n'hésitez pas à faire le test.

Pourrais-je avoir le site où vous avez trouvé vos sources Mooflow et Milkbox ? Je vais essayer de reconstruire votre page avec ces différents scripts (vous montrez le mooflow.js mais pas le milkbox ni les deux css).

Vous avez testé sur plusieurs navigateurs ?
__________________
Elen Poukram - Isegoria - Sandawe
vermine est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 03/08/2011, 10h51   #4
Candidat au titre de Membre du Club
 
Inscription : novembre 2005
Messages : 22
Détails du profil
Informations forums :
Inscription : novembre 2005
Messages : 22
Points : 10
Points : 10
bonjour,

Quand vous dites que vous n'arrivez pas à faire défiler les images avec votre souris, c'est avec la molette ou juste en pointant votre souris ?

Si c'est juste en pointant la souris sur l'image, alors c'est normal. Enfin, je ne suis pas un expert. De ce que j'en lis, il n'y a rien de définit pour l'évènement onHover ...

Cordialement,
nuhuruine est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 10h03.


 
 
 
 
Partenaires

Hébergement Web