lory-rails 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +13 -2
- data/VERSIONS.md +1 -0
- data/lib/lory/rails/version.rb +1 -1
- data/vendor/assets/javascripts/jquery.lory.js +1028 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 423102b3a8fec9793a9b5071ff60e76eece628f9
|
4
|
+
data.tar.gz: a9105edc9d1b59cc05d43074bf6aa00639e9aecf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bd368c60d553022a131ffe2b1d4b0232ba7333e1b8a2d109c5da71e0175d83d5c95fb7283217746088200835e91bdc8e25b4787ecff85f9126a765deaab94eb3
|
7
|
+
data.tar.gz: 56cf6defc2aa1f93dda983c29847eb0b34c87d5b5718284d17a45198db71b91d49c778e3ea2a91cb44fa014bb2b805d403b76959cf125cd1eb041e6f8898b959
|
data/README.md
CHANGED
@@ -4,9 +4,9 @@
|
|
4
4
|
[![GitHub last commit (branch)](https://img.shields.io/github/last-commit/tanvir002700/lory-rails/master.svg)](https://github.com/tanvir002700/lory-rails)
|
5
5
|
[![license](https://img.shields.io/github/license/tanvir002700/lory-rails.svg)](https://github.com/tanvir002700/lory-rails/blob/master/LICENSE)
|
6
6
|
|
7
|
-
|
7
|
+
This gem packages the Jquery lory plugin. So you never have to download a custom package through the web interface again.
|
8
8
|
|
9
|
-
|
9
|
+
See VERSIONS.md to see which versions of lory-rails bundle which versions of lory.
|
10
10
|
|
11
11
|
## Installation
|
12
12
|
|
@@ -35,6 +35,17 @@ And then edit your app/assets/stylesheets/application.js file to look something
|
|
35
35
|
*/
|
36
36
|
```
|
37
37
|
|
38
|
+
Integration as a jQuery Plugin add jquery.lory
|
39
|
+
``` css
|
40
|
+
/*
|
41
|
+
*= require_self
|
42
|
+
*= require jqeury
|
43
|
+
*= require jquery-ui
|
44
|
+
*= require jquery.lory
|
45
|
+
*= require_tree .
|
46
|
+
*/
|
47
|
+
```
|
48
|
+
|
38
49
|
**lory-rails is dependant on jQuery, so make sure you have it in your Gemfile.**
|
39
50
|
|
40
51
|
## Usage
|
data/VERSIONS.md
CHANGED
data/lib/lory/rails/version.rb
CHANGED
@@ -0,0 +1,1028 @@
|
|
1
|
+
(function webpackUniversalModuleDefinition(root, factory) {
|
2
|
+
if(typeof exports === 'object' && typeof module === 'object')
|
3
|
+
module.exports = factory();
|
4
|
+
else if(typeof define === 'function' && define.amd)
|
5
|
+
define([], factory);
|
6
|
+
else {
|
7
|
+
var a = factory();
|
8
|
+
for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];
|
9
|
+
}
|
10
|
+
})(typeof self !== 'undefined' ? self : this, function() {
|
11
|
+
return /******/ (function(modules) { // webpackBootstrap
|
12
|
+
/******/ // The module cache
|
13
|
+
/******/ var installedModules = {};
|
14
|
+
/******/
|
15
|
+
/******/ // The require function
|
16
|
+
/******/ function __webpack_require__(moduleId) {
|
17
|
+
/******/
|
18
|
+
/******/ // Check if module is in cache
|
19
|
+
/******/ if(installedModules[moduleId]) {
|
20
|
+
/******/ return installedModules[moduleId].exports;
|
21
|
+
/******/ }
|
22
|
+
/******/ // Create a new module (and put it into the cache)
|
23
|
+
/******/ var module = installedModules[moduleId] = {
|
24
|
+
/******/ i: moduleId,
|
25
|
+
/******/ l: false,
|
26
|
+
/******/ exports: {}
|
27
|
+
/******/ };
|
28
|
+
/******/
|
29
|
+
/******/ // Execute the module function
|
30
|
+
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
31
|
+
/******/
|
32
|
+
/******/ // Flag the module as loaded
|
33
|
+
/******/ module.l = true;
|
34
|
+
/******/
|
35
|
+
/******/ // Return the exports of the module
|
36
|
+
/******/ return module.exports;
|
37
|
+
/******/ }
|
38
|
+
/******/
|
39
|
+
/******/
|
40
|
+
/******/ // expose the modules object (__webpack_modules__)
|
41
|
+
/******/ __webpack_require__.m = modules;
|
42
|
+
/******/
|
43
|
+
/******/ // expose the module cache
|
44
|
+
/******/ __webpack_require__.c = installedModules;
|
45
|
+
/******/
|
46
|
+
/******/ // define getter function for harmony exports
|
47
|
+
/******/ __webpack_require__.d = function(exports, name, getter) {
|
48
|
+
/******/ if(!__webpack_require__.o(exports, name)) {
|
49
|
+
/******/ Object.defineProperty(exports, name, {
|
50
|
+
/******/ configurable: false,
|
51
|
+
/******/ enumerable: true,
|
52
|
+
/******/ get: getter
|
53
|
+
/******/ });
|
54
|
+
/******/ }
|
55
|
+
/******/ };
|
56
|
+
/******/
|
57
|
+
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
58
|
+
/******/ __webpack_require__.n = function(module) {
|
59
|
+
/******/ var getter = module && module.__esModule ?
|
60
|
+
/******/ function getDefault() { return module['default']; } :
|
61
|
+
/******/ function getModuleExports() { return module; };
|
62
|
+
/******/ __webpack_require__.d(getter, 'a', getter);
|
63
|
+
/******/ return getter;
|
64
|
+
/******/ };
|
65
|
+
/******/
|
66
|
+
/******/ // Object.prototype.hasOwnProperty.call
|
67
|
+
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
|
68
|
+
/******/
|
69
|
+
/******/ // __webpack_public_path__
|
70
|
+
/******/ __webpack_require__.p = "";
|
71
|
+
/******/
|
72
|
+
/******/ // Load entry module and return exports
|
73
|
+
/******/ return __webpack_require__(__webpack_require__.s = 8);
|
74
|
+
/******/ })
|
75
|
+
/************************************************************************/
|
76
|
+
/******/ ([
|
77
|
+
/* 0 */
|
78
|
+
/***/ (function(module, exports) {
|
79
|
+
|
80
|
+
var g;
|
81
|
+
|
82
|
+
// This works in non-strict mode
|
83
|
+
g = (function() {
|
84
|
+
return this;
|
85
|
+
})();
|
86
|
+
|
87
|
+
try {
|
88
|
+
// This works if eval is allowed (see CSP)
|
89
|
+
g = g || Function("return this")() || (1,eval)("this");
|
90
|
+
} catch(e) {
|
91
|
+
// This works if the window reference is available
|
92
|
+
if(typeof window === "object")
|
93
|
+
g = window;
|
94
|
+
}
|
95
|
+
|
96
|
+
// g can still be undefined, but nothing to do about it...
|
97
|
+
// We return undefined, instead of nothing here, so it's
|
98
|
+
// easier to handle this case. if(!global) { ...}
|
99
|
+
|
100
|
+
module.exports = g;
|
101
|
+
|
102
|
+
|
103
|
+
/***/ }),
|
104
|
+
/* 1 */
|
105
|
+
/***/ (function(module, exports, __webpack_require__) {
|
106
|
+
|
107
|
+
"use strict";
|
108
|
+
|
109
|
+
|
110
|
+
Object.defineProperty(exports, "__esModule", {
|
111
|
+
value: true
|
112
|
+
});
|
113
|
+
|
114
|
+
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 */
|
115
|
+
|
116
|
+
exports.lory = lory;
|
117
|
+
|
118
|
+
var _detectPrefixes = __webpack_require__(2);
|
119
|
+
|
120
|
+
var _detectPrefixes2 = _interopRequireDefault(_detectPrefixes);
|
121
|
+
|
122
|
+
var _detectSupportsPassive = __webpack_require__(3);
|
123
|
+
|
124
|
+
var _detectSupportsPassive2 = _interopRequireDefault(_detectSupportsPassive);
|
125
|
+
|
126
|
+
var _dispatchEvent = __webpack_require__(4);
|
127
|
+
|
128
|
+
var _dispatchEvent2 = _interopRequireDefault(_dispatchEvent);
|
129
|
+
|
130
|
+
var _defaults = __webpack_require__(6);
|
131
|
+
|
132
|
+
var _defaults2 = _interopRequireDefault(_defaults);
|
133
|
+
|
134
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
135
|
+
|
136
|
+
var slice = Array.prototype.slice;
|
137
|
+
|
138
|
+
function lory(slider, opts) {
|
139
|
+
var position = void 0;
|
140
|
+
var slidesWidth = void 0;
|
141
|
+
var frameWidth = void 0;
|
142
|
+
var slides = void 0;
|
143
|
+
|
144
|
+
/**
|
145
|
+
* slider DOM elements
|
146
|
+
*/
|
147
|
+
var frame = void 0;
|
148
|
+
var slideContainer = void 0;
|
149
|
+
var prevCtrl = void 0;
|
150
|
+
var nextCtrl = void 0;
|
151
|
+
var prefixes = void 0;
|
152
|
+
var transitionEndCallback = void 0;
|
153
|
+
|
154
|
+
var index = 0;
|
155
|
+
var options = {};
|
156
|
+
var touchEventParams = (0, _detectSupportsPassive2.default)() ? { passive: true } : false;
|
157
|
+
|
158
|
+
/**
|
159
|
+
* if object is jQuery convert to native DOM element
|
160
|
+
*/
|
161
|
+
if (typeof jQuery !== 'undefined' && slider instanceof jQuery) {
|
162
|
+
slider = slider[0];
|
163
|
+
}
|
164
|
+
|
165
|
+
/**
|
166
|
+
* private
|
167
|
+
* set active class to element which is the current slide
|
168
|
+
*/
|
169
|
+
function setActiveElement(slides, currentIndex) {
|
170
|
+
var _options = options,
|
171
|
+
classNameActiveSlide = _options.classNameActiveSlide;
|
172
|
+
|
173
|
+
|
174
|
+
slides.forEach(function (element, index) {
|
175
|
+
if (element.classList.contains(classNameActiveSlide)) {
|
176
|
+
element.classList.remove(classNameActiveSlide);
|
177
|
+
}
|
178
|
+
});
|
179
|
+
|
180
|
+
slides[currentIndex].classList.add(classNameActiveSlide);
|
181
|
+
}
|
182
|
+
|
183
|
+
/**
|
184
|
+
* private
|
185
|
+
* setupInfinite: function to setup if infinite is set
|
186
|
+
*
|
187
|
+
* @param {array} slideArray
|
188
|
+
* @return {array} array of updated slideContainer elements
|
189
|
+
*/
|
190
|
+
function setupInfinite(slideArray) {
|
191
|
+
var _options2 = options,
|
192
|
+
infinite = _options2.infinite;
|
193
|
+
|
194
|
+
|
195
|
+
var front = slideArray.slice(0, infinite);
|
196
|
+
var back = slideArray.slice(slideArray.length - infinite, slideArray.length);
|
197
|
+
|
198
|
+
front.forEach(function (element) {
|
199
|
+
var cloned = element.cloneNode(true);
|
200
|
+
|
201
|
+
slideContainer.appendChild(cloned);
|
202
|
+
});
|
203
|
+
|
204
|
+
back.reverse().forEach(function (element) {
|
205
|
+
var cloned = element.cloneNode(true);
|
206
|
+
|
207
|
+
slideContainer.insertBefore(cloned, slideContainer.firstChild);
|
208
|
+
});
|
209
|
+
|
210
|
+
slideContainer.addEventListener(prefixes.transitionEnd, onTransitionEnd);
|
211
|
+
|
212
|
+
return slice.call(slideContainer.children);
|
213
|
+
}
|
214
|
+
|
215
|
+
/**
|
216
|
+
* [dispatchSliderEvent description]
|
217
|
+
* @return {[type]} [description]
|
218
|
+
*/
|
219
|
+
function dispatchSliderEvent(phase, type, detail) {
|
220
|
+
(0, _dispatchEvent2.default)(slider, phase + '.lory.' + type, detail);
|
221
|
+
}
|
222
|
+
|
223
|
+
/**
|
224
|
+
* translates to a given position in a given time in milliseconds
|
225
|
+
*
|
226
|
+
* @to {number} number in pixels where to translate to
|
227
|
+
* @duration {number} time in milliseconds for the transistion
|
228
|
+
* @ease {string} easing css property
|
229
|
+
*/
|
230
|
+
function translate(to, duration, ease) {
|
231
|
+
var style = slideContainer && slideContainer.style;
|
232
|
+
|
233
|
+
if (style) {
|
234
|
+
style[prefixes.transition + 'TimingFunction'] = ease;
|
235
|
+
style[prefixes.transition + 'Duration'] = duration + 'ms';
|
236
|
+
|
237
|
+
if (prefixes.hasTranslate3d) {
|
238
|
+
style[prefixes.transform] = 'translate3d(' + to + 'px, 0, 0)';
|
239
|
+
} else {
|
240
|
+
style[prefixes.transform] = 'translate(' + to + 'px, 0)';
|
241
|
+
}
|
242
|
+
}
|
243
|
+
}
|
244
|
+
|
245
|
+
/**
|
246
|
+
* slidefunction called by prev, next & touchend
|
247
|
+
*
|
248
|
+
* determine nextIndex and slide to next postion
|
249
|
+
* under restrictions of the defined options
|
250
|
+
*
|
251
|
+
* @direction {boolean}
|
252
|
+
*/
|
253
|
+
function slide(nextIndex, direction) {
|
254
|
+
var _options3 = options,
|
255
|
+
slideSpeed = _options3.slideSpeed,
|
256
|
+
slidesToScroll = _options3.slidesToScroll,
|
257
|
+
infinite = _options3.infinite,
|
258
|
+
rewind = _options3.rewind,
|
259
|
+
rewindSpeed = _options3.rewindSpeed,
|
260
|
+
ease = _options3.ease,
|
261
|
+
classNameActiveSlide = _options3.classNameActiveSlide;
|
262
|
+
|
263
|
+
|
264
|
+
var duration = slideSpeed;
|
265
|
+
|
266
|
+
var nextSlide = direction ? index + 1 : index - 1;
|
267
|
+
var maxOffset = Math.round(slidesWidth - frameWidth);
|
268
|
+
|
269
|
+
dispatchSliderEvent('before', 'slide', {
|
270
|
+
index: index,
|
271
|
+
nextSlide: nextSlide
|
272
|
+
});
|
273
|
+
|
274
|
+
/**
|
275
|
+
* Reset control classes
|
276
|
+
*/
|
277
|
+
if (prevCtrl) {
|
278
|
+
prevCtrl.classList.remove('disabled');
|
279
|
+
}
|
280
|
+
if (nextCtrl) {
|
281
|
+
nextCtrl.classList.remove('disabled');
|
282
|
+
}
|
283
|
+
|
284
|
+
if (typeof nextIndex !== 'number') {
|
285
|
+
if (direction) {
|
286
|
+
nextIndex = index + slidesToScroll;
|
287
|
+
} else {
|
288
|
+
nextIndex = index - slidesToScroll;
|
289
|
+
}
|
290
|
+
}
|
291
|
+
|
292
|
+
nextIndex = Math.min(Math.max(nextIndex, 0), slides.length - 1);
|
293
|
+
|
294
|
+
if (infinite && direction === undefined) {
|
295
|
+
nextIndex += infinite;
|
296
|
+
}
|
297
|
+
|
298
|
+
var nextOffset = Math.min(Math.max(slides[nextIndex].offsetLeft * -1, maxOffset * -1), 0);
|
299
|
+
|
300
|
+
if (rewind && Math.abs(position.x) === maxOffset && direction) {
|
301
|
+
nextOffset = 0;
|
302
|
+
nextIndex = 0;
|
303
|
+
duration = rewindSpeed;
|
304
|
+
}
|
305
|
+
|
306
|
+
/**
|
307
|
+
* translate to the nextOffset by a defined duration and ease function
|
308
|
+
*/
|
309
|
+
translate(nextOffset, duration, ease);
|
310
|
+
|
311
|
+
/**
|
312
|
+
* update the position with the next position
|
313
|
+
*/
|
314
|
+
position.x = nextOffset;
|
315
|
+
|
316
|
+
/**
|
317
|
+
* update the index with the nextIndex only if
|
318
|
+
* the offset of the nextIndex is in the range of the maxOffset
|
319
|
+
*/
|
320
|
+
if (slides[nextIndex].offsetLeft <= maxOffset) {
|
321
|
+
index = nextIndex;
|
322
|
+
}
|
323
|
+
|
324
|
+
if (infinite && (nextIndex === slides.length - infinite || nextIndex === 0)) {
|
325
|
+
if (direction) {
|
326
|
+
index = infinite;
|
327
|
+
}
|
328
|
+
|
329
|
+
if (!direction) {
|
330
|
+
index = slides.length - infinite * 2;
|
331
|
+
}
|
332
|
+
|
333
|
+
position.x = slides[index].offsetLeft * -1;
|
334
|
+
|
335
|
+
transitionEndCallback = function transitionEndCallback() {
|
336
|
+
translate(slides[index].offsetLeft * -1, 0, undefined);
|
337
|
+
};
|
338
|
+
}
|
339
|
+
|
340
|
+
if (classNameActiveSlide) {
|
341
|
+
setActiveElement(slice.call(slides), index);
|
342
|
+
}
|
343
|
+
|
344
|
+
/**
|
345
|
+
* update classes for next and prev arrows
|
346
|
+
* based on user settings
|
347
|
+
*/
|
348
|
+
if (prevCtrl && !infinite && nextIndex === 0) {
|
349
|
+
prevCtrl.classList.add('disabled');
|
350
|
+
}
|
351
|
+
|
352
|
+
if (nextCtrl && !infinite && !rewind && nextIndex + 1 === slides.length) {
|
353
|
+
nextCtrl.classList.add('disabled');
|
354
|
+
}
|
355
|
+
|
356
|
+
dispatchSliderEvent('after', 'slide', {
|
357
|
+
currentSlide: index
|
358
|
+
});
|
359
|
+
}
|
360
|
+
|
361
|
+
/**
|
362
|
+
* public
|
363
|
+
* setup function
|
364
|
+
*/
|
365
|
+
function setup() {
|
366
|
+
dispatchSliderEvent('before', 'init');
|
367
|
+
|
368
|
+
prefixes = (0, _detectPrefixes2.default)();
|
369
|
+
options = _extends({}, _defaults2.default, opts);
|
370
|
+
|
371
|
+
var _options4 = options,
|
372
|
+
classNameFrame = _options4.classNameFrame,
|
373
|
+
classNameSlideContainer = _options4.classNameSlideContainer,
|
374
|
+
classNamePrevCtrl = _options4.classNamePrevCtrl,
|
375
|
+
classNameNextCtrl = _options4.classNameNextCtrl,
|
376
|
+
enableMouseEvents = _options4.enableMouseEvents,
|
377
|
+
classNameActiveSlide = _options4.classNameActiveSlide,
|
378
|
+
initialIndex = _options4.initialIndex;
|
379
|
+
|
380
|
+
|
381
|
+
index = initialIndex;
|
382
|
+
frame = slider.getElementsByClassName(classNameFrame)[0];
|
383
|
+
slideContainer = frame.getElementsByClassName(classNameSlideContainer)[0];
|
384
|
+
prevCtrl = slider.getElementsByClassName(classNamePrevCtrl)[0];
|
385
|
+
nextCtrl = slider.getElementsByClassName(classNameNextCtrl)[0];
|
386
|
+
|
387
|
+
position = {
|
388
|
+
x: slideContainer.offsetLeft,
|
389
|
+
y: slideContainer.offsetTop
|
390
|
+
};
|
391
|
+
|
392
|
+
if (options.infinite) {
|
393
|
+
slides = setupInfinite(slice.call(slideContainer.children));
|
394
|
+
} else {
|
395
|
+
slides = slice.call(slideContainer.children);
|
396
|
+
|
397
|
+
if (prevCtrl) {
|
398
|
+
prevCtrl.classList.add('disabled');
|
399
|
+
}
|
400
|
+
|
401
|
+
if (nextCtrl && slides.length === 1 && !options.rewind) {
|
402
|
+
nextCtrl.classList.add('disabled');
|
403
|
+
}
|
404
|
+
}
|
405
|
+
|
406
|
+
reset();
|
407
|
+
|
408
|
+
if (classNameActiveSlide) {
|
409
|
+
setActiveElement(slides, index);
|
410
|
+
}
|
411
|
+
|
412
|
+
if (prevCtrl && nextCtrl) {
|
413
|
+
prevCtrl.addEventListener('click', prev);
|
414
|
+
nextCtrl.addEventListener('click', next);
|
415
|
+
}
|
416
|
+
|
417
|
+
frame.addEventListener('touchstart', onTouchstart, touchEventParams);
|
418
|
+
|
419
|
+
if (enableMouseEvents) {
|
420
|
+
frame.addEventListener('mousedown', onTouchstart);
|
421
|
+
frame.addEventListener('click', onClick);
|
422
|
+
}
|
423
|
+
|
424
|
+
options.window.addEventListener('resize', onResize);
|
425
|
+
|
426
|
+
dispatchSliderEvent('after', 'init');
|
427
|
+
}
|
428
|
+
|
429
|
+
/**
|
430
|
+
* public
|
431
|
+
* reset function: called on resize
|
432
|
+
*/
|
433
|
+
function reset() {
|
434
|
+
var _options5 = options,
|
435
|
+
infinite = _options5.infinite,
|
436
|
+
ease = _options5.ease,
|
437
|
+
rewindSpeed = _options5.rewindSpeed,
|
438
|
+
rewindOnResize = _options5.rewindOnResize,
|
439
|
+
classNameActiveSlide = _options5.classNameActiveSlide,
|
440
|
+
initialIndex = _options5.initialIndex;
|
441
|
+
|
442
|
+
|
443
|
+
slidesWidth = slideContainer.getBoundingClientRect().width || slideContainer.offsetWidth;
|
444
|
+
frameWidth = frame.getBoundingClientRect().width || frame.offsetWidth;
|
445
|
+
|
446
|
+
if (frameWidth === slidesWidth) {
|
447
|
+
slidesWidth = slides.reduce(function (previousValue, slide) {
|
448
|
+
return previousValue + slide.getBoundingClientRect().width || slide.offsetWidth;
|
449
|
+
}, 0);
|
450
|
+
}
|
451
|
+
|
452
|
+
if (rewindOnResize) {
|
453
|
+
index = initialIndex;
|
454
|
+
} else {
|
455
|
+
ease = null;
|
456
|
+
rewindSpeed = 0;
|
457
|
+
}
|
458
|
+
|
459
|
+
if (infinite) {
|
460
|
+
translate(slides[index + infinite].offsetLeft * -1, 0, null);
|
461
|
+
|
462
|
+
index = index + infinite;
|
463
|
+
position.x = slides[index].offsetLeft * -1;
|
464
|
+
} else {
|
465
|
+
translate(slides[index].offsetLeft * -1, rewindSpeed, ease);
|
466
|
+
position.x = slides[index].offsetLeft * -1;
|
467
|
+
}
|
468
|
+
|
469
|
+
if (classNameActiveSlide) {
|
470
|
+
setActiveElement(slice.call(slides), index);
|
471
|
+
}
|
472
|
+
}
|
473
|
+
|
474
|
+
/**
|
475
|
+
* public
|
476
|
+
* slideTo: called on clickhandler
|
477
|
+
*/
|
478
|
+
function slideTo(index) {
|
479
|
+
slide(index);
|
480
|
+
}
|
481
|
+
|
482
|
+
/**
|
483
|
+
* public
|
484
|
+
* returnIndex function: called on clickhandler
|
485
|
+
*/
|
486
|
+
function returnIndex() {
|
487
|
+
return index - options.infinite || 0;
|
488
|
+
}
|
489
|
+
|
490
|
+
/**
|
491
|
+
* public
|
492
|
+
* prev function: called on clickhandler
|
493
|
+
*/
|
494
|
+
function prev() {
|
495
|
+
slide(false, false);
|
496
|
+
}
|
497
|
+
|
498
|
+
/**
|
499
|
+
* public
|
500
|
+
* next function: called on clickhandler
|
501
|
+
*/
|
502
|
+
function next() {
|
503
|
+
slide(false, true);
|
504
|
+
}
|
505
|
+
|
506
|
+
/**
|
507
|
+
* public
|
508
|
+
* destroy function: called to gracefully destroy the lory instance
|
509
|
+
*/
|
510
|
+
function destroy() {
|
511
|
+
dispatchSliderEvent('before', 'destroy');
|
512
|
+
|
513
|
+
// remove event listeners
|
514
|
+
frame.removeEventListener(prefixes.transitionEnd, onTransitionEnd);
|
515
|
+
frame.removeEventListener('touchstart', onTouchstart, touchEventParams);
|
516
|
+
frame.removeEventListener('touchmove', onTouchmove, touchEventParams);
|
517
|
+
frame.removeEventListener('touchend', onTouchend);
|
518
|
+
frame.removeEventListener('mousemove', onTouchmove);
|
519
|
+
frame.removeEventListener('mousedown', onTouchstart);
|
520
|
+
frame.removeEventListener('mouseup', onTouchend);
|
521
|
+
frame.removeEventListener('mouseleave', onTouchend);
|
522
|
+
frame.removeEventListener('click', onClick);
|
523
|
+
|
524
|
+
options.window.removeEventListener('resize', onResize);
|
525
|
+
|
526
|
+
if (prevCtrl) {
|
527
|
+
prevCtrl.removeEventListener('click', prev);
|
528
|
+
}
|
529
|
+
|
530
|
+
if (nextCtrl) {
|
531
|
+
nextCtrl.removeEventListener('click', next);
|
532
|
+
}
|
533
|
+
|
534
|
+
// remove cloned slides if infinite is set
|
535
|
+
if (options.infinite) {
|
536
|
+
Array.apply(null, Array(options.infinite)).forEach(function () {
|
537
|
+
slideContainer.removeChild(slideContainer.firstChild);
|
538
|
+
slideContainer.removeChild(slideContainer.lastChild);
|
539
|
+
});
|
540
|
+
}
|
541
|
+
|
542
|
+
dispatchSliderEvent('after', 'destroy');
|
543
|
+
}
|
544
|
+
|
545
|
+
// event handling
|
546
|
+
|
547
|
+
var touchOffset = void 0;
|
548
|
+
var delta = void 0;
|
549
|
+
var isScrolling = void 0;
|
550
|
+
|
551
|
+
function onTransitionEnd() {
|
552
|
+
if (transitionEndCallback) {
|
553
|
+
transitionEndCallback();
|
554
|
+
|
555
|
+
transitionEndCallback = undefined;
|
556
|
+
}
|
557
|
+
}
|
558
|
+
|
559
|
+
function onTouchstart(event) {
|
560
|
+
var _options6 = options,
|
561
|
+
enableMouseEvents = _options6.enableMouseEvents;
|
562
|
+
|
563
|
+
var touches = event.touches ? event.touches[0] : event;
|
564
|
+
|
565
|
+
if (enableMouseEvents) {
|
566
|
+
frame.addEventListener('mousemove', onTouchmove);
|
567
|
+
frame.addEventListener('mouseup', onTouchend);
|
568
|
+
frame.addEventListener('mouseleave', onTouchend);
|
569
|
+
}
|
570
|
+
|
571
|
+
frame.addEventListener('touchmove', onTouchmove, touchEventParams);
|
572
|
+
frame.addEventListener('touchend', onTouchend);
|
573
|
+
|
574
|
+
var pageX = touches.pageX,
|
575
|
+
pageY = touches.pageY;
|
576
|
+
|
577
|
+
|
578
|
+
touchOffset = {
|
579
|
+
x: pageX,
|
580
|
+
y: pageY,
|
581
|
+
time: Date.now()
|
582
|
+
};
|
583
|
+
|
584
|
+
isScrolling = undefined;
|
585
|
+
|
586
|
+
delta = {};
|
587
|
+
|
588
|
+
dispatchSliderEvent('on', 'touchstart', {
|
589
|
+
event: event
|
590
|
+
});
|
591
|
+
}
|
592
|
+
|
593
|
+
function onTouchmove(event) {
|
594
|
+
var touches = event.touches ? event.touches[0] : event;
|
595
|
+
var pageX = touches.pageX,
|
596
|
+
pageY = touches.pageY;
|
597
|
+
|
598
|
+
|
599
|
+
delta = {
|
600
|
+
x: pageX - touchOffset.x,
|
601
|
+
y: pageY - touchOffset.y
|
602
|
+
};
|
603
|
+
|
604
|
+
if (typeof isScrolling === 'undefined') {
|
605
|
+
isScrolling = !!(isScrolling || Math.abs(delta.x) < Math.abs(delta.y));
|
606
|
+
}
|
607
|
+
|
608
|
+
if (!isScrolling && touchOffset) {
|
609
|
+
event.preventDefault();
|
610
|
+
translate(position.x + delta.x, 0, null);
|
611
|
+
}
|
612
|
+
|
613
|
+
// may be
|
614
|
+
dispatchSliderEvent('on', 'touchmove', {
|
615
|
+
event: event
|
616
|
+
});
|
617
|
+
}
|
618
|
+
|
619
|
+
function onTouchend(event) {
|
620
|
+
/**
|
621
|
+
* time between touchstart and touchend in milliseconds
|
622
|
+
* @duration {number}
|
623
|
+
*/
|
624
|
+
var duration = touchOffset ? Date.now() - touchOffset.time : undefined;
|
625
|
+
|
626
|
+
/**
|
627
|
+
* is valid if:
|
628
|
+
*
|
629
|
+
* -> swipe attempt time is over 300 ms
|
630
|
+
* and
|
631
|
+
* -> swipe distance is greater than 25px
|
632
|
+
* or
|
633
|
+
* -> swipe distance is more then a third of the swipe area
|
634
|
+
*
|
635
|
+
* @isValidSlide {Boolean}
|
636
|
+
*/
|
637
|
+
var isValid = Number(duration) < 300 && Math.abs(delta.x) > 25 || Math.abs(delta.x) > frameWidth / 3;
|
638
|
+
|
639
|
+
/**
|
640
|
+
* is out of bounds if:
|
641
|
+
*
|
642
|
+
* -> index is 0 and delta x is greater than 0
|
643
|
+
* or
|
644
|
+
* -> index is the last slide and delta is smaller than 0
|
645
|
+
*
|
646
|
+
* @isOutOfBounds {Boolean}
|
647
|
+
*/
|
648
|
+
var isOutOfBounds = !index && delta.x > 0 || index === slides.length - 1 && delta.x < 0;
|
649
|
+
|
650
|
+
var direction = delta.x < 0;
|
651
|
+
|
652
|
+
if (!isScrolling) {
|
653
|
+
if (isValid && !isOutOfBounds) {
|
654
|
+
slide(false, direction);
|
655
|
+
} else {
|
656
|
+
translate(position.x, options.snapBackSpeed);
|
657
|
+
}
|
658
|
+
}
|
659
|
+
|
660
|
+
touchOffset = undefined;
|
661
|
+
|
662
|
+
/**
|
663
|
+
* remove eventlisteners after swipe attempt
|
664
|
+
*/
|
665
|
+
frame.removeEventListener('touchmove', onTouchmove);
|
666
|
+
frame.removeEventListener('touchend', onTouchend);
|
667
|
+
frame.removeEventListener('mousemove', onTouchmove);
|
668
|
+
frame.removeEventListener('mouseup', onTouchend);
|
669
|
+
frame.removeEventListener('mouseleave', onTouchend);
|
670
|
+
|
671
|
+
dispatchSliderEvent('on', 'touchend', {
|
672
|
+
event: event
|
673
|
+
});
|
674
|
+
}
|
675
|
+
|
676
|
+
function onClick(event) {
|
677
|
+
if (delta.x) {
|
678
|
+
event.preventDefault();
|
679
|
+
}
|
680
|
+
}
|
681
|
+
|
682
|
+
function onResize(event) {
|
683
|
+
reset();
|
684
|
+
|
685
|
+
dispatchSliderEvent('on', 'resize', {
|
686
|
+
event: event
|
687
|
+
});
|
688
|
+
}
|
689
|
+
|
690
|
+
// trigger initial setup
|
691
|
+
setup();
|
692
|
+
|
693
|
+
// expose public api
|
694
|
+
return {
|
695
|
+
setup: setup,
|
696
|
+
reset: reset,
|
697
|
+
slideTo: slideTo,
|
698
|
+
returnIndex: returnIndex,
|
699
|
+
prev: prev,
|
700
|
+
next: next,
|
701
|
+
destroy: destroy
|
702
|
+
};
|
703
|
+
}
|
704
|
+
|
705
|
+
/***/ }),
|
706
|
+
/* 2 */
|
707
|
+
/***/ (function(module, exports, __webpack_require__) {
|
708
|
+
|
709
|
+
"use strict";
|
710
|
+
/* WEBPACK VAR INJECTION */(function(global) {
|
711
|
+
|
712
|
+
Object.defineProperty(exports, "__esModule", {
|
713
|
+
value: true
|
714
|
+
});
|
715
|
+
exports.default = detectPrefixes;
|
716
|
+
/**
|
717
|
+
* Detecting prefixes for saving time and bytes
|
718
|
+
*/
|
719
|
+
function detectPrefixes() {
|
720
|
+
var transform = void 0;
|
721
|
+
var transition = void 0;
|
722
|
+
var transitionEnd = void 0;
|
723
|
+
var hasTranslate3d = void 0;
|
724
|
+
|
725
|
+
(function () {
|
726
|
+
var el = document.createElement('_');
|
727
|
+
var style = el.style;
|
728
|
+
|
729
|
+
var prop = void 0;
|
730
|
+
|
731
|
+
if (style[prop = 'webkitTransition'] === '') {
|
732
|
+
transitionEnd = 'webkitTransitionEnd';
|
733
|
+
transition = prop;
|
734
|
+
}
|
735
|
+
|
736
|
+
if (style[prop = 'transition'] === '') {
|
737
|
+
transitionEnd = 'transitionend';
|
738
|
+
transition = prop;
|
739
|
+
}
|
740
|
+
|
741
|
+
if (style[prop = 'webkitTransform'] === '') {
|
742
|
+
transform = prop;
|
743
|
+
}
|
744
|
+
|
745
|
+
if (style[prop = 'msTransform'] === '') {
|
746
|
+
transform = prop;
|
747
|
+
}
|
748
|
+
|
749
|
+
if (style[prop = 'transform'] === '') {
|
750
|
+
transform = prop;
|
751
|
+
}
|
752
|
+
|
753
|
+
document.body.insertBefore(el, null);
|
754
|
+
style[transform] = 'translate3d(0, 0, 0)';
|
755
|
+
hasTranslate3d = !!global.getComputedStyle(el).getPropertyValue(transform);
|
756
|
+
document.body.removeChild(el);
|
757
|
+
})();
|
758
|
+
|
759
|
+
return {
|
760
|
+
transform: transform,
|
761
|
+
transition: transition,
|
762
|
+
transitionEnd: transitionEnd,
|
763
|
+
hasTranslate3d: hasTranslate3d
|
764
|
+
};
|
765
|
+
}
|
766
|
+
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0)))
|
767
|
+
|
768
|
+
/***/ }),
|
769
|
+
/* 3 */
|
770
|
+
/***/ (function(module, exports, __webpack_require__) {
|
771
|
+
|
772
|
+
"use strict";
|
773
|
+
|
774
|
+
|
775
|
+
Object.defineProperty(exports, "__esModule", {
|
776
|
+
value: true
|
777
|
+
});
|
778
|
+
exports.default = detectSupportsPassive;
|
779
|
+
function detectSupportsPassive() {
|
780
|
+
var supportsPassive = false;
|
781
|
+
|
782
|
+
try {
|
783
|
+
var opts = Object.defineProperty({}, 'passive', {
|
784
|
+
get: function get() {
|
785
|
+
supportsPassive = true;
|
786
|
+
}
|
787
|
+
});
|
788
|
+
|
789
|
+
window.addEventListener('testPassive', null, opts);
|
790
|
+
window.removeEventListener('testPassive', null, opts);
|
791
|
+
} catch (e) {}
|
792
|
+
|
793
|
+
return supportsPassive;
|
794
|
+
}
|
795
|
+
|
796
|
+
/***/ }),
|
797
|
+
/* 4 */
|
798
|
+
/***/ (function(module, exports, __webpack_require__) {
|
799
|
+
|
800
|
+
"use strict";
|
801
|
+
|
802
|
+
|
803
|
+
Object.defineProperty(exports, "__esModule", {
|
804
|
+
value: true
|
805
|
+
});
|
806
|
+
exports.default = dispatchEvent;
|
807
|
+
|
808
|
+
var _customEvent = __webpack_require__(5);
|
809
|
+
|
810
|
+
var _customEvent2 = _interopRequireDefault(_customEvent);
|
811
|
+
|
812
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
813
|
+
|
814
|
+
/**
|
815
|
+
* dispatch custom events
|
816
|
+
*
|
817
|
+
* @param {element} el slideshow element
|
818
|
+
* @param {string} type custom event name
|
819
|
+
* @param {object} detail custom detail information
|
820
|
+
*/
|
821
|
+
function dispatchEvent(target, type, detail) {
|
822
|
+
var event = new _customEvent2.default(type, {
|
823
|
+
bubbles: true,
|
824
|
+
cancelable: true,
|
825
|
+
detail: detail
|
826
|
+
});
|
827
|
+
|
828
|
+
target.dispatchEvent(event);
|
829
|
+
}
|
830
|
+
|
831
|
+
/***/ }),
|
832
|
+
/* 5 */
|
833
|
+
/***/ (function(module, exports, __webpack_require__) {
|
834
|
+
|
835
|
+
/* WEBPACK VAR INJECTION */(function(global) {
|
836
|
+
var NativeCustomEvent = global.CustomEvent;
|
837
|
+
|
838
|
+
function useNative () {
|
839
|
+
try {
|
840
|
+
var p = new NativeCustomEvent('cat', { detail: { foo: 'bar' } });
|
841
|
+
return 'cat' === p.type && 'bar' === p.detail.foo;
|
842
|
+
} catch (e) {
|
843
|
+
}
|
844
|
+
return false;
|
845
|
+
}
|
846
|
+
|
847
|
+
/**
|
848
|
+
* Cross-browser `CustomEvent` constructor.
|
849
|
+
*
|
850
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent.CustomEvent
|
851
|
+
*
|
852
|
+
* @public
|
853
|
+
*/
|
854
|
+
|
855
|
+
module.exports = useNative() ? NativeCustomEvent :
|
856
|
+
|
857
|
+
// IE >= 9
|
858
|
+
'undefined' !== typeof document && 'function' === typeof document.createEvent ? function CustomEvent (type, params) {
|
859
|
+
var e = document.createEvent('CustomEvent');
|
860
|
+
if (params) {
|
861
|
+
e.initCustomEvent(type, params.bubbles, params.cancelable, params.detail);
|
862
|
+
} else {
|
863
|
+
e.initCustomEvent(type, false, false, void 0);
|
864
|
+
}
|
865
|
+
return e;
|
866
|
+
} :
|
867
|
+
|
868
|
+
// IE <= 8
|
869
|
+
function CustomEvent (type, params) {
|
870
|
+
var e = document.createEventObject();
|
871
|
+
e.type = type;
|
872
|
+
if (params) {
|
873
|
+
e.bubbles = Boolean(params.bubbles);
|
874
|
+
e.cancelable = Boolean(params.cancelable);
|
875
|
+
e.detail = params.detail;
|
876
|
+
} else {
|
877
|
+
e.bubbles = false;
|
878
|
+
e.cancelable = false;
|
879
|
+
e.detail = void 0;
|
880
|
+
}
|
881
|
+
return e;
|
882
|
+
}
|
883
|
+
|
884
|
+
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0)))
|
885
|
+
|
886
|
+
/***/ }),
|
887
|
+
/* 6 */
|
888
|
+
/***/ (function(module, exports, __webpack_require__) {
|
889
|
+
|
890
|
+
"use strict";
|
891
|
+
|
892
|
+
|
893
|
+
Object.defineProperty(exports, "__esModule", {
|
894
|
+
value: true
|
895
|
+
});
|
896
|
+
exports.default = {
|
897
|
+
/**
|
898
|
+
* slides scrolled at once
|
899
|
+
* @slidesToScroll {Number}
|
900
|
+
*/
|
901
|
+
slidesToScroll: 1,
|
902
|
+
|
903
|
+
/**
|
904
|
+
* time in milliseconds for the animation of a valid slide attempt
|
905
|
+
* @slideSpeed {Number}
|
906
|
+
*/
|
907
|
+
slideSpeed: 300,
|
908
|
+
|
909
|
+
/**
|
910
|
+
* time in milliseconds for the animation of the rewind after the last slide
|
911
|
+
* @rewindSpeed {Number}
|
912
|
+
*/
|
913
|
+
rewindSpeed: 600,
|
914
|
+
|
915
|
+
/**
|
916
|
+
* time for the snapBack of the slider if the slide attempt was not valid
|
917
|
+
* @snapBackSpeed {Number}
|
918
|
+
*/
|
919
|
+
snapBackSpeed: 200,
|
920
|
+
|
921
|
+
/**
|
922
|
+
* Basic easing functions: https://developer.mozilla.org/de/docs/Web/CSS/transition-timing-function
|
923
|
+
* cubic bezier easing functions: http://easings.net/de
|
924
|
+
* @ease {String}
|
925
|
+
*/
|
926
|
+
ease: 'ease',
|
927
|
+
|
928
|
+
/**
|
929
|
+
* if slider reached the last slide, with next click the slider goes back to the startindex.
|
930
|
+
* use infinite or rewind, not both
|
931
|
+
* @rewind {Boolean}
|
932
|
+
*/
|
933
|
+
rewind: false,
|
934
|
+
|
935
|
+
/**
|
936
|
+
* number of visible slides or false
|
937
|
+
* use infinite or rewind, not both
|
938
|
+
* @infinite {number}
|
939
|
+
*/
|
940
|
+
infinite: false,
|
941
|
+
|
942
|
+
/**
|
943
|
+
* the slide index to show when the slider is initialized.
|
944
|
+
* @initialIndex {number}
|
945
|
+
*/
|
946
|
+
initialIndex: 0,
|
947
|
+
|
948
|
+
/**
|
949
|
+
* class name for slider frame
|
950
|
+
* @classNameFrame {string}
|
951
|
+
*/
|
952
|
+
classNameFrame: 'js_frame',
|
953
|
+
|
954
|
+
/**
|
955
|
+
* class name for slides container
|
956
|
+
* @classNameSlideContainer {string}
|
957
|
+
*/
|
958
|
+
classNameSlideContainer: 'js_slides',
|
959
|
+
|
960
|
+
/**
|
961
|
+
* class name for slider prev control
|
962
|
+
* @classNamePrevCtrl {string}
|
963
|
+
*/
|
964
|
+
classNamePrevCtrl: 'js_prev',
|
965
|
+
|
966
|
+
/**
|
967
|
+
* class name for slider next control
|
968
|
+
* @classNameNextCtrl {string}
|
969
|
+
*/
|
970
|
+
classNameNextCtrl: 'js_next',
|
971
|
+
|
972
|
+
/**
|
973
|
+
* class name for current active slide
|
974
|
+
* if emptyString then no class is set
|
975
|
+
* @classNameActiveSlide {string}
|
976
|
+
*/
|
977
|
+
classNameActiveSlide: 'active',
|
978
|
+
|
979
|
+
/**
|
980
|
+
* enables mouse events for swiping on desktop devices
|
981
|
+
* @enableMouseEvents {boolean}
|
982
|
+
*/
|
983
|
+
enableMouseEvents: false,
|
984
|
+
|
985
|
+
/**
|
986
|
+
* window instance
|
987
|
+
* @window {object}
|
988
|
+
*/
|
989
|
+
window: window,
|
990
|
+
|
991
|
+
/**
|
992
|
+
* If false, slides lory to the first slide on window resize.
|
993
|
+
* @rewindOnResize {boolean}
|
994
|
+
*/
|
995
|
+
rewindOnResize: true
|
996
|
+
};
|
997
|
+
|
998
|
+
/***/ }),
|
999
|
+
/* 7 */,
|
1000
|
+
/* 8 */
|
1001
|
+
/***/ (function(module, exports, __webpack_require__) {
|
1002
|
+
|
1003
|
+
"use strict";
|
1004
|
+
|
1005
|
+
|
1006
|
+
var _lory = __webpack_require__(1);
|
1007
|
+
|
1008
|
+
function init($) {
|
1009
|
+
$.fn.lory = function (options) {
|
1010
|
+
return this.each(function () {
|
1011
|
+
var instanceOptions;
|
1012
|
+
|
1013
|
+
if (!$.data(this, 'lory')) {
|
1014
|
+
instanceOptions = $.extend({}, options, $(this).data());
|
1015
|
+
$.data(this, 'lory', (0, _lory.lory)(this, instanceOptions));
|
1016
|
+
}
|
1017
|
+
});
|
1018
|
+
};
|
1019
|
+
} /* globals jQuery */
|
1020
|
+
;
|
1021
|
+
|
1022
|
+
if (typeof jQuery !== 'undefined') {
|
1023
|
+
init(jQuery);
|
1024
|
+
}
|
1025
|
+
|
1026
|
+
/***/ })
|
1027
|
+
/******/ ]);
|
1028
|
+
});
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lory-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- tanvir hasan
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-04-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -58,6 +58,7 @@ files:
|
|
58
58
|
- lib/lory/rails/engine.rb
|
59
59
|
- lib/lory/rails/version.rb
|
60
60
|
- lory-rails.gemspec
|
61
|
+
- vendor/assets/javascripts/jquery.lory.js
|
61
62
|
- vendor/assets/javascripts/lory.js
|
62
63
|
homepage: https://rubygems.org/gems/lory-rails
|
63
64
|
licenses:
|