Skip to content

Commit

Permalink
Merge pull request #735 from meandmax/benmerckx-master
Browse files Browse the repository at this point in the history
Add trigger commit to fix from @benmerckx
  • Loading branch information
meandmax authored Jun 4, 2018
2 parents ced88f1 + 37da719 commit d7c0b2e
Show file tree
Hide file tree
Showing 8 changed files with 94 additions and 100 deletions.
23 changes: 16 additions & 7 deletions dist/jquery.lory.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,13 @@ function lory(slider, opts) {
}
}

/**
* returns an element's width
*/
function elementWidth(element) {
return element.getBoundingClientRect().width || element.offsetWidth;
}

/**
* slidefunction called by prev, next & touchend
*
Expand Down Expand Up @@ -448,12 +455,12 @@ function lory(slider, opts) {
initialIndex = _options5.initialIndex;


slidesWidth = slideContainer.getBoundingClientRect().width || slideContainer.offsetWidth;
frameWidth = frame.getBoundingClientRect().width || frame.offsetWidth;
slidesWidth = elementWidth(slideContainer);
frameWidth = elementWidth(frame);

if (frameWidth === slidesWidth) {
slidesWidth = slides.reduce(function (previousValue, slide) {
return previousValue + slide.getBoundingClientRect().width || slide.offsetWidth;
return previousValue + elementWidth(slide);
}, 0);
}

Expand Down Expand Up @@ -687,11 +694,13 @@ function lory(slider, opts) {
}

function onResize(event) {
reset();
if (frameWidth !== elementWidth(frame)) {
reset();

dispatchSliderEvent('on', 'resize', {
event: event
});
dispatchSliderEvent('on', 'resize', {
event: event
});
}
}

// trigger initial setup
Expand Down
2 changes: 1 addition & 1 deletion dist/jquery.lory.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/jquery.lory.min.js.map

Large diffs are not rendered by default.

23 changes: 16 additions & 7 deletions dist/lory.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,13 @@ function lory(slider, opts) {
}
}

/**
* returns an element's width
*/
function elementWidth(element) {
return element.getBoundingClientRect().width || element.offsetWidth;
}

/**
* slidefunction called by prev, next & touchend
*
Expand Down Expand Up @@ -448,12 +455,12 @@ function lory(slider, opts) {
initialIndex = _options5.initialIndex;


slidesWidth = slideContainer.getBoundingClientRect().width || slideContainer.offsetWidth;
frameWidth = frame.getBoundingClientRect().width || frame.offsetWidth;
slidesWidth = elementWidth(slideContainer);
frameWidth = elementWidth(frame);

if (frameWidth === slidesWidth) {
slidesWidth = slides.reduce(function (previousValue, slide) {
return previousValue + slide.getBoundingClientRect().width || slide.offsetWidth;
return previousValue + elementWidth(slide);
}, 0);
}

Expand Down Expand Up @@ -687,11 +694,13 @@ function lory(slider, opts) {
}

function onResize(event) {
reset();
if (frameWidth !== elementWidth(frame)) {
reset();

dispatchSliderEvent('on', 'resize', {
event: event
});
dispatchSliderEvent('on', 'resize', {
event: event
});
}
}

// trigger initial setup
Expand Down
2 changes: 1 addition & 1 deletion dist/lory.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/lory.min.js.map

Large diffs are not rendered by default.

25 changes: 16 additions & 9 deletions src/lory.js
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,13 @@ export function lory (slider, opts) {
}
}

/**
* returns an element's width
*/
function elementWidth (element) {
return element.getBoundingClientRect().width || element.offsetWidth;
}

/**
* slidefunction called by prev, next & touchend
*
Expand Down Expand Up @@ -311,14 +318,12 @@ export function lory (slider, opts) {
function reset () {
var {infinite, ease, rewindSpeed, rewindOnResize, classNameActiveSlide, initialIndex} = options;

slidesWidth = slideContainer.getBoundingClientRect()
.width || slideContainer.offsetWidth;
frameWidth = frame.getBoundingClientRect()
.width || frame.offsetWidth;
slidesWidth = elementWidth(slideContainer);
frameWidth = elementWidth(frame);

if (frameWidth === slidesWidth) {
slidesWidth = slides.reduce(function (previousValue, slide) {
return previousValue + slide.getBoundingClientRect().width || slide.offsetWidth;
return previousValue + elementWidth(slide);
}, 0);
}

Expand Down Expand Up @@ -549,11 +554,13 @@ export function lory (slider, opts) {
}

function onResize (event) {
reset();
if (frameWidth !== elementWidth(frame)) {
reset();

dispatchSliderEvent('on', 'resize', {
event
});
dispatchSliderEvent('on', 'resize', {
event
});
}
}

// trigger initial setup
Expand Down
Loading

0 comments on commit d7c0b2e

Please sign in to comment.