Skip to content

Commit

Permalink
Updated jQuery plugin to version 1.3.3
Browse files Browse the repository at this point in the history
  • Loading branch information
ausi committed Apr 2, 2014
1 parent 6f029d5 commit 59243a0
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 4 deletions.
50 changes: 48 additions & 2 deletions assets/js/rocksolid-slider.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! rocksolid-slider v1.3.2 */
/*! rocksolid-slider v1.3.3 */
(function($, window, document) {

var Rst = {};
Expand Down Expand Up @@ -405,6 +405,14 @@ Rst.Slide = (function() {
*/
Slide.prototype.setState = function(state) {

// Ensure the preactive state gets applied before the active state
// to trigger animation styles
if (state === 'active' && state !== this.state && this.state !== 'preactive') {
this.setState('preactive');
// Get a css value to ensure the engine applies the styles
this.element.css('opacity');
}

if (
this.type === 'video' &&
this.state &&
Expand Down Expand Up @@ -698,12 +706,20 @@ Rst.Slider = (function() {
.addClass(this.options.cssPrefix + 'type-' + this.options.type)
.addClass(this.options.cssPrefix + 'skin-' + this.options.skin);

if (this.options.direction === 'x' && (
if (this.options.direction === 'x' && this.options.height === 'normalize') {
this.normalizeSize = true;
this.options.height = 'auto';
}
else if (this.options.direction === 'x' && (
this.options.height === 'auto' ||
(this.options.height === 'css' && this.elements.main.height() < 1)
)) {
this.autoSize = true;
}
else if (this.options.direction === 'y' && this.options.width === 'normalize') {
this.normalizeSize = true;
this.options.width = 'auto';
}
else if (this.options.direction === 'y' && (
this.options.width === 'auto' ||
(this.options.width === 'css' && this.elements.main.width() < 1)
Expand Down Expand Up @@ -885,6 +901,7 @@ Rst.Slider = (function() {
// - a css length value: e.g. "100%", "500px", "50em"
// - "auto": get the size from the active slide dimensions at runtime
// height can be set to auto only if the direction is "x"
// - "normalize": similar to auto but uses the size of the largest slide
// - a proportion: keep a fixed proportion for the slides, e.g. "480x270"
// this must not set to both dimensions
width: 'css',
Expand Down Expand Up @@ -1820,6 +1837,12 @@ Rst.Slider = (function() {

this.viewSizeFixedCache = {x: x, y: y};

if (this.normalizeSize && this.normalizedSize) {
this.viewSizeFixedCache[
this.options.direction === 'x' ? 'y' : 'x'
] = this.normalizedSize;
}

var gapSize = this.getGapSize();
var visibleCount = this.getVisibleSlidesCount();
this.slideSize = Math.round(
Expand Down Expand Up @@ -1928,6 +1951,29 @@ Rst.Slider = (function() {
}

var size = this.getViewSize(this.slideIndex);

// Calculate the normalized size of all slides
if (this.normalizeSize) {
this.normalizedSize = 0;
$.each(this.slides, function(i, slide) {
var wasInjected = true;
if (!slide.isInjected()) {
wasInjected = false;
self.elements.slides.append(slide.element);
}
self.normalizedSize = Math.max(self.normalizedSize, slide.size(
self.options.direction === 'x' ? self.slideSize : null,
self.options.direction === 'y' ? self.slideSize : null,
true
)[self.options.direction === 'x' ? 'y' : 'x']);
if (!wasInjected) {
slide.element.detach();
}
});
// Reset the size
size = this.getViewSize(this.slideIndex);
}

this.modify(this.elements.crop, {
width: size.x,
height: size.y
Expand Down
Loading

0 comments on commit 59243a0

Please sign in to comment.