lory-rails 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 01eb60e45b8bef97723965bd65f3ca8b9b4c7ca8
4
+ data.tar.gz: 5e8d5787011a1c88591f30210cbddfeb2d98c857
5
+ SHA512:
6
+ metadata.gz: c17fa31c58247fe617d93651f5813a42042de6a843c50cd60bdc5d51c681fe65109520b1881a80e11dad2e6382598a305e4c7a1da0899622890de41a0d1c6a0e
7
+ data.tar.gz: 43ff5cfec127ffaadfbe5134d48308650836c5a040e8ee8ea0a53b69f6bb35618655e56e792bab52ac9a94aefbabdf4328a20e914ec7bc3027f56b02f8a1bbf6
data/.gitignore ADDED
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
12
+ *.gem
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.4.1
5
+ before_install: gem install bundler -v 1.16.0
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at tanvir002700@gmail.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in lory-rails.gemspec
6
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 tanvir hasan
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,60 @@
1
+ # Lory::Rails
2
+ [![Gem Version](https://badge.fury.io/rb/lory-rails.svg)](https://rubygems.org/gems/lory-rails)
3
+ [![Downloads](https://img.shields.io/gem/dt/lory-rails.svg)](https://rubygems.org/gems/lory-rails)
4
+ [![GitHub last commit (branch)](https://img.shields.io/github/last-commit/tanvir002700/lory-rails/master.svg)](https://github.com/tanvir002700/lory-rails)
5
+ [![license](https://img.shields.io/github/license/tanvir002700/lory-rails.svg)](https://github.com/tanvir002700/lory-rails/blob/master/LICENSE)
6
+
7
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/lory/rails`. To experiment with that code, run `bin/console` for an interactive prompt.
8
+
9
+ TODO: Delete this and the text above, and describe your gem
10
+
11
+ ## Installation
12
+
13
+ Add this line to your application's Gemfile:
14
+
15
+ ```ruby
16
+ gem 'lory-rails'
17
+ ```
18
+
19
+ And then execute:
20
+
21
+ $ bundle
22
+
23
+ Or install it yourself as:
24
+
25
+ $ gem install lory-rails
26
+
27
+ And then edit your app/assets/stylesheets/application.js file to look something like:
28
+ ``` css
29
+ /*
30
+ *= require_self
31
+ *= require jqeury
32
+ *= require jquery-ui
33
+ *= require lory
34
+ *= require_tree .
35
+ */
36
+ ```
37
+
38
+ **lory-rails is dependant on jQuery, so make sure you have it in your Gemfile.**
39
+
40
+ ## Usage
41
+
42
+ View [lory](http://meandmax.github.io/lory) for complete useage information.
43
+
44
+ ## Development
45
+
46
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
47
+
48
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
49
+
50
+ ## Contributing
51
+
52
+ Bug reports and pull requests are welcome on GitHub at https://github.com/tanvir002700/lory-rails. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
53
+
54
+ ## License
55
+
56
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
57
+
58
+ ## Code of Conduct
59
+
60
+ Everyone interacting in the Lory::Rails project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/tanvir002700/lory-rails/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/VERSIONS.md ADDED
@@ -0,0 +1,5 @@
1
+ # Bundled Versions
2
+
3
+ | Gem | lory |
4
+ |--------|-----------|
5
+ | 0.1.0 | 2.4.0
data/lib/lory/rails.rb ADDED
@@ -0,0 +1,2 @@
1
+ require "lory/rails/version"
2
+ require "lory/rails/engine" if defined? Rails
@@ -0,0 +1,6 @@
1
+ module Lory
2
+ module Rails
3
+ class Engine < ::Rails::Engine; end
4
+ end
5
+ end
6
+
@@ -0,0 +1,5 @@
1
+ module Lory
2
+ module Rails
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,36 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "lory/rails/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "lory-rails"
8
+ spec.version = Lory::Rails::VERSION
9
+ spec.authors = ["tanvir hasan"]
10
+ spec.email = ["tanvir002700@gmail.com"]
11
+
12
+ spec.summary = %q{This gem packages the js lory.js plugin. So you never have to download a custom package through the web interface again.}
13
+ spec.description = %q{Touch enabled minimalistic slider written in vanilla JavaScript.}
14
+ spec.homepage = "https://rubygems.org/gems/lory-rails"
15
+ spec.license = "MIT"
16
+ spec.metadata = { 'source_code_uri' => 'https://github.com/tanvir002700/lory-rails' }
17
+
18
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
19
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
20
+ if spec.respond_to?(:metadata)
21
+ spec.metadata["allowed_push_host"] = "https://rubygems.org"
22
+ else
23
+ raise "RubyGems 2.0 or newer is required to protect against " \
24
+ "public gem pushes."
25
+ end
26
+
27
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
28
+ f.match(%r{^(test|spec|features)/})
29
+ end
30
+ spec.bindir = "exe"
31
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
32
+ spec.require_paths = ["lib"]
33
+
34
+ spec.add_development_dependency "bundler", "~> 1.16"
35
+ spec.add_development_dependency "rake", "~> 10.0"
36
+ end
@@ -0,0 +1,1007 @@
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 = 7);
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
+ /***/ (function(module, exports, __webpack_require__) {
1001
+
1002
+ module.exports = __webpack_require__(1);
1003
+
1004
+
1005
+ /***/ })
1006
+ /******/ ]);
1007
+ });
metadata ADDED
@@ -0,0 +1,89 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: lory-rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - tanvir hasan
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2018-03-01 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.16'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.16'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ description: Touch enabled minimalistic slider written in vanilla JavaScript.
42
+ email:
43
+ - tanvir002700@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".gitignore"
49
+ - ".rspec"
50
+ - ".travis.yml"
51
+ - CODE_OF_CONDUCT.md
52
+ - Gemfile
53
+ - LICENSE.txt
54
+ - README.md
55
+ - Rakefile
56
+ - VERSIONS.md
57
+ - lib/lory/rails.rb
58
+ - lib/lory/rails/engine.rb
59
+ - lib/lory/rails/version.rb
60
+ - lory-rails.gemspec
61
+ - vendor/assets/javascripts/lory.js
62
+ homepage: https://rubygems.org/gems/lory-rails
63
+ licenses:
64
+ - MIT
65
+ metadata:
66
+ source_code_uri: https://github.com/tanvir002700/lory-rails
67
+ allowed_push_host: https://rubygems.org
68
+ post_install_message:
69
+ rdoc_options: []
70
+ require_paths:
71
+ - lib
72
+ required_ruby_version: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ required_rubygems_version: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ requirements: []
83
+ rubyforge_project:
84
+ rubygems_version: 2.6.11
85
+ signing_key:
86
+ specification_version: 4
87
+ summary: This gem packages the js lory.js plugin. So you never have to download a
88
+ custom package through the web interface again.
89
+ test_files: []