j'ai fait une petite classe mootools que je viens partager ici. Elle permet simplement de faire coulisser un conteneur dans un autre avec 2 boutons.
Voici le code de la classe
Extrait HTML
Extrait CSS :
Voilà, si ça peut servir
Voici le code de la classe
Code PHP:
var stylesSliderCK = new Class({
options: {
innerBlocksClass: 'stylescontrolcontinnerfloat',
leftButtonClass: 'slideLeftButton',
rightButtonClass: 'slideRightButton'
},
initialize: function(el, options) {
var el = document.id(el); if (!el) return;
this.setOptions(options);
this.leftButton = el.getParent().getElement('.'+this.options.leftButtonClass); if (!this.leftButton) return;
this.rightButton = el.getParent().getElement('.'+this.options.rightButtonClass); if (!this.rightButton) return;
this.innerBlocks = el.getElements('.'+this.options.innerBlocksClass); if (!this.innerBlocks) return;
el.setProperty('width',250*this.innerBlocks.length);
this.rightButton.addEvent('click', function(event) {
event = new Event(event).stop();
if (-el.getProperty('width') < el.getProperty('margin-left')-750) {
el.tween('margin-left', el.getProperty('margin-left')-250);
el.setProperty('margin-left',el.getProperty('margin-left')-250);
}
});
this.leftButton.addEvent('click', function(event) {
event = new Event(event).stop();
if (el.getProperty('margin-left') < 0) {
el.tween('margin-left', parseInt(el.getProperty('margin-left'))+250);
el.setProperty('margin-left',parseInt(el.getProperty('margin-left'))+250);
}
});
}
});
stylesSliderCK.implement(new Options);
new stylesSliderCK('scrolltest');
Code HTML:
<div id="css3controlgeneralcont"> <div class="slideLeftButton">Click to slide left</div> <div class="slideRightButton">Click to slide right</div> <div class="stylescontrolcontinner" id="scrolltest"> <div class="stylescontrolcontinnerfloat">
Code:
#css3controlgeneralcont { height: 330px; width: 770px; overflow: hidden; float: left; margin : 10px; position: absolute; border: 1px solid #fff; -moz-box-shadow: 0 0 5px #888; -webkit-box-shadow: 0 0 5px#888; box-shadow: 0 0 5px #888; } .stylescontrolcontinner { height: 330px; } .stylescontrolcontinnerfloat { float: left; width: 250px; height: 330px; }
Commentaire