11540 sujets

JavaScript, DOM et API Web HTML5

Bonjour,

Je suis webdesigner, et je suis entrain de refaire mon site perso sur la base d'un slider plein ecran en parallax.
J'ai acheté le truc chez code canyon et j'essaie de bidouiller le javascript.

Mon problème : j'aimerai que l'on puisse naviguer avec les touches "fleche haut et fleche bas" du clavier. Cependant le javascript est configuré différement avec "les fleches droite et gauche".

La navigation clavier s'ajoute simplement en mettant un " keybNav : true," dans une fonction javascript.

Je pense que la modif est à faire là

			if( ls.o.keybNav && $(el).find('.ls-layer').length > 1 ){
				
				$('body').bind('keydown',function(e){ 
					if( !ls.g.isAnimating ){
						if( e.which == 37 ){
							ls.o.cbPrev();							
							ls.prev('clicked');
						}else if( e.which == 39 ){
							ls.o.cbNext();							
							ls.next('clicked');
						}
					}
				});


ou là
			// Animating sublayers of current layer

			ls.g.curLayer.find(' > *[class*="ls-s"]').each(function(){

				var curSubSlideDir = $(this).data('slidedirection') ? $(this).data('slidedirection') : slideDirection;
				var lml, lmt;

				switch(curSubSlideDir){
					case 'left':
						lml = -ls.g.sliderWidth();
						lmt = 0;
						break;
					case 'right':
						lml = ls.g.sliderWidth();
						lmt = 0;
						break;
					case 'top':
						lmt = -ls.g.sliderHeight();
						lml = 0;
						break;
					case 'bottom':
						lmt = ls.g.sliderHeight();
						lml = 0;
						break;
				}

				// NEW FEATURE v1.6 added slideoutdirection to sublayers

				var curSubSlideOutDir = $(this).data('slideoutdirection') ? $(this).data('slideoutdirection') : false;

				switch(curSubSlideOutDir){
					case 'left':
						lml = ls.g.sliderWidth();
						lmt = 0;
						break;
					case 'right':
						lml = -ls.g.sliderWidth();
						lmt = 0;
						break;
					case 'top':
						lmt = ls.g.sliderHeight();
						lml = 0;
						break;
					case 'bottom':
						lmt = -ls.g.sliderHeight();
						lml = 0;
						break;
				}
ou plutot là
				// Control functions: prev, next, start, stop & change

					var lsData = $(this).data('LayerSlider');
					if( lsData ){
						if( !lsData.g.isAnimating ){
							if( typeof(options) == 'number' ){
								if( options > 0 && options < lsData.g.layersNum + 1 && options != lsData.g.curLayerIndex ){
									lsData.change(options);
								}						
							}else{
								switch(options){
									case 'prev':
										lsData.o.cbPrev();
										lsData.prev('clicked');
										break;
									case 'next':
										lsData.o.cbNext();
										lsData.next('clicked');
										break;
									case 'start':
										if( !lsData.g.autoSlideshow ){
											lsData.o.cbStart();
											lsData.g.originalAutoSlideshow = true;
											lsData.start();
										}							
										break;
								}
							}
						}
						if( ( lsData.g.autoSlideshow || ( !lsData.g.autoSlideshow && lsData.g.originalAutoSlideshow ) ) && options == 'stop' ){
							lsData.o.cbStop();
							lsData.g.originalAutoSlideshow = false;
							lsData.g.curLayer.find('iframe[src*="www.youtu"], iframe[src*="player.vimeo"]').each(function(){
								
								// Clearing videoTimeouts

								clearTimeout( $(this).data( 'videoTimer') );
							});
							
							lsData.stop();
						}
					}
				});	


non j'ai essayé de bidoullier en deplacant des left pat top mais ça ne marche pas Smiley ohwell /

Help piz
J'ai trouvé!!!!
en fait fallait juste remplacé le numero des case...
if( ls.o.keybNav && $(el).find('.ls-layer').length > 1 ){
				
				$('body').bind('keydown',function(e){ 
					if( !ls.g.isAnimating ){
						if( e.which == 38 ){
							ls.o.cbPrev();							
							ls.prev('clicked');
						}else if( e.which == 40 ){
							ls.o.cbNext();							
							ls.next('clicked');
						}
					}
				});


la case 37 modifié en 38 et la 39 en 40. Smiley biggrin Cool Raoul