perfect-scrollbar-rails 0.6.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: bcf5dc1ecb75ad7d7a02bc79fa4a6af4ade826ff
4
+ data.tar.gz: 035d617278a7553d8886dd27b48c1ef2f5f3e331
5
+ SHA512:
6
+ metadata.gz: 32f729fb4352ab14706a3c68da545b6f0e790b8fefd7046b34b7822fec5fbd8d4c178f5a944a1973c659c938f79b7f98cdb0525cc92650f1b6f4af5eea7241e5
7
+ data.tar.gz: 5232e97350540e03620bcf2113fd1824ebe34a8c1044d3148675b65b823ff8a8565bd7711b1b8221a0abfee1376723a36adce178cf1ebf483c511cfa7f1d952b
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+
data/Dockerfile ADDED
@@ -0,0 +1,35 @@
1
+ # How to use it
2
+ # =============
3
+ #
4
+ # Visit http://blog.zedroot.org/using-docker-to-maintain-a-ruby-gem/
5
+
6
+ # ~~~~ Image base ~~~~
7
+ # Base image with the latest Ruby only
8
+ FROM ruby:2.3.0
9
+ MAINTAINER Guillaume Hain zedtux@zedroot.org
10
+
11
+
12
+ # ~~~~ Set up the environment ~~~~
13
+ ENV DEBIAN_FRONTEND noninteractive
14
+
15
+ # ~~~~ OS Maintenance ~~~~
16
+ RUN apt-get update && apt-get install -y unzip
17
+
18
+ # ~~~~ Rails Preparation ~~~~
19
+ # Rubygems and Bundler
20
+ RUN touch ~/.gemrc && \
21
+ echo "gem: --no-ri --no-rdoc" >> ~/.gemrc && \
22
+ gem install rubygems-update && \
23
+ update_rubygems && \
24
+ gem install bundler && \
25
+ mkdir -p /gem/
26
+
27
+ WORKDIR /gem/
28
+ ADD . /gem/
29
+ RUN bundle install
30
+
31
+ # Import the gem source code
32
+ VOLUME .:/gem/
33
+
34
+ ENTRYPOINT ["bundle", "exec"]
35
+ CMD ["rake", "-T"]
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in perfect-scrollbar-rails.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2016 Guillaume Hain
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,41 @@
1
+ # perfect-scrollbar-Rails
2
+
3
+ This Gem integrates [noraesae](https://github.com/noraesae)'s [perfect-scrollbar](https://github.com/noraesae/perfect-scrollbar/) to your Rails project.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'perfect-scrollbar-rails'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install perfect-scrollbar-rails
18
+
19
+ ## Usage
20
+
21
+ This gem uses a Rails Engine to make perfect-scrollbar's assets available to you.
22
+
23
+ Require the JavaScript files from your `application.js` or wherever needed using:
24
+
25
+ ```
26
+ //= require perfect-scrollbar
27
+ ```
28
+
29
+ Require the CSS files from your `application.scss` or wherever needed using:
30
+
31
+ ```
32
+ *= require perfect-scrollbar
33
+ ```
34
+
35
+ ## Contributing
36
+
37
+ 1. Fork it
38
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
39
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
40
+ 4. Push to the branch (`git push origin my-new-feature`)
41
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,50 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'fileutils'
3
+
4
+ desc 'Update the perfect-scrollbar Javascript and CSS files'
5
+ task :update do
6
+ def working_dir
7
+ 'tmp'
8
+ end
9
+
10
+ def ensure_working_dir_exists!
11
+ FileUtils.mkdir_p(working_dir)
12
+ end
13
+
14
+ def zip_path
15
+ File.join(working_dir, 'perfect-scrollbar.zip')
16
+ end
17
+
18
+ def download(version)
19
+ base_url = 'https://github.com/noraesae/perfect-scrollbar/releases/download'
20
+ final_url = "#{base_url}/#{version}/perfect-scrollbar.zip"
21
+ puts "Downlading perfect-scrollbar #{version} ..."
22
+ `curl -Lfo #{zip_path} #{final_url}`
23
+ end
24
+
25
+ def extract
26
+ puts "Extracting perfect-scrollbar archive ..."
27
+ `unzip -d #{working_dir} #{zip_path}`
28
+ end
29
+
30
+ def move_files
31
+ puts "Installating assets files ..."
32
+ `mv #{working_dir}/js/perfect-scrollbar.jquery.js \
33
+ vendor/assets/javascripts/perfect-scrollbar.js`
34
+ `mv #{working_dir}/css/perfect-scrollbar.css vendor/assets/stylesheets`
35
+ end
36
+
37
+ def clean
38
+ `rm -rf #{working_dir}`
39
+ end
40
+
41
+ FileUtils.mkdir_p('vendor/assets/javascripts')
42
+ FileUtils.mkdir_p('vendor/assets/stylesheets')
43
+ ensure_working_dir_exists!
44
+ download(PerfectScrollbar::Rails::VERSION)
45
+ extract
46
+ move_files
47
+ clean
48
+
49
+ puts "\e[32mDone!\e[0m"
50
+ end
@@ -0,0 +1,9 @@
1
+ require 'perfect-scrollbar-rails/version'
2
+
3
+ module PerfectScrollbar
4
+ module Rails
5
+ class Engine < ::Rails::Engine
6
+ # Make assets avaiable
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,5 @@
1
+ module PerfectScrollbar
2
+ module Rails
3
+ VERSION = '0.6.8.1'
4
+ end
5
+ end
@@ -0,0 +1,38 @@
1
+ #!/usr/bin/env bash
2
+
3
+ DOCKER_IMAGE_NAME="$USER/perfect-scrollbar-rails"
4
+ LIBRARY_NEW_VERSION=`cat lib/**/*.rb | grep VERSION | awk '{ print $3 }' | tr -d "'"`
5
+
6
+ LIBRARY_UPDATED=`git status --porcelain | grep -v "lib/perfect-scrollbar-rails/version.rb"`
7
+ if [[ -n "$LIBRARY_UPDATED" ]]; then
8
+ echo "Your repository is not clean !"
9
+ exit 1
10
+ fi
11
+
12
+ echo "Ensuring Docker image $DOCKER_IMAGE_NAME exists ..."
13
+ EXISTING_DOCKER_IMAGE=`docker images | grep "$DOCKER_IMAGE_NAME"`
14
+ if [[ -z "$EXISTING_DOCKER_IMAGE" ]]; then
15
+ echo "Building the Docker image ..."
16
+ docker build -t "$DOCKER_IMAGE_NAME" .
17
+ fi
18
+
19
+ echo "Updating library code to version $LIBRARY_NEW_VERSION ..."
20
+ docker run --rm -v `pwd`:/gem/ "$DOCKER_IMAGE_NAME" rake update
21
+
22
+ LIBRARY_UPDATED=`git status --porcelain | grep -v make_new_release.sh`
23
+ if [[ -z "$LIBRARY_UPDATED" ]]; then
24
+ echo "No update found, stopping release creation."
25
+ exit 1
26
+ elif [[ "$LIBRARY_UPDATED" == " M lib/perfect-scrollbar-rails/version.rb" ]]; then
27
+ echo "None of the JS or CSS files have been updated."
28
+ exit 1
29
+ fi
30
+
31
+ echo "Committing new version ..."
32
+ git commit -am "Import version $LIBRARY_NEW_VERSION"
33
+
34
+ echo "Releasing gem ..."
35
+ docker run --rm -v ~/.gitconfig:/root/.gitconfig \
36
+ -v ~/.ssh/:/root/.ssh/ \
37
+ -v ~/.gem/:/root/.gem/ \
38
+ -v `pwd`:/gem/ "$DOCKER_IMAGE_NAME" rake release
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'perfect-scrollbar-rails/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'perfect-scrollbar-rails'
8
+ spec.version = PerfectScrollbar::Rails::VERSION
9
+ spec.authors = ['Guillaume Hain']
10
+ spec.email = ['zedtux@zedroot.org']
11
+ spec.description = 'Make perfect-scrollbar available to Rails'
12
+ spec.summary = "This Gem integrates noraesae's Jquery " \
13
+ 'perfect-scrollbar with Rails, exposing its ' \
14
+ 'JavaScript and CSS assets via a Rails Engine.'
15
+ spec.homepage = 'https://github.com/YourCursus/perfect-scrollbar-rails'
16
+ spec.license = 'MIT'
17
+
18
+ spec.files = `git ls-files`.split($RS)
19
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
20
+ spec.require_paths = ['lib']
21
+
22
+ spec.add_dependency 'railties', '>= 3.2', '< 5.0'
23
+ spec.add_development_dependency 'bundler', '~> 1.3'
24
+ spec.add_development_dependency 'rake'
25
+ end
@@ -0,0 +1,1617 @@
1
+ /* perfect-scrollbar v0.6.8 */
2
+ (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
3
+ /* Copyright (c) 2015 Hyunje Alex Jun and other contributors
4
+ * Licensed under the MIT License
5
+ */
6
+ 'use strict';
7
+
8
+ var ps = require('../main')
9
+ , psInstances = require('../plugin/instances');
10
+
11
+ function mountJQuery(jQuery) {
12
+ jQuery.fn.perfectScrollbar = function (settingOrCommand) {
13
+ return this.each(function () {
14
+ if (typeof settingOrCommand === 'object' ||
15
+ typeof settingOrCommand === 'undefined') {
16
+ // If it's an object or none, initialize.
17
+ var settings = settingOrCommand;
18
+
19
+ if (!psInstances.get(this)) {
20
+ ps.initialize(this, settings);
21
+ }
22
+ } else {
23
+ // Unless, it may be a command.
24
+ var command = settingOrCommand;
25
+
26
+ if (command === 'update') {
27
+ ps.update(this);
28
+ } else if (command === 'destroy') {
29
+ ps.destroy(this);
30
+ }
31
+ }
32
+
33
+ return jQuery(this);
34
+ });
35
+ };
36
+ }
37
+
38
+ if (typeof define === 'function' && define.amd) {
39
+ // AMD. Register as an anonymous module.
40
+ define(['jquery'], mountJQuery);
41
+ } else {
42
+ var jq = window.jQuery ? window.jQuery : window.$;
43
+ if (typeof jq !== 'undefined') {
44
+ mountJQuery(jq);
45
+ }
46
+ }
47
+
48
+ module.exports = mountJQuery;
49
+
50
+ },{"../main":7,"../plugin/instances":18}],2:[function(require,module,exports){
51
+ /* Copyright (c) 2015 Hyunje Alex Jun and other contributors
52
+ * Licensed under the MIT License
53
+ */
54
+ 'use strict';
55
+
56
+ function oldAdd(element, className) {
57
+ var classes = element.className.split(' ');
58
+ if (classes.indexOf(className) < 0) {
59
+ classes.push(className);
60
+ }
61
+ element.className = classes.join(' ');
62
+ }
63
+
64
+ function oldRemove(element, className) {
65
+ var classes = element.className.split(' ');
66
+ var idx = classes.indexOf(className);
67
+ if (idx >= 0) {
68
+ classes.splice(idx, 1);
69
+ }
70
+ element.className = classes.join(' ');
71
+ }
72
+
73
+ exports.add = function (element, className) {
74
+ if (element.classList) {
75
+ element.classList.add(className);
76
+ } else {
77
+ oldAdd(element, className);
78
+ }
79
+ };
80
+
81
+ exports.remove = function (element, className) {
82
+ if (element.classList) {
83
+ element.classList.remove(className);
84
+ } else {
85
+ oldRemove(element, className);
86
+ }
87
+ };
88
+
89
+ exports.list = function (element) {
90
+ if (element.classList) {
91
+ return Array.prototype.slice.apply(element.classList);
92
+ } else {
93
+ return element.className.split(' ');
94
+ }
95
+ };
96
+
97
+ },{}],3:[function(require,module,exports){
98
+ /* Copyright (c) 2015 Hyunje Alex Jun and other contributors
99
+ * Licensed under the MIT License
100
+ */
101
+ 'use strict';
102
+
103
+ var DOM = {};
104
+
105
+ DOM.e = function (tagName, className) {
106
+ var element = document.createElement(tagName);
107
+ element.className = className;
108
+ return element;
109
+ };
110
+
111
+ DOM.appendTo = function (child, parent) {
112
+ parent.appendChild(child);
113
+ return child;
114
+ };
115
+
116
+ function cssGet(element, styleName) {
117
+ return window.getComputedStyle(element)[styleName];
118
+ }
119
+
120
+ function cssSet(element, styleName, styleValue) {
121
+ if (typeof styleValue === 'number') {
122
+ styleValue = styleValue.toString() + 'px';
123
+ }
124
+ element.style[styleName] = styleValue;
125
+ return element;
126
+ }
127
+
128
+ function cssMultiSet(element, obj) {
129
+ for (var key in obj) {
130
+ var val = obj[key];
131
+ if (typeof val === 'number') {
132
+ val = val.toString() + 'px';
133
+ }
134
+ element.style[key] = val;
135
+ }
136
+ return element;
137
+ }
138
+
139
+ DOM.css = function (element, styleNameOrObject, styleValue) {
140
+ if (typeof styleNameOrObject === 'object') {
141
+ // multiple set with object
142
+ return cssMultiSet(element, styleNameOrObject);
143
+ } else {
144
+ if (typeof styleValue === 'undefined') {
145
+ return cssGet(element, styleNameOrObject);
146
+ } else {
147
+ return cssSet(element, styleNameOrObject, styleValue);
148
+ }
149
+ }
150
+ };
151
+
152
+ DOM.matches = function (element, query) {
153
+ if (typeof element.matches !== 'undefined') {
154
+ return element.matches(query);
155
+ } else {
156
+ if (typeof element.matchesSelector !== 'undefined') {
157
+ return element.matchesSelector(query);
158
+ } else if (typeof element.webkitMatchesSelector !== 'undefined') {
159
+ return element.webkitMatchesSelector(query);
160
+ } else if (typeof element.mozMatchesSelector !== 'undefined') {
161
+ return element.mozMatchesSelector(query);
162
+ } else if (typeof element.msMatchesSelector !== 'undefined') {
163
+ return element.msMatchesSelector(query);
164
+ }
165
+ }
166
+ };
167
+
168
+ DOM.remove = function (element) {
169
+ if (typeof element.remove !== 'undefined') {
170
+ element.remove();
171
+ } else {
172
+ if (element.parentNode) {
173
+ element.parentNode.removeChild(element);
174
+ }
175
+ }
176
+ };
177
+
178
+ DOM.queryChildren = function (element, selector) {
179
+ return Array.prototype.filter.call(element.childNodes, function (child) {
180
+ return DOM.matches(child, selector);
181
+ });
182
+ };
183
+
184
+ module.exports = DOM;
185
+
186
+ },{}],4:[function(require,module,exports){
187
+ /* Copyright (c) 2015 Hyunje Alex Jun and other contributors
188
+ * Licensed under the MIT License
189
+ */
190
+ 'use strict';
191
+
192
+ var EventElement = function (element) {
193
+ this.element = element;
194
+ this.events = {};
195
+ };
196
+
197
+ EventElement.prototype.bind = function (eventName, handler) {
198
+ if (typeof this.events[eventName] === 'undefined') {
199
+ this.events[eventName] = [];
200
+ }
201
+ this.events[eventName].push(handler);
202
+ this.element.addEventListener(eventName, handler, false);
203
+ };
204
+
205
+ EventElement.prototype.unbind = function (eventName, handler) {
206
+ var isHandlerProvided = (typeof handler !== 'undefined');
207
+ this.events[eventName] = this.events[eventName].filter(function (hdlr) {
208
+ if (isHandlerProvided && hdlr !== handler) {
209
+ return true;
210
+ }
211
+ this.element.removeEventListener(eventName, hdlr, false);
212
+ return false;
213
+ }, this);
214
+ };
215
+
216
+ EventElement.prototype.unbindAll = function () {
217
+ for (var name in this.events) {
218
+ this.unbind(name);
219
+ }
220
+ };
221
+
222
+ var EventManager = function () {
223
+ this.eventElements = [];
224
+ };
225
+
226
+ EventManager.prototype.eventElement = function (element) {
227
+ var ee = this.eventElements.filter(function (eventElement) {
228
+ return eventElement.element === element;
229
+ })[0];
230
+ if (typeof ee === 'undefined') {
231
+ ee = new EventElement(element);
232
+ this.eventElements.push(ee);
233
+ }
234
+ return ee;
235
+ };
236
+
237
+ EventManager.prototype.bind = function (element, eventName, handler) {
238
+ this.eventElement(element).bind(eventName, handler);
239
+ };
240
+
241
+ EventManager.prototype.unbind = function (element, eventName, handler) {
242
+ this.eventElement(element).unbind(eventName, handler);
243
+ };
244
+
245
+ EventManager.prototype.unbindAll = function () {
246
+ for (var i = 0; i < this.eventElements.length; i++) {
247
+ this.eventElements[i].unbindAll();
248
+ }
249
+ };
250
+
251
+ EventManager.prototype.once = function (element, eventName, handler) {
252
+ var ee = this.eventElement(element);
253
+ var onceHandler = function (e) {
254
+ ee.unbind(eventName, onceHandler);
255
+ handler(e);
256
+ };
257
+ ee.bind(eventName, onceHandler);
258
+ };
259
+
260
+ module.exports = EventManager;
261
+
262
+ },{}],5:[function(require,module,exports){
263
+ /* Copyright (c) 2015 Hyunje Alex Jun and other contributors
264
+ * Licensed under the MIT License
265
+ */
266
+ 'use strict';
267
+
268
+ module.exports = (function () {
269
+ function s4() {
270
+ return Math.floor((1 + Math.random()) * 0x10000)
271
+ .toString(16)
272
+ .substring(1);
273
+ }
274
+ return function () {
275
+ return s4() + s4() + '-' + s4() + '-' + s4() + '-' +
276
+ s4() + '-' + s4() + s4() + s4();
277
+ };
278
+ })();
279
+
280
+ },{}],6:[function(require,module,exports){
281
+ /* Copyright (c) 2015 Hyunje Alex Jun and other contributors
282
+ * Licensed under the MIT License
283
+ */
284
+ 'use strict';
285
+
286
+ var cls = require('./class')
287
+ , d = require('./dom');
288
+
289
+ exports.toInt = function (x) {
290
+ return parseInt(x, 10) || 0;
291
+ };
292
+
293
+ exports.clone = function (obj) {
294
+ if (obj === null) {
295
+ return null;
296
+ } else if (typeof obj === 'object') {
297
+ var result = {};
298
+ for (var key in obj) {
299
+ result[key] = this.clone(obj[key]);
300
+ }
301
+ return result;
302
+ } else {
303
+ return obj;
304
+ }
305
+ };
306
+
307
+ exports.extend = function (original, source) {
308
+ var result = this.clone(original);
309
+ for (var key in source) {
310
+ result[key] = this.clone(source[key]);
311
+ }
312
+ return result;
313
+ };
314
+
315
+ exports.isEditable = function (el) {
316
+ return d.matches(el, "input,[contenteditable]") ||
317
+ d.matches(el, "select,[contenteditable]") ||
318
+ d.matches(el, "textarea,[contenteditable]") ||
319
+ d.matches(el, "button,[contenteditable]");
320
+ };
321
+
322
+ exports.removePsClasses = function (element) {
323
+ var clsList = cls.list(element);
324
+ for (var i = 0; i < clsList.length; i++) {
325
+ var className = clsList[i];
326
+ if (className.indexOf('ps-') === 0) {
327
+ cls.remove(element, className);
328
+ }
329
+ }
330
+ };
331
+
332
+ exports.outerWidth = function (element) {
333
+ return this.toInt(d.css(element, 'width')) +
334
+ this.toInt(d.css(element, 'paddingLeft')) +
335
+ this.toInt(d.css(element, 'paddingRight')) +
336
+ this.toInt(d.css(element, 'borderLeftWidth')) +
337
+ this.toInt(d.css(element, 'borderRightWidth'));
338
+ };
339
+
340
+ exports.startScrolling = function (element, axis) {
341
+ cls.add(element, 'ps-in-scrolling');
342
+ if (typeof axis !== 'undefined') {
343
+ cls.add(element, 'ps-' + axis);
344
+ } else {
345
+ cls.add(element, 'ps-x');
346
+ cls.add(element, 'ps-y');
347
+ }
348
+ };
349
+
350
+ exports.stopScrolling = function (element, axis) {
351
+ cls.remove(element, 'ps-in-scrolling');
352
+ if (typeof axis !== 'undefined') {
353
+ cls.remove(element, 'ps-' + axis);
354
+ } else {
355
+ cls.remove(element, 'ps-x');
356
+ cls.remove(element, 'ps-y');
357
+ }
358
+ };
359
+
360
+ exports.env = {
361
+ isWebKit: 'WebkitAppearance' in document.documentElement.style,
362
+ supportsTouch: (('ontouchstart' in window) || window.DocumentTouch && document instanceof window.DocumentTouch),
363
+ supportsIePointer: window.navigator.msMaxTouchPoints !== null
364
+ };
365
+
366
+ },{"./class":2,"./dom":3}],7:[function(require,module,exports){
367
+ /* Copyright (c) 2015 Hyunje Alex Jun and other contributors
368
+ * Licensed under the MIT License
369
+ */
370
+ 'use strict';
371
+
372
+ var destroy = require('./plugin/destroy')
373
+ , initialize = require('./plugin/initialize')
374
+ , update = require('./plugin/update');
375
+
376
+ module.exports = {
377
+ initialize: initialize,
378
+ update: update,
379
+ destroy: destroy
380
+ };
381
+
382
+ },{"./plugin/destroy":9,"./plugin/initialize":17,"./plugin/update":21}],8:[function(require,module,exports){
383
+ /* Copyright (c) 2015 Hyunje Alex Jun and other contributors
384
+ * Licensed under the MIT License
385
+ */
386
+ 'use strict';
387
+
388
+ module.exports = {
389
+ maxScrollbarLength: null,
390
+ minScrollbarLength: null,
391
+ scrollXMarginOffset: 0,
392
+ scrollYMarginOffset: 0,
393
+ stopPropagationOnClick: true,
394
+ suppressScrollX: false,
395
+ suppressScrollY: false,
396
+ swipePropagation: true,
397
+ useBothWheelAxes: false,
398
+ useKeyboard: true,
399
+ useSelectionScroll: false,
400
+ wheelPropagation: false,
401
+ wheelSpeed: 1
402
+ };
403
+
404
+ },{}],9:[function(require,module,exports){
405
+ /* Copyright (c) 2015 Hyunje Alex Jun and other contributors
406
+ * Licensed under the MIT License
407
+ */
408
+ 'use strict';
409
+
410
+ var d = require('../lib/dom')
411
+ , h = require('../lib/helper')
412
+ , instances = require('./instances');
413
+
414
+ module.exports = function (element) {
415
+ var i = instances.get(element);
416
+
417
+ if (!i) {
418
+ return;
419
+ }
420
+
421
+ i.event.unbindAll();
422
+ d.remove(i.scrollbarX);
423
+ d.remove(i.scrollbarY);
424
+ d.remove(i.scrollbarXRail);
425
+ d.remove(i.scrollbarYRail);
426
+ h.removePsClasses(element);
427
+
428
+ instances.remove(element);
429
+ };
430
+
431
+ },{"../lib/dom":3,"../lib/helper":6,"./instances":18}],10:[function(require,module,exports){
432
+ /* Copyright (c) 2015 Hyunje Alex Jun and other contributors
433
+ * Licensed under the MIT License
434
+ */
435
+ 'use strict';
436
+
437
+ var h = require('../../lib/helper')
438
+ , instances = require('../instances')
439
+ , updateGeometry = require('../update-geometry')
440
+ , updateScroll = require('../update-scroll');
441
+
442
+ function bindClickRailHandler(element, i) {
443
+ function pageOffset(el) {
444
+ return el.getBoundingClientRect();
445
+ }
446
+ var stopPropagation = window.Event.prototype.stopPropagation.bind;
447
+
448
+ if (i.settings.stopPropagationOnClick) {
449
+ i.event.bind(i.scrollbarY, 'click', stopPropagation);
450
+ }
451
+ i.event.bind(i.scrollbarYRail, 'click', function (e) {
452
+ var halfOfScrollbarLength = h.toInt(i.scrollbarYHeight / 2);
453
+ var positionTop = i.railYRatio * (e.pageY - window.pageYOffset - pageOffset(i.scrollbarYRail).top - halfOfScrollbarLength);
454
+ var maxPositionTop = i.railYRatio * (i.railYHeight - i.scrollbarYHeight);
455
+ var positionRatio = positionTop / maxPositionTop;
456
+
457
+ if (positionRatio < 0) {
458
+ positionRatio = 0;
459
+ } else if (positionRatio > 1) {
460
+ positionRatio = 1;
461
+ }
462
+
463
+ updateScroll(element, 'top', (i.contentHeight - i.containerHeight) * positionRatio);
464
+ updateGeometry(element);
465
+
466
+ e.stopPropagation();
467
+ });
468
+
469
+ if (i.settings.stopPropagationOnClick) {
470
+ i.event.bind(i.scrollbarX, 'click', stopPropagation);
471
+ }
472
+ i.event.bind(i.scrollbarXRail, 'click', function (e) {
473
+ var halfOfScrollbarLength = h.toInt(i.scrollbarXWidth / 2);
474
+ var positionLeft = i.railXRatio * (e.pageX - window.pageXOffset - pageOffset(i.scrollbarXRail).left - halfOfScrollbarLength);
475
+ var maxPositionLeft = i.railXRatio * (i.railXWidth - i.scrollbarXWidth);
476
+ var positionRatio = positionLeft / maxPositionLeft;
477
+
478
+ if (positionRatio < 0) {
479
+ positionRatio = 0;
480
+ } else if (positionRatio > 1) {
481
+ positionRatio = 1;
482
+ }
483
+
484
+ updateScroll(element, 'left', ((i.contentWidth - i.containerWidth) * positionRatio) - i.negativeScrollAdjustment);
485
+ updateGeometry(element);
486
+
487
+ e.stopPropagation();
488
+ });
489
+ }
490
+
491
+ module.exports = function (element) {
492
+ var i = instances.get(element);
493
+ bindClickRailHandler(element, i);
494
+ };
495
+
496
+ },{"../../lib/helper":6,"../instances":18,"../update-geometry":19,"../update-scroll":20}],11:[function(require,module,exports){
497
+ /* Copyright (c) 2015 Hyunje Alex Jun and other contributors
498
+ * Licensed under the MIT License
499
+ */
500
+ 'use strict';
501
+
502
+ var d = require('../../lib/dom')
503
+ , h = require('../../lib/helper')
504
+ , instances = require('../instances')
505
+ , updateGeometry = require('../update-geometry')
506
+ , updateScroll = require('../update-scroll');
507
+
508
+ function bindMouseScrollXHandler(element, i) {
509
+ var currentLeft = null;
510
+ var currentPageX = null;
511
+
512
+ function updateScrollLeft(deltaX) {
513
+ var newLeft = currentLeft + (deltaX * i.railXRatio);
514
+ var maxLeft = Math.max(0, i.scrollbarXRail.getBoundingClientRect().left) + (i.railXRatio * (i.railXWidth - i.scrollbarXWidth));
515
+
516
+ if (newLeft < 0) {
517
+ i.scrollbarXLeft = 0;
518
+ } else if (newLeft > maxLeft) {
519
+ i.scrollbarXLeft = maxLeft;
520
+ } else {
521
+ i.scrollbarXLeft = newLeft;
522
+ }
523
+
524
+ var scrollLeft = h.toInt(i.scrollbarXLeft * (i.contentWidth - i.containerWidth) / (i.containerWidth - (i.railXRatio * i.scrollbarXWidth))) - i.negativeScrollAdjustment;
525
+ updateScroll(element, 'left', scrollLeft);
526
+ }
527
+
528
+ var mouseMoveHandler = function (e) {
529
+ updateScrollLeft(e.pageX - currentPageX);
530
+ updateGeometry(element);
531
+ e.stopPropagation();
532
+ e.preventDefault();
533
+ };
534
+
535
+ var mouseUpHandler = function () {
536
+ h.stopScrolling(element, 'x');
537
+ i.event.unbind(i.ownerDocument, 'mousemove', mouseMoveHandler);
538
+ };
539
+
540
+ i.event.bind(i.scrollbarX, 'mousedown', function (e) {
541
+ currentPageX = e.pageX;
542
+ currentLeft = h.toInt(d.css(i.scrollbarX, 'left')) * i.railXRatio;
543
+ h.startScrolling(element, 'x');
544
+
545
+ i.event.bind(i.ownerDocument, 'mousemove', mouseMoveHandler);
546
+ i.event.once(i.ownerDocument, 'mouseup', mouseUpHandler);
547
+
548
+ e.stopPropagation();
549
+ e.preventDefault();
550
+ });
551
+ }
552
+
553
+ function bindMouseScrollYHandler(element, i) {
554
+ var currentTop = null;
555
+ var currentPageY = null;
556
+
557
+ function updateScrollTop(deltaY) {
558
+ var newTop = currentTop + (deltaY * i.railYRatio);
559
+ var maxTop = Math.max(0, i.scrollbarYRail.getBoundingClientRect().top) + (i.railYRatio * (i.railYHeight - i.scrollbarYHeight));
560
+
561
+ if (newTop < 0) {
562
+ i.scrollbarYTop = 0;
563
+ } else if (newTop > maxTop) {
564
+ i.scrollbarYTop = maxTop;
565
+ } else {
566
+ i.scrollbarYTop = newTop;
567
+ }
568
+
569
+ var scrollTop = h.toInt(i.scrollbarYTop * (i.contentHeight - i.containerHeight) / (i.containerHeight - (i.railYRatio * i.scrollbarYHeight)));
570
+ updateScroll(element, 'top', scrollTop);
571
+ }
572
+
573
+ var mouseMoveHandler = function (e) {
574
+ updateScrollTop(e.pageY - currentPageY);
575
+ updateGeometry(element);
576
+ e.stopPropagation();
577
+ e.preventDefault();
578
+ };
579
+
580
+ var mouseUpHandler = function () {
581
+ h.stopScrolling(element, 'y');
582
+ i.event.unbind(i.ownerDocument, 'mousemove', mouseMoveHandler);
583
+ };
584
+
585
+ i.event.bind(i.scrollbarY, 'mousedown', function (e) {
586
+ currentPageY = e.pageY;
587
+ currentTop = h.toInt(d.css(i.scrollbarY, 'top')) * i.railYRatio;
588
+ h.startScrolling(element, 'y');
589
+
590
+ i.event.bind(i.ownerDocument, 'mousemove', mouseMoveHandler);
591
+ i.event.once(i.ownerDocument, 'mouseup', mouseUpHandler);
592
+
593
+ e.stopPropagation();
594
+ e.preventDefault();
595
+ });
596
+ }
597
+
598
+ module.exports = function (element) {
599
+ var i = instances.get(element);
600
+ bindMouseScrollXHandler(element, i);
601
+ bindMouseScrollYHandler(element, i);
602
+ };
603
+
604
+ },{"../../lib/dom":3,"../../lib/helper":6,"../instances":18,"../update-geometry":19,"../update-scroll":20}],12:[function(require,module,exports){
605
+ /* Copyright (c) 2015 Hyunje Alex Jun and other contributors
606
+ * Licensed under the MIT License
607
+ */
608
+ 'use strict';
609
+
610
+ var h = require('../../lib/helper')
611
+ , instances = require('../instances')
612
+ , updateGeometry = require('../update-geometry')
613
+ , updateScroll = require('../update-scroll');
614
+
615
+ function bindKeyboardHandler(element, i) {
616
+ var hovered = false;
617
+ i.event.bind(element, 'mouseenter', function () {
618
+ hovered = true;
619
+ });
620
+ i.event.bind(element, 'mouseleave', function () {
621
+ hovered = false;
622
+ });
623
+
624
+ var shouldPrevent = false;
625
+ function shouldPreventDefault(deltaX, deltaY) {
626
+ var scrollTop = element.scrollTop;
627
+ if (deltaX === 0) {
628
+ if (!i.scrollbarYActive) {
629
+ return false;
630
+ }
631
+ if ((scrollTop === 0 && deltaY > 0) || (scrollTop >= i.contentHeight - i.containerHeight && deltaY < 0)) {
632
+ return !i.settings.wheelPropagation;
633
+ }
634
+ }
635
+
636
+ var scrollLeft = element.scrollLeft;
637
+ if (deltaY === 0) {
638
+ if (!i.scrollbarXActive) {
639
+ return false;
640
+ }
641
+ if ((scrollLeft === 0 && deltaX < 0) || (scrollLeft >= i.contentWidth - i.containerWidth && deltaX > 0)) {
642
+ return !i.settings.wheelPropagation;
643
+ }
644
+ }
645
+ return true;
646
+ }
647
+
648
+ i.event.bind(i.ownerDocument, 'keydown', function (e) {
649
+ if (e.isDefaultPrevented && e.isDefaultPrevented()) {
650
+ return;
651
+ }
652
+
653
+ if (!hovered) {
654
+ return;
655
+ }
656
+
657
+ var activeElement = document.activeElement ? document.activeElement : i.ownerDocument.activeElement;
658
+ if (activeElement) {
659
+ // go deeper if element is a webcomponent
660
+ while (activeElement.shadowRoot) {
661
+ activeElement = activeElement.shadowRoot.activeElement;
662
+ }
663
+ if (h.isEditable(activeElement)) {
664
+ return;
665
+ }
666
+ }
667
+
668
+ var deltaX = 0;
669
+ var deltaY = 0;
670
+
671
+ switch (e.which) {
672
+ case 37: // left
673
+ deltaX = -30;
674
+ break;
675
+ case 38: // up
676
+ deltaY = 30;
677
+ break;
678
+ case 39: // right
679
+ deltaX = 30;
680
+ break;
681
+ case 40: // down
682
+ deltaY = -30;
683
+ break;
684
+ case 33: // page up
685
+ deltaY = 90;
686
+ break;
687
+ case 32: // space bar
688
+ if (e.shiftKey) {
689
+ deltaY = 90;
690
+ } else {
691
+ deltaY = -90;
692
+ }
693
+ break;
694
+ case 34: // page down
695
+ deltaY = -90;
696
+ break;
697
+ case 35: // end
698
+ if (e.ctrlKey) {
699
+ deltaY = -i.contentHeight;
700
+ } else {
701
+ deltaY = -i.containerHeight;
702
+ }
703
+ break;
704
+ case 36: // home
705
+ if (e.ctrlKey) {
706
+ deltaY = element.scrollTop;
707
+ } else {
708
+ deltaY = i.containerHeight;
709
+ }
710
+ break;
711
+ default:
712
+ return;
713
+ }
714
+
715
+ updateScroll(element, 'top', element.scrollTop - deltaY);
716
+ updateScroll(element, 'left', element.scrollLeft + deltaX);
717
+ updateGeometry(element);
718
+
719
+ shouldPrevent = shouldPreventDefault(deltaX, deltaY);
720
+ if (shouldPrevent) {
721
+ e.preventDefault();
722
+ }
723
+ });
724
+ }
725
+
726
+ module.exports = function (element) {
727
+ var i = instances.get(element);
728
+ bindKeyboardHandler(element, i);
729
+ };
730
+
731
+ },{"../../lib/helper":6,"../instances":18,"../update-geometry":19,"../update-scroll":20}],13:[function(require,module,exports){
732
+ /* Copyright (c) 2015 Hyunje Alex Jun and other contributors
733
+ * Licensed under the MIT License
734
+ */
735
+ 'use strict';
736
+
737
+ var instances = require('../instances')
738
+ , updateGeometry = require('../update-geometry')
739
+ , updateScroll = require('../update-scroll');
740
+
741
+ function bindMouseWheelHandler(element, i) {
742
+ var shouldPrevent = false;
743
+
744
+ function shouldPreventDefault(deltaX, deltaY) {
745
+ var scrollTop = element.scrollTop;
746
+ if (deltaX === 0) {
747
+ if (!i.scrollbarYActive) {
748
+ return false;
749
+ }
750
+ if ((scrollTop === 0 && deltaY > 0) || (scrollTop >= i.contentHeight - i.containerHeight && deltaY < 0)) {
751
+ return !i.settings.wheelPropagation;
752
+ }
753
+ }
754
+
755
+ var scrollLeft = element.scrollLeft;
756
+ if (deltaY === 0) {
757
+ if (!i.scrollbarXActive) {
758
+ return false;
759
+ }
760
+ if ((scrollLeft === 0 && deltaX < 0) || (scrollLeft >= i.contentWidth - i.containerWidth && deltaX > 0)) {
761
+ return !i.settings.wheelPropagation;
762
+ }
763
+ }
764
+ return true;
765
+ }
766
+
767
+ function getDeltaFromEvent(e) {
768
+ var deltaX = e.deltaX;
769
+ var deltaY = -1 * e.deltaY;
770
+
771
+ if (typeof deltaX === "undefined" || typeof deltaY === "undefined") {
772
+ // OS X Safari
773
+ deltaX = -1 * e.wheelDeltaX / 6;
774
+ deltaY = e.wheelDeltaY / 6;
775
+ }
776
+
777
+ if (e.deltaMode && e.deltaMode === 1) {
778
+ // Firefox in deltaMode 1: Line scrolling
779
+ deltaX *= 10;
780
+ deltaY *= 10;
781
+ }
782
+
783
+ if (deltaX !== deltaX && deltaY !== deltaY/* NaN checks */) {
784
+ // IE in some mouse drivers
785
+ deltaX = 0;
786
+ deltaY = e.wheelDelta;
787
+ }
788
+
789
+ return [deltaX, deltaY];
790
+ }
791
+
792
+ function shouldBeConsumedByTextarea(deltaX, deltaY) {
793
+ var hoveredTextarea = element.querySelector('textarea:hover');
794
+ if (hoveredTextarea) {
795
+ var maxScrollTop = hoveredTextarea.scrollHeight - hoveredTextarea.clientHeight;
796
+ if (maxScrollTop > 0) {
797
+ if (!(hoveredTextarea.scrollTop === 0 && deltaY > 0) &&
798
+ !(hoveredTextarea.scrollTop === maxScrollTop && deltaY < 0)) {
799
+ return true;
800
+ }
801
+ }
802
+ var maxScrollLeft = hoveredTextarea.scrollLeft - hoveredTextarea.clientWidth;
803
+ if (maxScrollLeft > 0) {
804
+ if (!(hoveredTextarea.scrollLeft === 0 && deltaX < 0) &&
805
+ !(hoveredTextarea.scrollLeft === maxScrollLeft && deltaX > 0)) {
806
+ return true;
807
+ }
808
+ }
809
+ }
810
+ return false;
811
+ }
812
+
813
+ function mousewheelHandler(e) {
814
+ var delta = getDeltaFromEvent(e);
815
+
816
+ var deltaX = delta[0];
817
+ var deltaY = delta[1];
818
+
819
+ if (shouldBeConsumedByTextarea(deltaX, deltaY)) {
820
+ return;
821
+ }
822
+
823
+ shouldPrevent = false;
824
+ if (!i.settings.useBothWheelAxes) {
825
+ // deltaX will only be used for horizontal scrolling and deltaY will
826
+ // only be used for vertical scrolling - this is the default
827
+ updateScroll(element, 'top', element.scrollTop - (deltaY * i.settings.wheelSpeed));
828
+ updateScroll(element, 'left', element.scrollLeft + (deltaX * i.settings.wheelSpeed));
829
+ } else if (i.scrollbarYActive && !i.scrollbarXActive) {
830
+ // only vertical scrollbar is active and useBothWheelAxes option is
831
+ // active, so let's scroll vertical bar using both mouse wheel axes
832
+ if (deltaY) {
833
+ updateScroll(element, 'top', element.scrollTop - (deltaY * i.settings.wheelSpeed));
834
+ } else {
835
+ updateScroll(element, 'top', element.scrollTop + (deltaX * i.settings.wheelSpeed));
836
+ }
837
+ shouldPrevent = true;
838
+ } else if (i.scrollbarXActive && !i.scrollbarYActive) {
839
+ // useBothWheelAxes and only horizontal bar is active, so use both
840
+ // wheel axes for horizontal bar
841
+ if (deltaX) {
842
+ updateScroll(element, 'left', element.scrollLeft + (deltaX * i.settings.wheelSpeed));
843
+ } else {
844
+ updateScroll(element, 'left', element.scrollLeft - (deltaY * i.settings.wheelSpeed));
845
+ }
846
+ shouldPrevent = true;
847
+ }
848
+
849
+ updateGeometry(element);
850
+
851
+ shouldPrevent = (shouldPrevent || shouldPreventDefault(deltaX, deltaY));
852
+ if (shouldPrevent) {
853
+ e.stopPropagation();
854
+ e.preventDefault();
855
+ }
856
+ }
857
+
858
+ if (typeof window.onwheel !== "undefined") {
859
+ i.event.bind(element, 'wheel', mousewheelHandler);
860
+ } else if (typeof window.onmousewheel !== "undefined") {
861
+ i.event.bind(element, 'mousewheel', mousewheelHandler);
862
+ }
863
+ }
864
+
865
+ module.exports = function (element) {
866
+ var i = instances.get(element);
867
+ bindMouseWheelHandler(element, i);
868
+ };
869
+
870
+ },{"../instances":18,"../update-geometry":19,"../update-scroll":20}],14:[function(require,module,exports){
871
+ /* Copyright (c) 2015 Hyunje Alex Jun and other contributors
872
+ * Licensed under the MIT License
873
+ */
874
+ 'use strict';
875
+
876
+ var instances = require('../instances')
877
+ , updateGeometry = require('../update-geometry');
878
+
879
+ function bindNativeScrollHandler(element, i) {
880
+ i.event.bind(element, 'scroll', function () {
881
+ updateGeometry(element);
882
+ });
883
+ }
884
+
885
+ module.exports = function (element) {
886
+ var i = instances.get(element);
887
+ bindNativeScrollHandler(element, i);
888
+ };
889
+
890
+ },{"../instances":18,"../update-geometry":19}],15:[function(require,module,exports){
891
+ /* Copyright (c) 2015 Hyunje Alex Jun and other contributors
892
+ * Licensed under the MIT License
893
+ */
894
+ 'use strict';
895
+
896
+ var h = require('../../lib/helper')
897
+ , instances = require('../instances')
898
+ , updateGeometry = require('../update-geometry')
899
+ , updateScroll = require('../update-scroll');
900
+
901
+ function bindSelectionHandler(element, i) {
902
+ function getRangeNode() {
903
+ var selection = window.getSelection ? window.getSelection() :
904
+ document.getSelection ? document.getSelection() : '';
905
+ if (selection.toString().length === 0) {
906
+ return null;
907
+ } else {
908
+ return selection.getRangeAt(0).commonAncestorContainer;
909
+ }
910
+ }
911
+
912
+ var scrollingLoop = null;
913
+ var scrollDiff = {top: 0, left: 0};
914
+ function startScrolling() {
915
+ if (!scrollingLoop) {
916
+ scrollingLoop = setInterval(function () {
917
+ if (!instances.get(element)) {
918
+ clearInterval(scrollingLoop);
919
+ return;
920
+ }
921
+
922
+ updateScroll(element, 'top', element.scrollTop + scrollDiff.top);
923
+ updateScroll(element, 'left', element.scrollLeft + scrollDiff.left);
924
+ updateGeometry(element);
925
+ }, 50); // every .1 sec
926
+ }
927
+ }
928
+ function stopScrolling() {
929
+ if (scrollingLoop) {
930
+ clearInterval(scrollingLoop);
931
+ scrollingLoop = null;
932
+ }
933
+ h.stopScrolling(element);
934
+ }
935
+
936
+ var isSelected = false;
937
+ i.event.bind(i.ownerDocument, 'selectionchange', function () {
938
+ if (element.contains(getRangeNode())) {
939
+ isSelected = true;
940
+ } else {
941
+ isSelected = false;
942
+ stopScrolling();
943
+ }
944
+ });
945
+ i.event.bind(window, 'mouseup', function () {
946
+ if (isSelected) {
947
+ isSelected = false;
948
+ stopScrolling();
949
+ }
950
+ });
951
+
952
+ i.event.bind(window, 'mousemove', function (e) {
953
+ if (isSelected) {
954
+ var mousePosition = {x: e.pageX, y: e.pageY};
955
+ var containerGeometry = {
956
+ left: element.offsetLeft,
957
+ right: element.offsetLeft + element.offsetWidth,
958
+ top: element.offsetTop,
959
+ bottom: element.offsetTop + element.offsetHeight
960
+ };
961
+
962
+ if (mousePosition.x < containerGeometry.left + 3) {
963
+ scrollDiff.left = -5;
964
+ h.startScrolling(element, 'x');
965
+ } else if (mousePosition.x > containerGeometry.right - 3) {
966
+ scrollDiff.left = 5;
967
+ h.startScrolling(element, 'x');
968
+ } else {
969
+ scrollDiff.left = 0;
970
+ }
971
+
972
+ if (mousePosition.y < containerGeometry.top + 3) {
973
+ if (containerGeometry.top + 3 - mousePosition.y < 5) {
974
+ scrollDiff.top = -5;
975
+ } else {
976
+ scrollDiff.top = -20;
977
+ }
978
+ h.startScrolling(element, 'y');
979
+ } else if (mousePosition.y > containerGeometry.bottom - 3) {
980
+ if (mousePosition.y - containerGeometry.bottom + 3 < 5) {
981
+ scrollDiff.top = 5;
982
+ } else {
983
+ scrollDiff.top = 20;
984
+ }
985
+ h.startScrolling(element, 'y');
986
+ } else {
987
+ scrollDiff.top = 0;
988
+ }
989
+
990
+ if (scrollDiff.top === 0 && scrollDiff.left === 0) {
991
+ stopScrolling();
992
+ } else {
993
+ startScrolling();
994
+ }
995
+ }
996
+ });
997
+ }
998
+
999
+ module.exports = function (element) {
1000
+ var i = instances.get(element);
1001
+ bindSelectionHandler(element, i);
1002
+ };
1003
+
1004
+ },{"../../lib/helper":6,"../instances":18,"../update-geometry":19,"../update-scroll":20}],16:[function(require,module,exports){
1005
+ /* Copyright (c) 2015 Hyunje Alex Jun and other contributors
1006
+ * Licensed under the MIT License
1007
+ */
1008
+ 'use strict';
1009
+
1010
+ var instances = require('../instances')
1011
+ , updateGeometry = require('../update-geometry')
1012
+ , updateScroll = require('../update-scroll');
1013
+
1014
+ function bindTouchHandler(element, i, supportsTouch, supportsIePointer) {
1015
+ function shouldPreventDefault(deltaX, deltaY) {
1016
+ var scrollTop = element.scrollTop;
1017
+ var scrollLeft = element.scrollLeft;
1018
+ var magnitudeX = Math.abs(deltaX);
1019
+ var magnitudeY = Math.abs(deltaY);
1020
+
1021
+ if (magnitudeY > magnitudeX) {
1022
+ // user is perhaps trying to swipe up/down the page
1023
+
1024
+ if (((deltaY < 0) && (scrollTop === i.contentHeight - i.containerHeight)) ||
1025
+ ((deltaY > 0) && (scrollTop === 0))) {
1026
+ return !i.settings.swipePropagation;
1027
+ }
1028
+ } else if (magnitudeX > magnitudeY) {
1029
+ // user is perhaps trying to swipe left/right across the page
1030
+
1031
+ if (((deltaX < 0) && (scrollLeft === i.contentWidth - i.containerWidth)) ||
1032
+ ((deltaX > 0) && (scrollLeft === 0))) {
1033
+ return !i.settings.swipePropagation;
1034
+ }
1035
+ }
1036
+
1037
+ return true;
1038
+ }
1039
+
1040
+ function applyTouchMove(differenceX, differenceY) {
1041
+ updateScroll(element, 'top', element.scrollTop - differenceY);
1042
+ updateScroll(element, 'left', element.scrollLeft - differenceX);
1043
+
1044
+ updateGeometry(element);
1045
+ }
1046
+
1047
+ var startOffset = {};
1048
+ var startTime = 0;
1049
+ var speed = {};
1050
+ var easingLoop = null;
1051
+ var inGlobalTouch = false;
1052
+ var inLocalTouch = false;
1053
+
1054
+ function globalTouchStart() {
1055
+ inGlobalTouch = true;
1056
+ }
1057
+ function globalTouchEnd() {
1058
+ inGlobalTouch = false;
1059
+ }
1060
+
1061
+ function getTouch(e) {
1062
+ if (e.targetTouches) {
1063
+ return e.targetTouches[0];
1064
+ } else {
1065
+ // Maybe IE pointer
1066
+ return e;
1067
+ }
1068
+ }
1069
+ function shouldHandle(e) {
1070
+ if (e.targetTouches && e.targetTouches.length === 1) {
1071
+ return true;
1072
+ }
1073
+ if (e.pointerType && e.pointerType !== 'mouse' && e.pointerType !== e.MSPOINTER_TYPE_MOUSE) {
1074
+ return true;
1075
+ }
1076
+ return false;
1077
+ }
1078
+ function touchStart(e) {
1079
+ if (shouldHandle(e)) {
1080
+ inLocalTouch = true;
1081
+
1082
+ var touch = getTouch(e);
1083
+
1084
+ startOffset.pageX = touch.pageX;
1085
+ startOffset.pageY = touch.pageY;
1086
+
1087
+ startTime = (new Date()).getTime();
1088
+
1089
+ if (easingLoop !== null) {
1090
+ clearInterval(easingLoop);
1091
+ }
1092
+
1093
+ e.stopPropagation();
1094
+ }
1095
+ }
1096
+ function touchMove(e) {
1097
+ if (!inGlobalTouch && inLocalTouch && shouldHandle(e)) {
1098
+ var touch = getTouch(e);
1099
+
1100
+ var currentOffset = {pageX: touch.pageX, pageY: touch.pageY};
1101
+
1102
+ var differenceX = currentOffset.pageX - startOffset.pageX;
1103
+ var differenceY = currentOffset.pageY - startOffset.pageY;
1104
+
1105
+ applyTouchMove(differenceX, differenceY);
1106
+ startOffset = currentOffset;
1107
+
1108
+ var currentTime = (new Date()).getTime();
1109
+
1110
+ var timeGap = currentTime - startTime;
1111
+ if (timeGap > 0) {
1112
+ speed.x = differenceX / timeGap;
1113
+ speed.y = differenceY / timeGap;
1114
+ startTime = currentTime;
1115
+ }
1116
+
1117
+ if (shouldPreventDefault(differenceX, differenceY)) {
1118
+ e.stopPropagation();
1119
+ e.preventDefault();
1120
+ }
1121
+ }
1122
+ }
1123
+ function touchEnd() {
1124
+ if (!inGlobalTouch && inLocalTouch) {
1125
+ inLocalTouch = false;
1126
+
1127
+ clearInterval(easingLoop);
1128
+ easingLoop = setInterval(function () {
1129
+ if (!instances.get(element)) {
1130
+ clearInterval(easingLoop);
1131
+ return;
1132
+ }
1133
+
1134
+ if (Math.abs(speed.x) < 0.01 && Math.abs(speed.y) < 0.01) {
1135
+ clearInterval(easingLoop);
1136
+ return;
1137
+ }
1138
+
1139
+ applyTouchMove(speed.x * 30, speed.y * 30);
1140
+
1141
+ speed.x *= 0.8;
1142
+ speed.y *= 0.8;
1143
+ }, 10);
1144
+ }
1145
+ }
1146
+
1147
+ if (supportsTouch) {
1148
+ i.event.bind(window, 'touchstart', globalTouchStart);
1149
+ i.event.bind(window, 'touchend', globalTouchEnd);
1150
+ i.event.bind(element, 'touchstart', touchStart);
1151
+ i.event.bind(element, 'touchmove', touchMove);
1152
+ i.event.bind(element, 'touchend', touchEnd);
1153
+ }
1154
+
1155
+ if (supportsIePointer) {
1156
+ if (window.PointerEvent) {
1157
+ i.event.bind(window, 'pointerdown', globalTouchStart);
1158
+ i.event.bind(window, 'pointerup', globalTouchEnd);
1159
+ i.event.bind(element, 'pointerdown', touchStart);
1160
+ i.event.bind(element, 'pointermove', touchMove);
1161
+ i.event.bind(element, 'pointerup', touchEnd);
1162
+ } else if (window.MSPointerEvent) {
1163
+ i.event.bind(window, 'MSPointerDown', globalTouchStart);
1164
+ i.event.bind(window, 'MSPointerUp', globalTouchEnd);
1165
+ i.event.bind(element, 'MSPointerDown', touchStart);
1166
+ i.event.bind(element, 'MSPointerMove', touchMove);
1167
+ i.event.bind(element, 'MSPointerUp', touchEnd);
1168
+ }
1169
+ }
1170
+ }
1171
+
1172
+ module.exports = function (element, supportsTouch, supportsIePointer) {
1173
+ var i = instances.get(element);
1174
+ bindTouchHandler(element, i, supportsTouch, supportsIePointer);
1175
+ };
1176
+
1177
+ },{"../instances":18,"../update-geometry":19,"../update-scroll":20}],17:[function(require,module,exports){
1178
+ /* Copyright (c) 2015 Hyunje Alex Jun and other contributors
1179
+ * Licensed under the MIT License
1180
+ */
1181
+ 'use strict';
1182
+
1183
+ var cls = require('../lib/class')
1184
+ , h = require('../lib/helper')
1185
+ , instances = require('./instances')
1186
+ , updateGeometry = require('./update-geometry');
1187
+
1188
+ // Handlers
1189
+ var clickRailHandler = require('./handler/click-rail')
1190
+ , dragScrollbarHandler = require('./handler/drag-scrollbar')
1191
+ , keyboardHandler = require('./handler/keyboard')
1192
+ , mouseWheelHandler = require('./handler/mouse-wheel')
1193
+ , nativeScrollHandler = require('./handler/native-scroll')
1194
+ , selectionHandler = require('./handler/selection')
1195
+ , touchHandler = require('./handler/touch');
1196
+
1197
+ module.exports = function (element, userSettings) {
1198
+ userSettings = typeof userSettings === 'object' ? userSettings : {};
1199
+
1200
+ cls.add(element, 'ps-container');
1201
+
1202
+ // Create a plugin instance.
1203
+ var i = instances.add(element);
1204
+
1205
+ i.settings = h.extend(i.settings, userSettings);
1206
+
1207
+ clickRailHandler(element);
1208
+ dragScrollbarHandler(element);
1209
+ mouseWheelHandler(element);
1210
+ nativeScrollHandler(element);
1211
+
1212
+ if (i.settings.useSelectionScroll) {
1213
+ selectionHandler(element);
1214
+ }
1215
+
1216
+ if (h.env.supportsTouch || h.env.supportsIePointer) {
1217
+ touchHandler(element, h.env.supportsTouch, h.env.supportsIePointer);
1218
+ }
1219
+ if (i.settings.useKeyboard) {
1220
+ keyboardHandler(element);
1221
+ }
1222
+
1223
+ updateGeometry(element);
1224
+ };
1225
+
1226
+ },{"../lib/class":2,"../lib/helper":6,"./handler/click-rail":10,"./handler/drag-scrollbar":11,"./handler/keyboard":12,"./handler/mouse-wheel":13,"./handler/native-scroll":14,"./handler/selection":15,"./handler/touch":16,"./instances":18,"./update-geometry":19}],18:[function(require,module,exports){
1227
+ /* Copyright (c) 2015 Hyunje Alex Jun and other contributors
1228
+ * Licensed under the MIT License
1229
+ */
1230
+ 'use strict';
1231
+
1232
+ var d = require('../lib/dom')
1233
+ , defaultSettings = require('./default-setting')
1234
+ , EventManager = require('../lib/event-manager')
1235
+ , guid = require('../lib/guid')
1236
+ , h = require('../lib/helper');
1237
+
1238
+ var instances = {};
1239
+
1240
+ function Instance(element) {
1241
+ var i = this;
1242
+
1243
+ i.settings = h.clone(defaultSettings);
1244
+ i.containerWidth = null;
1245
+ i.containerHeight = null;
1246
+ i.contentWidth = null;
1247
+ i.contentHeight = null;
1248
+
1249
+ i.isRtl = d.css(element, 'direction') === "rtl";
1250
+ i.isNegativeScroll = (function () {
1251
+ var originalScrollLeft = element.scrollLeft;
1252
+ var result = null;
1253
+ element.scrollLeft = -1;
1254
+ result = element.scrollLeft < 0;
1255
+ element.scrollLeft = originalScrollLeft;
1256
+ return result;
1257
+ })();
1258
+ i.negativeScrollAdjustment = i.isNegativeScroll ? element.scrollWidth - element.clientWidth : 0;
1259
+ i.event = new EventManager();
1260
+ i.ownerDocument = element.ownerDocument || document;
1261
+
1262
+ i.scrollbarXRail = d.appendTo(d.e('div', 'ps-scrollbar-x-rail'), element);
1263
+ i.scrollbarX = d.appendTo(d.e('div', 'ps-scrollbar-x'), i.scrollbarXRail);
1264
+ i.scrollbarX.setAttribute('tabindex', 0);
1265
+ i.scrollbarXActive = null;
1266
+ i.scrollbarXWidth = null;
1267
+ i.scrollbarXLeft = null;
1268
+ i.scrollbarXBottom = h.toInt(d.css(i.scrollbarXRail, 'bottom'));
1269
+ i.isScrollbarXUsingBottom = i.scrollbarXBottom === i.scrollbarXBottom; // !isNaN
1270
+ i.scrollbarXTop = i.isScrollbarXUsingBottom ? null : h.toInt(d.css(i.scrollbarXRail, 'top'));
1271
+ i.railBorderXWidth = h.toInt(d.css(i.scrollbarXRail, 'borderLeftWidth')) + h.toInt(d.css(i.scrollbarXRail, 'borderRightWidth'));
1272
+ // Set rail to display:block to calculate margins
1273
+ d.css(i.scrollbarXRail, 'display', 'block');
1274
+ i.railXMarginWidth = h.toInt(d.css(i.scrollbarXRail, 'marginLeft')) + h.toInt(d.css(i.scrollbarXRail, 'marginRight'));
1275
+ d.css(i.scrollbarXRail, 'display', '');
1276
+ i.railXWidth = null;
1277
+ i.railXRatio = null;
1278
+
1279
+ i.scrollbarYRail = d.appendTo(d.e('div', 'ps-scrollbar-y-rail'), element);
1280
+ i.scrollbarY = d.appendTo(d.e('div', 'ps-scrollbar-y'), i.scrollbarYRail);
1281
+ i.scrollbarY.setAttribute('tabindex', 0);
1282
+ i.scrollbarYActive = null;
1283
+ i.scrollbarYHeight = null;
1284
+ i.scrollbarYTop = null;
1285
+ i.scrollbarYRight = h.toInt(d.css(i.scrollbarYRail, 'right'));
1286
+ i.isScrollbarYUsingRight = i.scrollbarYRight === i.scrollbarYRight; // !isNaN
1287
+ i.scrollbarYLeft = i.isScrollbarYUsingRight ? null : h.toInt(d.css(i.scrollbarYRail, 'left'));
1288
+ i.scrollbarYOuterWidth = i.isRtl ? h.outerWidth(i.scrollbarY) : null;
1289
+ i.railBorderYWidth = h.toInt(d.css(i.scrollbarYRail, 'borderTopWidth')) + h.toInt(d.css(i.scrollbarYRail, 'borderBottomWidth'));
1290
+ d.css(i.scrollbarYRail, 'display', 'block');
1291
+ i.railYMarginHeight = h.toInt(d.css(i.scrollbarYRail, 'marginTop')) + h.toInt(d.css(i.scrollbarYRail, 'marginBottom'));
1292
+ d.css(i.scrollbarYRail, 'display', '');
1293
+ i.railYHeight = null;
1294
+ i.railYRatio = null;
1295
+ }
1296
+
1297
+ function getId(element) {
1298
+ if (typeof element.dataset === 'undefined') {
1299
+ return element.getAttribute('data-ps-id');
1300
+ } else {
1301
+ return element.dataset.psId;
1302
+ }
1303
+ }
1304
+
1305
+ function setId(element, id) {
1306
+ if (typeof element.dataset === 'undefined') {
1307
+ element.setAttribute('data-ps-id', id);
1308
+ } else {
1309
+ element.dataset.psId = id;
1310
+ }
1311
+ }
1312
+
1313
+ function removeId(element) {
1314
+ if (typeof element.dataset === 'undefined') {
1315
+ element.removeAttribute('data-ps-id');
1316
+ } else {
1317
+ delete element.dataset.psId;
1318
+ }
1319
+ }
1320
+
1321
+ exports.add = function (element) {
1322
+ var newId = guid();
1323
+ setId(element, newId);
1324
+ instances[newId] = new Instance(element);
1325
+ return instances[newId];
1326
+ };
1327
+
1328
+ exports.remove = function (element) {
1329
+ delete instances[getId(element)];
1330
+ removeId(element);
1331
+ };
1332
+
1333
+ exports.get = function (element) {
1334
+ return instances[getId(element)];
1335
+ };
1336
+
1337
+ },{"../lib/dom":3,"../lib/event-manager":4,"../lib/guid":5,"../lib/helper":6,"./default-setting":8}],19:[function(require,module,exports){
1338
+ /* Copyright (c) 2015 Hyunje Alex Jun and other contributors
1339
+ * Licensed under the MIT License
1340
+ */
1341
+ 'use strict';
1342
+
1343
+ var cls = require('../lib/class')
1344
+ , d = require('../lib/dom')
1345
+ , h = require('../lib/helper')
1346
+ , instances = require('./instances')
1347
+ , updateScroll = require('./update-scroll');
1348
+
1349
+ function getThumbSize(i, thumbSize) {
1350
+ if (i.settings.minScrollbarLength) {
1351
+ thumbSize = Math.max(thumbSize, i.settings.minScrollbarLength);
1352
+ }
1353
+ if (i.settings.maxScrollbarLength) {
1354
+ thumbSize = Math.min(thumbSize, i.settings.maxScrollbarLength);
1355
+ }
1356
+ return thumbSize;
1357
+ }
1358
+
1359
+ function updateCss(element, i) {
1360
+ var xRailOffset = {width: i.railXWidth};
1361
+ if (i.isRtl) {
1362
+ xRailOffset.left = i.negativeScrollAdjustment + element.scrollLeft + i.containerWidth - i.contentWidth;
1363
+ } else {
1364
+ xRailOffset.left = element.scrollLeft;
1365
+ }
1366
+ if (i.isScrollbarXUsingBottom) {
1367
+ xRailOffset.bottom = i.scrollbarXBottom - element.scrollTop;
1368
+ } else {
1369
+ xRailOffset.top = i.scrollbarXTop + element.scrollTop;
1370
+ }
1371
+ d.css(i.scrollbarXRail, xRailOffset);
1372
+
1373
+ var yRailOffset = {top: element.scrollTop, height: i.railYHeight};
1374
+ if (i.isScrollbarYUsingRight) {
1375
+ if (i.isRtl) {
1376
+ yRailOffset.right = i.contentWidth - (i.negativeScrollAdjustment + element.scrollLeft) - i.scrollbarYRight - i.scrollbarYOuterWidth;
1377
+ } else {
1378
+ yRailOffset.right = i.scrollbarYRight - element.scrollLeft;
1379
+ }
1380
+ } else {
1381
+ if (i.isRtl) {
1382
+ yRailOffset.left = i.negativeScrollAdjustment + element.scrollLeft + i.containerWidth * 2 - i.contentWidth - i.scrollbarYLeft - i.scrollbarYOuterWidth;
1383
+ } else {
1384
+ yRailOffset.left = i.scrollbarYLeft + element.scrollLeft;
1385
+ }
1386
+ }
1387
+ d.css(i.scrollbarYRail, yRailOffset);
1388
+
1389
+ d.css(i.scrollbarX, {left: i.scrollbarXLeft, width: i.scrollbarXWidth - i.railBorderXWidth});
1390
+ d.css(i.scrollbarY, {top: i.scrollbarYTop, height: i.scrollbarYHeight - i.railBorderYWidth});
1391
+ }
1392
+
1393
+ module.exports = function (element) {
1394
+ var i = instances.get(element);
1395
+
1396
+ i.containerWidth = element.clientWidth;
1397
+ i.containerHeight = element.clientHeight;
1398
+ i.contentWidth = element.scrollWidth;
1399
+ i.contentHeight = element.scrollHeight;
1400
+
1401
+ var existingRails;
1402
+ if (!element.contains(i.scrollbarXRail)) {
1403
+ existingRails = d.queryChildren(element, '.ps-scrollbar-x-rail');
1404
+ if (existingRails.length > 0) {
1405
+ existingRails.forEach(function (rail) {
1406
+ d.remove(rail);
1407
+ });
1408
+ }
1409
+ d.appendTo(i.scrollbarXRail, element);
1410
+ }
1411
+ if (!element.contains(i.scrollbarYRail)) {
1412
+ existingRails = d.queryChildren(element, '.ps-scrollbar-y-rail');
1413
+ if (existingRails.length > 0) {
1414
+ existingRails.forEach(function (rail) {
1415
+ d.remove(rail);
1416
+ });
1417
+ }
1418
+ d.appendTo(i.scrollbarYRail, element);
1419
+ }
1420
+
1421
+ if (!i.settings.suppressScrollX && i.containerWidth + i.settings.scrollXMarginOffset < i.contentWidth) {
1422
+ i.scrollbarXActive = true;
1423
+ i.railXWidth = i.containerWidth - i.railXMarginWidth;
1424
+ i.railXRatio = i.containerWidth / i.railXWidth;
1425
+ i.scrollbarXWidth = getThumbSize(i, h.toInt(i.railXWidth * i.containerWidth / i.contentWidth));
1426
+ i.scrollbarXLeft = h.toInt((i.negativeScrollAdjustment + element.scrollLeft) * (i.railXWidth - i.scrollbarXWidth) / (i.contentWidth - i.containerWidth));
1427
+ } else {
1428
+ i.scrollbarXActive = false;
1429
+ }
1430
+
1431
+ if (!i.settings.suppressScrollY && i.containerHeight + i.settings.scrollYMarginOffset < i.contentHeight) {
1432
+ i.scrollbarYActive = true;
1433
+ i.railYHeight = i.containerHeight - i.railYMarginHeight;
1434
+ i.railYRatio = i.containerHeight / i.railYHeight;
1435
+ i.scrollbarYHeight = getThumbSize(i, h.toInt(i.railYHeight * i.containerHeight / i.contentHeight));
1436
+ i.scrollbarYTop = h.toInt(element.scrollTop * (i.railYHeight - i.scrollbarYHeight) / (i.contentHeight - i.containerHeight));
1437
+ } else {
1438
+ i.scrollbarYActive = false;
1439
+ }
1440
+
1441
+ if (i.scrollbarXLeft >= i.railXWidth - i.scrollbarXWidth) {
1442
+ i.scrollbarXLeft = i.railXWidth - i.scrollbarXWidth;
1443
+ }
1444
+ if (i.scrollbarYTop >= i.railYHeight - i.scrollbarYHeight) {
1445
+ i.scrollbarYTop = i.railYHeight - i.scrollbarYHeight;
1446
+ }
1447
+
1448
+ updateCss(element, i);
1449
+
1450
+ if (i.scrollbarXActive) {
1451
+ cls.add(element, 'ps-active-x');
1452
+ } else {
1453
+ cls.remove(element, 'ps-active-x');
1454
+ i.scrollbarXWidth = 0;
1455
+ i.scrollbarXLeft = 0;
1456
+ updateScroll(element, 'left', 0);
1457
+ }
1458
+ if (i.scrollbarYActive) {
1459
+ cls.add(element, 'ps-active-y');
1460
+ } else {
1461
+ cls.remove(element, 'ps-active-y');
1462
+ i.scrollbarYHeight = 0;
1463
+ i.scrollbarYTop = 0;
1464
+ updateScroll(element, 'top', 0);
1465
+ }
1466
+ };
1467
+
1468
+ },{"../lib/class":2,"../lib/dom":3,"../lib/helper":6,"./instances":18,"./update-scroll":20}],20:[function(require,module,exports){
1469
+ /* Copyright (c) 2015 Hyunje Alex Jun and other contributors
1470
+ * Licensed under the MIT License
1471
+ */
1472
+ 'use strict';
1473
+
1474
+ var instances = require('./instances');
1475
+
1476
+ var upEvent = document.createEvent('Event')
1477
+ , downEvent = document.createEvent('Event')
1478
+ , leftEvent = document.createEvent('Event')
1479
+ , rightEvent = document.createEvent('Event')
1480
+ , yEvent = document.createEvent('Event')
1481
+ , xEvent = document.createEvent('Event')
1482
+ , xStartEvent = document.createEvent('Event')
1483
+ , xEndEvent = document.createEvent('Event')
1484
+ , yStartEvent = document.createEvent('Event')
1485
+ , yEndEvent = document.createEvent('Event')
1486
+ , lastTop
1487
+ , lastLeft;
1488
+
1489
+ upEvent.initEvent('ps-scroll-up', true, true);
1490
+ downEvent.initEvent('ps-scroll-down', true, true);
1491
+ leftEvent.initEvent('ps-scroll-left', true, true);
1492
+ rightEvent.initEvent('ps-scroll-right', true, true);
1493
+ yEvent.initEvent('ps-scroll-y', true, true);
1494
+ xEvent.initEvent('ps-scroll-x', true, true);
1495
+ xStartEvent.initEvent('ps-x-reach-start', true, true);
1496
+ xEndEvent.initEvent('ps-x-reach-end', true, true);
1497
+ yStartEvent.initEvent('ps-y-reach-start', true, true);
1498
+ yEndEvent.initEvent('ps-y-reach-end', true, true);
1499
+
1500
+ module.exports = function (element, axis, value) {
1501
+ if (typeof element === 'undefined') {
1502
+ throw 'You must provide an element to the update-scroll function';
1503
+ }
1504
+
1505
+ if (typeof axis === 'undefined') {
1506
+ throw 'You must provide an axis to the update-scroll function';
1507
+ }
1508
+
1509
+ if (typeof value === 'undefined') {
1510
+ throw 'You must provide a value to the update-scroll function';
1511
+ }
1512
+
1513
+ if (axis === 'top' && value <= 0) {
1514
+ element.scrollTop = 0;
1515
+ element.dispatchEvent(yStartEvent);
1516
+ return; // don't allow negative scroll
1517
+ }
1518
+
1519
+ if (axis === 'left' && value <= 0) {
1520
+ element.scrollLeft = 0;
1521
+ element.dispatchEvent(xStartEvent);
1522
+ return; // don't allow negative scroll
1523
+ }
1524
+
1525
+ var i = instances.get(element);
1526
+
1527
+ if (axis === 'top' && value >= i.contentHeight - i.containerHeight) {
1528
+ element.scrollTop = i.contentHeight - i.containerHeight;
1529
+ element.dispatchEvent(yEndEvent);
1530
+ return; // don't allow scroll past container
1531
+ }
1532
+
1533
+ if (axis === 'left' && value >= i.contentWidth - i.containerWidth) {
1534
+ element.scrollLeft = i.contentWidth - i.containerWidth;
1535
+ element.dispatchEvent(xEndEvent);
1536
+ return; // don't allow scroll past container
1537
+ }
1538
+
1539
+ if (!lastTop) {
1540
+ lastTop = element.scrollTop;
1541
+ }
1542
+
1543
+ if (!lastLeft) {
1544
+ lastLeft = element.scrollLeft;
1545
+ }
1546
+
1547
+ if (axis === 'top' && value < lastTop) {
1548
+ element.dispatchEvent(upEvent);
1549
+ }
1550
+
1551
+ if (axis === 'top' && value > lastTop) {
1552
+ element.dispatchEvent(downEvent);
1553
+ }
1554
+
1555
+ if (axis === 'left' && value < lastLeft) {
1556
+ element.dispatchEvent(leftEvent);
1557
+ }
1558
+
1559
+ if (axis === 'left' && value > lastLeft) {
1560
+ element.dispatchEvent(rightEvent);
1561
+ }
1562
+
1563
+ if (axis === 'top') {
1564
+ element.scrollTop = lastTop = value;
1565
+ element.dispatchEvent(yEvent);
1566
+ }
1567
+
1568
+ if (axis === 'left') {
1569
+ element.scrollLeft = lastLeft = value;
1570
+ element.dispatchEvent(xEvent);
1571
+ }
1572
+
1573
+ };
1574
+
1575
+ },{"./instances":18}],21:[function(require,module,exports){
1576
+ /* Copyright (c) 2015 Hyunje Alex Jun and other contributors
1577
+ * Licensed under the MIT License
1578
+ */
1579
+ 'use strict';
1580
+
1581
+ var d = require('../lib/dom')
1582
+ , h = require('../lib/helper')
1583
+ , instances = require('./instances')
1584
+ , updateGeometry = require('./update-geometry')
1585
+ , updateScroll = require('./update-scroll');
1586
+
1587
+ module.exports = function (element) {
1588
+ var i = instances.get(element);
1589
+
1590
+ if (!i) {
1591
+ return;
1592
+ }
1593
+
1594
+ // Recalcuate negative scrollLeft adjustment
1595
+ i.negativeScrollAdjustment = i.isNegativeScroll ? element.scrollWidth - element.clientWidth : 0;
1596
+
1597
+ // Recalculate rail margins
1598
+ d.css(i.scrollbarXRail, 'display', 'block');
1599
+ d.css(i.scrollbarYRail, 'display', 'block');
1600
+ i.railXMarginWidth = h.toInt(d.css(i.scrollbarXRail, 'marginLeft')) + h.toInt(d.css(i.scrollbarXRail, 'marginRight'));
1601
+ i.railYMarginHeight = h.toInt(d.css(i.scrollbarYRail, 'marginTop')) + h.toInt(d.css(i.scrollbarYRail, 'marginBottom'));
1602
+
1603
+ // Hide scrollbars not to affect scrollWidth and scrollHeight
1604
+ d.css(i.scrollbarXRail, 'display', 'none');
1605
+ d.css(i.scrollbarYRail, 'display', 'none');
1606
+
1607
+ updateGeometry(element);
1608
+
1609
+ // Update top/left scroll to trigger events
1610
+ updateScroll(element, 'top', element.scrollTop);
1611
+ updateScroll(element, 'left', element.scrollLeft);
1612
+
1613
+ d.css(i.scrollbarXRail, 'display', '');
1614
+ d.css(i.scrollbarYRail, 'display', '');
1615
+ };
1616
+
1617
+ },{"../lib/dom":3,"../lib/helper":6,"./instances":18,"./update-geometry":19,"./update-scroll":20}]},{},[1]);