update SlidePanel + CSS
This commit is contained in:
parent
5ac44923e4
commit
87771969b0
2 changed files with 20 additions and 11 deletions
|
@ -2055,6 +2055,8 @@ Panels
|
|||
}
|
||||
.OxSlidePanel > div {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
}
|
||||
|
||||
.OxSplitPanel {
|
||||
|
|
|
@ -7,13 +7,15 @@ Ox.SlidePanel = function(options, self) {
|
|||
.defaults({
|
||||
animate: 250,
|
||||
elements: [],
|
||||
orientation: 'horizontal',
|
||||
selected: ''
|
||||
})
|
||||
.options(options || {})
|
||||
.update({
|
||||
selected: function() {
|
||||
selectElement(self.options.selected);
|
||||
}
|
||||
},
|
||||
size: updateElements
|
||||
})
|
||||
.addClass('OxSlidePanel');
|
||||
|
||||
|
@ -24,29 +26,34 @@ Ox.SlidePanel = function(options, self) {
|
|||
self.$content = Ox.Element()
|
||||
.css(getContentCSS())
|
||||
.appendTo(that);
|
||||
self.options.elements.forEach(function(element) {
|
||||
element
|
||||
.css({width: self.options.width + 'px'})
|
||||
.appendTo(self.$content);
|
||||
updateElements();
|
||||
self.options.elements.forEach(function(element, index) {
|
||||
element.element.appendTo(self.$content);
|
||||
});
|
||||
|
||||
function getContentCSS() {
|
||||
return {
|
||||
left: -getIndexById(self.options.elements, self.options.selected)
|
||||
* self.options.width + 'px',
|
||||
width: self.options.width + 'px'
|
||||
left: -Ox.getIndexById(self.options.elements, self.options.selected)
|
||||
* self.options.size + 'px',
|
||||
width: self.options.size + 'px'
|
||||
};
|
||||
}
|
||||
|
||||
function getElementCSS(index) {
|
||||
return {
|
||||
left: index * self.options.width + 'px',
|
||||
width: self.options.width + 'px'
|
||||
left: index * self.options.size + 'px',
|
||||
width: self.options.size + 'px'
|
||||
};
|
||||
}
|
||||
|
||||
function selectElement(id) {
|
||||
self.content.animate(getContentCSS(), self.options.animate);
|
||||
self.$content.animate(getContentCSS(), self.options.animate);
|
||||
}
|
||||
|
||||
function updateElements() {
|
||||
self.options.elements.forEach(function(element, index) {
|
||||
element.element.css(getElementCSS(index));
|
||||
});
|
||||
}
|
||||
|
||||
that.replaceElement = function(idOrIndex, element) {
|
||||
|
|
Loading…
Reference in a new issue