Skip to content

Commit

Permalink
Merge pull request #101 from KingHenne/fix/resize-handler
Browse files Browse the repository at this point in the history
fix(lory.js): call reset() *before* dispatching resize event
  • Loading branch information
meandmax committed Nov 27, 2015
2 parents c87b162 + f7a8942 commit 0b62466
Show file tree
Hide file tree
Showing 11 changed files with 238 additions and 313 deletions.
22 changes: 13 additions & 9 deletions demo/js/jquery.lory.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ return /******/ (function(modules) { // webpackBootstrap

'use strict';

var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; /* globals jQuery */

Object.defineProperty(exports, "__esModule", {
value: true
Expand All @@ -100,8 +100,6 @@ return /******/ (function(modules) { // webpackBootstrap

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function _instanceof(left, right) { if (right != null && right[Symbol.hasInstance]) { return right[Symbol.hasInstance](left); } else { return left instanceof right; } } /* globals jQuery */

var slice = Array.prototype.slice;

function lory(slider, opts) {
Expand All @@ -126,7 +124,7 @@ return /******/ (function(modules) { // webpackBootstrap
/**
* if object is jQuery convert to native DOM element
*/
if (typeof jQuery !== 'undefined' && _instanceof(slider, jQuery)) {
if (typeof jQuery !== 'undefined' && slider instanceof jQuery) {
slider = slider[0];
}

Expand Down Expand Up @@ -353,7 +351,7 @@ return /******/ (function(modules) { // webpackBootstrap
slideContainer.addEventListener('click', onClick);
}

window.addEventListener('resize', onResize);
options.window.addEventListener('resize', onResize);

dispatchSliderEvent('after', 'init');
}
Expand Down Expand Up @@ -439,7 +437,7 @@ return /******/ (function(modules) { // webpackBootstrap
slideContainer.removeEventListener('mouseleave', onTouchend);
slideContainer.removeEventListener('click', onClick);

window.removeEventListener('resize', onResize);
options.window.removeEventListener('resize', onResize);

if (prevCtrl) {
prevCtrl.removeEventListener('click', prev);
Expand Down Expand Up @@ -588,11 +586,11 @@ return /******/ (function(modules) { // webpackBootstrap
}

function onResize(event) {
reset();

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

reset();
}

// trigger initial setup
Expand Down Expand Up @@ -851,7 +849,13 @@ return /******/ (function(modules) { // webpackBootstrap
* enables mouse events for swiping on desktop devices
* @enableMouseEvents {boolean}
*/
enableMouseEvents: false
enableMouseEvents: false,

/**
* window instance
* @window {object}
*/
window: window
};

/***/ }
Expand Down
2 changes: 1 addition & 1 deletion demo/js/jquery.lory.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 0b62466

Please sign in to comment.