tether-rails 1.2.0 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 170c3d6cc2a69f59b36022f72980e9904f081a25
4
- data.tar.gz: 76a8cda8ee5659d21c97e327848ae6e1d430ce53
3
+ metadata.gz: de93ccccb7666876b9d68581ce49a5df0c5cf475
4
+ data.tar.gz: 8a0732631e09bd1e1c980be57d3c51839d163cd6
5
5
  SHA512:
6
- metadata.gz: a0522e826ca9628b32209e7e96d78e7957ab98fa78828f4487379ef1caa9e77250377f4100fe259d21825acd3f15b7eac5f7b3ee9d09bf442d291f92d783a940
7
- data.tar.gz: 099e8c0ff130d06f33387cf1dfd4c455a23cc312875105aad939a1aceefe10ceeff4f5fce4fdc07cbd5825b1182c934a40c2eb4474c3e0070b7b4a1a8f57e8de
6
+ metadata.gz: 028f121b23f8893ddc6abe0583381bc3cb614de3106fb5737662fa97319f63dbe86251565d3f206b5e93af09d11ea42a1d3a318593bc3b6b8f65eeb065a32bb4
7
+ data.tar.gz: 190be216ade2240c328c34869153342386158b8f7f66282ab62ec21475a9481a492f4efe476e1b90664424bf0bb1c8330c50a500bb1aae07c795b0ee2ecfdf11
data/.gitignore CHANGED
@@ -1,2 +1,3 @@
1
+ *.gem
1
2
  .ruby-version
2
3
  Gemfile.lock
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in tether-rails.gemspec
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Jake Gavin
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 CHANGED
@@ -1,3 +1,4 @@
1
+ [![Gem Version](https://badge.fury.io/rb/tether-rails.svg)](https://badge.fury.io/rb/tether-rails)
1
2
  # tether-rails
2
3
 
3
4
  This gem wraps the [Tether](http://tether.io/docs/welcome/) JavaScript library so that it can be included easily in the Rails asset pipeline.
@@ -13,7 +14,7 @@ and run `bundle install`
13
14
 
14
15
  Then, add tether-rails to your `application.js` manifest
15
16
  ```
16
- //= require tether-rails
17
+ //= require tether
17
18
  ```
18
19
  and include the stylesheets in your `application.css` manifest
19
20
  ```
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -1,3 +1,3 @@
1
1
  module TetherRails
2
- VERSION = '1.2.0'
2
+ VERSION = '1.3.0'
3
3
  end
@@ -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 'tether-rails/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "tether-rails"
8
+ spec.version = TetherRails::VERSION
9
+ spec.authors = ["Jake Gavin"]
10
+ spec.email = ["jakegavin@gmail.com"]
11
+
12
+ spec.summary = "tether-rails wraps the Tether JavaScript library so that it can easily be included in Rails."
13
+ spec.homepage = "https://github.com/jakegavin/tether-rails"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
+ spec.bindir = "exe"
18
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency "rails", ">= 3.1"
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.11"
24
+ spec.add_development_dependency "rake", "~> 10.0"
25
+ end
@@ -1,4 +1,4 @@
1
- /*! tether 1.2.0 */
1
+ /*! tether 1.3.0 */
2
2
 
3
3
  (function(root, factory) {
4
4
  if (typeof define === 'function' && define.amd) {
@@ -21,25 +21,29 @@ if (typeof TetherBase === 'undefined') {
21
21
  TetherBase = { modules: [] };
22
22
  }
23
23
 
24
- function getScrollParent(el) {
24
+ var zeroElement = null;
25
+
26
+ function getScrollParents(el) {
25
27
  // In firefox if the el is inside an iframe with display: none; window.getComputedStyle() will return null;
26
28
  // https://bugzilla.mozilla.org/show_bug.cgi?id=548397
27
29
  var computedStyle = getComputedStyle(el) || {};
28
30
  var position = computedStyle.position;
31
+ var parents = [];
29
32
 
30
33
  if (position === 'fixed') {
31
- return el;
34
+ return [el];
32
35
  }
33
36
 
34
37
  var parent = el;
35
- while (parent = parent.parentNode) {
38
+ while ((parent = parent.parentNode) && parent && parent.nodeType === 1) {
36
39
  var style = undefined;
37
40
  try {
38
41
  style = getComputedStyle(parent);
39
42
  } catch (err) {}
40
43
 
41
44
  if (typeof style === 'undefined' || style === null) {
42
- return parent;
45
+ parents.push(parent);
46
+ return parents;
43
47
  }
44
48
 
45
49
  var _style = style;
@@ -49,12 +53,13 @@ function getScrollParent(el) {
49
53
 
50
54
  if (/(auto|scroll)/.test(overflow + overflowY + overflowX)) {
51
55
  if (position !== 'absolute' || ['relative', 'absolute', 'fixed'].indexOf(style.position) >= 0) {
52
- return parent;
56
+ parents.push(parent);
53
57
  }
54
58
  }
55
59
  }
56
60
 
57
- return document.body;
61
+ parents.push(document.body);
62
+ return parents;
58
63
  }
59
64
 
60
65
  var uniqueId = (function () {
@@ -65,14 +70,14 @@ var uniqueId = (function () {
65
70
  })();
66
71
 
67
72
  var zeroPosCache = {};
68
- var getOrigin = function getOrigin(doc) {
73
+ var getOrigin = function getOrigin() {
69
74
  // getBoundingClientRect is unfortunately too accurate. It introduces a pixel or two of
70
75
  // jitter as the user scrolls that messes with our ability to detect if two positions
71
76
  // are equivilant or not. We place an element at the top left of the page that will
72
77
  // get the same jitter, so we can cancel the two out.
73
- var node = doc._tetherZeroElement;
74
- if (typeof node === 'undefined') {
75
- node = doc.createElement('div');
78
+ var node = zeroElement;
79
+ if (!node) {
80
+ node = document.createElement('div');
76
81
  node.setAttribute('data-tether-id', uniqueId());
77
82
  extend(node.style, {
78
83
  top: 0,
@@ -80,9 +85,9 @@ var getOrigin = function getOrigin(doc) {
80
85
  position: 'absolute'
81
86
  });
82
87
 
83
- doc.body.appendChild(node);
88
+ document.body.appendChild(node);
84
89
 
85
- doc._tetherZeroElement = node;
90
+ zeroElement = node;
86
91
  }
87
92
 
88
93
  var id = node.getAttribute('data-tether-id');
@@ -104,6 +109,11 @@ var getOrigin = function getOrigin(doc) {
104
109
  return zeroPosCache[id];
105
110
  };
106
111
 
112
+ function removeUtilElements() {
113
+ document.body.removeChild(zeroElement);
114
+ zeroElement = undefined;
115
+ };
116
+
107
117
  function getBounds(el) {
108
118
  var doc = undefined;
109
119
  if (el === document) {
@@ -123,7 +133,7 @@ function getBounds(el) {
123
133
  box[k] = rect[k];
124
134
  }
125
135
 
126
- var origin = getOrigin(doc);
136
+ var origin = getOrigin();
127
137
 
128
138
  box.top -= origin.top;
129
139
  box.left -= origin.left;
@@ -359,7 +369,7 @@ var Evented = (function () {
359
369
  })();
360
370
 
361
371
  TetherBase.Utils = {
362
- getScrollParent: getScrollParent,
372
+ getScrollParents: getScrollParents,
363
373
  getBounds: getBounds,
364
374
  getOffsetParent: getOffsetParent,
365
375
  extend: extend,
@@ -371,7 +381,8 @@ TetherBase.Utils = {
371
381
  flush: flush,
372
382
  uniqueId: uniqueId,
373
383
  Evented: Evented,
374
- getScrollBarSize: getScrollBarSize
384
+ getScrollBarSize: getScrollBarSize,
385
+ removeUtilElements: removeUtilElements
375
386
  };
376
387
  /* globals TetherBase, performance */
377
388
 
@@ -381,14 +392,18 @@ var _slicedToArray = (function () { function sliceIterator(arr, i) { var _arr =
381
392
 
382
393
  var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
383
394
 
395
+ var _get = function get(_x6, _x7, _x8) { var _again = true; _function: while (_again) { var object = _x6, property = _x7, receiver = _x8; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x6 = parent; _x7 = property; _x8 = receiver; _again = true; desc = parent = undefined; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } };
396
+
384
397
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
385
398
 
399
+ function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
400
+
386
401
  if (typeof TetherBase === 'undefined') {
387
402
  throw new Error('You must include the utils.js file before tether.js');
388
403
  }
389
404
 
390
405
  var _TetherBase$Utils = TetherBase.Utils;
391
- var getScrollParent = _TetherBase$Utils.getScrollParent;
406
+ var getScrollParents = _TetherBase$Utils.getScrollParents;
392
407
  var getBounds = _TetherBase$Utils.getBounds;
393
408
  var getOffsetParent = _TetherBase$Utils.getOffsetParent;
394
409
  var extend = _TetherBase$Utils.extend;
@@ -398,6 +413,7 @@ var updateClasses = _TetherBase$Utils.updateClasses;
398
413
  var defer = _TetherBase$Utils.defer;
399
414
  var flush = _TetherBase$Utils.flush;
400
415
  var getScrollBarSize = _TetherBase$Utils.getScrollBarSize;
416
+ var removeUtilElements = _TetherBase$Utils.removeUtilElements;
401
417
 
402
418
  function within(a, b) {
403
419
  var diff = arguments.length <= 2 || arguments[2] === undefined ? 1 : arguments[2];
@@ -466,7 +482,7 @@ function now() {
466
482
  lastDuration = now() - lastCall;
467
483
  };
468
484
 
469
- if (typeof window !== 'undefined') {
485
+ if (typeof window !== 'undefined' && typeof window.addEventListener !== 'undefined') {
470
486
  ['resize', 'scroll', 'touchmove'].forEach(function (event) {
471
487
  window.addEventListener(event, tick);
472
488
  });
@@ -572,12 +588,15 @@ var parseOffset = function parseOffset(value) {
572
588
  };
573
589
  var parseAttachment = parseOffset;
574
590
 
575
- var TetherClass = (function () {
591
+ var TetherClass = (function (_Evented) {
592
+ _inherits(TetherClass, _Evented);
593
+
576
594
  function TetherClass(options) {
577
595
  var _this = this;
578
596
 
579
597
  _classCallCheck(this, TetherClass);
580
598
 
599
+ _get(Object.getPrototypeOf(TetherClass.prototype), 'constructor', this).call(this);
581
600
  this.position = this.position.bind(this);
582
601
 
583
602
  tethers.push(this);
@@ -668,14 +687,14 @@ var TetherClass = (function () {
668
687
  this.offset = parseOffset(this.options.offset);
669
688
  this.targetOffset = parseOffset(this.options.targetOffset);
670
689
 
671
- if (typeof this.scrollParent !== 'undefined') {
690
+ if (typeof this.scrollParents !== 'undefined') {
672
691
  this.disable();
673
692
  }
674
693
 
675
694
  if (this.targetModifier === 'scroll-handle') {
676
- this.scrollParent = this.target;
695
+ this.scrollParents = [this.target];
677
696
  } else {
678
- this.scrollParent = getScrollParent(this.target);
697
+ this.scrollParents = getScrollParents(this.target);
679
698
  }
680
699
 
681
700
  if (!(this.options.enabled === false)) {
@@ -796,6 +815,8 @@ var TetherClass = (function () {
796
815
  }, {
797
816
  key: 'enable',
798
817
  value: function enable() {
818
+ var _this3 = this;
819
+
799
820
  var pos = arguments.length <= 0 || arguments[0] === undefined ? true : arguments[0];
800
821
 
801
822
  if (!(this.options.addTargetClasses === false)) {
@@ -804,9 +825,11 @@ var TetherClass = (function () {
804
825
  addClass(this.element, this.getClass('enabled'));
805
826
  this.enabled = true;
806
827
 
807
- if (this.scrollParent !== document) {
808
- this.scrollParent.addEventListener('scroll', this.position);
809
- }
828
+ this.scrollParents.forEach(function (parent) {
829
+ if (parent !== document) {
830
+ parent.addEventListener('scroll', _this3.position);
831
+ }
832
+ });
810
833
 
811
834
  if (pos) {
812
835
  this.position();
@@ -815,32 +838,40 @@ var TetherClass = (function () {
815
838
  }, {
816
839
  key: 'disable',
817
840
  value: function disable() {
841
+ var _this4 = this;
842
+
818
843
  removeClass(this.target, this.getClass('enabled'));
819
844
  removeClass(this.element, this.getClass('enabled'));
820
845
  this.enabled = false;
821
846
 
822
- if (typeof this.scrollParent !== 'undefined') {
823
- this.scrollParent.removeEventListener('scroll', this.position);
847
+ if (typeof this.scrollParents !== 'undefined') {
848
+ this.scrollParents.forEach(function (parent) {
849
+ parent.removeEventListener('scroll', _this4.position);
850
+ });
824
851
  }
825
852
  }
826
853
  }, {
827
854
  key: 'destroy',
828
855
  value: function destroy() {
829
- var _this3 = this;
856
+ var _this5 = this;
830
857
 
831
858
  this.disable();
832
859
 
833
860
  tethers.forEach(function (tether, i) {
834
- if (tether === _this3) {
861
+ if (tether === _this5) {
835
862
  tethers.splice(i, 1);
836
- return;
837
863
  }
838
864
  });
865
+
866
+ // Remove any elements we were using for convenience from the DOM
867
+ if (tethers.length === 0) {
868
+ removeUtilElements();
869
+ }
839
870
  }
840
871
  }, {
841
872
  key: 'updateAttachClasses',
842
873
  value: function updateAttachClasses(elementAttach, targetAttach) {
843
- var _this4 = this;
874
+ var _this6 = this;
844
875
 
845
876
  elementAttach = elementAttach || this.attachment;
846
877
  targetAttach = targetAttach || this.targetAttachment;
@@ -873,27 +904,27 @@ var TetherClass = (function () {
873
904
 
874
905
  var all = [];
875
906
  sides.forEach(function (side) {
876
- all.push(_this4.getClass('element-attached') + '-' + side);
877
- all.push(_this4.getClass('target-attached') + '-' + side);
907
+ all.push(_this6.getClass('element-attached') + '-' + side);
908
+ all.push(_this6.getClass('target-attached') + '-' + side);
878
909
  });
879
910
 
880
911
  defer(function () {
881
- if (!(typeof _this4._addAttachClasses !== 'undefined')) {
912
+ if (!(typeof _this6._addAttachClasses !== 'undefined')) {
882
913
  return;
883
914
  }
884
915
 
885
- updateClasses(_this4.element, _this4._addAttachClasses, all);
886
- if (!(_this4.options.addTargetClasses === false)) {
887
- updateClasses(_this4.target, _this4._addAttachClasses, all);
916
+ updateClasses(_this6.element, _this6._addAttachClasses, all);
917
+ if (!(_this6.options.addTargetClasses === false)) {
918
+ updateClasses(_this6.target, _this6._addAttachClasses, all);
888
919
  }
889
920
 
890
- delete _this4._addAttachClasses;
921
+ delete _this6._addAttachClasses;
891
922
  });
892
923
  }
893
924
  }, {
894
925
  key: 'position',
895
926
  value: function position() {
896
- var _this5 = this;
927
+ var _this7 = this;
897
928
 
898
929
  var flushChanges = arguments.length <= 0 || arguments[0] === undefined ? true : arguments[0];
899
930
 
@@ -912,7 +943,7 @@ var TetherClass = (function () {
912
943
  this.updateAttachClasses(this.attachment, targetAttachment);
913
944
 
914
945
  var elementPos = this.cache('element-bounds', function () {
915
- return getBounds(_this5.element);
946
+ return getBounds(_this7.element);
916
947
  });
917
948
 
918
949
  var width = elementPos.width;
@@ -930,7 +961,7 @@ var TetherClass = (function () {
930
961
  }
931
962
 
932
963
  var targetPos = this.cache('target-bounds', function () {
933
- return _this5.getTargetBounds();
964
+ return _this7.getTargetBounds();
934
965
  });
935
966
  var targetSize = targetPos;
936
967
 
@@ -1014,10 +1045,10 @@ var TetherClass = (function () {
1014
1045
 
1015
1046
  if (typeof this.options.optimizations !== 'undefined' && this.options.optimizations.moveElement !== false && !(typeof this.targetModifier !== 'undefined')) {
1016
1047
  (function () {
1017
- var offsetParent = _this5.cache('target-offsetparent', function () {
1018
- return getOffsetParent(_this5.target);
1048
+ var offsetParent = _this7.cache('target-offsetparent', function () {
1049
+ return getOffsetParent(_this7.target);
1019
1050
  });
1020
- var offsetPosition = _this5.cache('target-offsetparent-bounds', function () {
1051
+ var offsetPosition = _this7.cache('target-offsetparent-bounds', function () {
1021
1052
  return getBounds(offsetParent);
1022
1053
  });
1023
1054
  var offsetParentStyle = getComputedStyle(offsetParent);
@@ -1070,7 +1101,7 @@ var TetherClass = (function () {
1070
1101
  }, {
1071
1102
  key: 'move',
1072
1103
  value: function move(pos) {
1073
- var _this6 = this;
1104
+ var _this8 = this;
1074
1105
 
1075
1106
  if (!(typeof this.element.parentNode !== 'undefined')) {
1076
1107
  return;
@@ -1101,8 +1132,8 @@ var TetherClass = (function () {
1101
1132
  var css = { top: '', left: '', right: '', bottom: '' };
1102
1133
 
1103
1134
  var transcribe = function transcribe(_same, _pos) {
1104
- var hasOptimizations = typeof _this6.options.optimizations !== 'undefined';
1105
- var gpu = hasOptimizations ? _this6.options.optimizations.gpu : null;
1135
+ var hasOptimizations = typeof _this8.options.optimizations !== 'undefined';
1136
+ var gpu = hasOptimizations ? _this8.options.optimizations.gpu : null;
1106
1137
  if (gpu !== false) {
1107
1138
  var yPos = undefined,
1108
1139
  xPos = undefined;
@@ -1154,14 +1185,14 @@ var TetherClass = (function () {
1154
1185
  } else if (typeof same.offset !== 'undefined' && same.offset.top && same.offset.left) {
1155
1186
  (function () {
1156
1187
  css.position = 'absolute';
1157
- var offsetParent = _this6.cache('target-offsetparent', function () {
1158
- return getOffsetParent(_this6.target);
1188
+ var offsetParent = _this8.cache('target-offsetparent', function () {
1189
+ return getOffsetParent(_this8.target);
1159
1190
  });
1160
1191
 
1161
- if (getOffsetParent(_this6.element) !== offsetParent) {
1192
+ if (getOffsetParent(_this8.element) !== offsetParent) {
1162
1193
  defer(function () {
1163
- _this6.element.parentNode.removeChild(_this6.element);
1164
- offsetParent.appendChild(_this6.element);
1194
+ _this8.element.parentNode.removeChild(_this8.element);
1195
+ offsetParent.appendChild(_this8.element);
1165
1196
  });
1166
1197
  }
1167
1198
 
@@ -1176,7 +1207,7 @@ var TetherClass = (function () {
1176
1207
  if (!moved) {
1177
1208
  var offsetParentIsBody = true;
1178
1209
  var currentNode = this.element.parentNode;
1179
- while (currentNode && currentNode.tagName !== 'BODY') {
1210
+ while (currentNode && currentNode.nodeType === 1 && currentNode.tagName !== 'BODY') {
1180
1211
  if (getComputedStyle(currentNode).position !== 'static') {
1181
1212
  offsetParentIsBody = false;
1182
1213
  break;
@@ -1198,11 +1229,6 @@ var TetherClass = (function () {
1198
1229
  var val = css[key];
1199
1230
  var elVal = this.element.style[key];
1200
1231
 
1201
- if (elVal !== '' && val !== '' && ['top', 'left', 'bottom', 'right'].indexOf(key) >= 0) {
1202
- elVal = parseFloat(elVal);
1203
- val = parseFloat(val);
1204
- }
1205
-
1206
1232
  if (elVal !== val) {
1207
1233
  write = true;
1208
1234
  writeCSS[key] = val;
@@ -1211,14 +1237,14 @@ var TetherClass = (function () {
1211
1237
 
1212
1238
  if (write) {
1213
1239
  defer(function () {
1214
- extend(_this6.element.style, writeCSS);
1240
+ extend(_this8.element.style, writeCSS);
1215
1241
  });
1216
1242
  }
1217
1243
  }
1218
1244
  }]);
1219
1245
 
1220
1246
  return TetherClass;
1221
- })();
1247
+ })(Evented);
1222
1248
 
1223
1249
  TetherClass.modules = [];
1224
1250
 
@@ -1241,7 +1267,7 @@ var BOUNDS_FORMAT = ['left', 'top', 'right', 'bottom'];
1241
1267
 
1242
1268
  function getBoundingRect(tether, to) {
1243
1269
  if (to === 'scrollParent') {
1244
- to = tether.scrollParent;
1270
+ to = tether.scrollParents[0];
1245
1271
  } else if (to === 'window') {
1246
1272
  to = [pageXOffset, pageYOffset, innerWidth + pageXOffset, innerHeight + pageYOffset];
1247
1273
  }
@@ -1369,34 +1395,32 @@ TetherBase.modules.push({
1369
1395
  }
1370
1396
 
1371
1397
  if (changeAttachY === 'together') {
1372
- if (top < bounds[1] && tAttachment.top === 'top') {
1373
- if (eAttachment.top === 'bottom') {
1398
+ if (tAttachment.top === 'top') {
1399
+ if (eAttachment.top === 'bottom' && top < bounds[1]) {
1374
1400
  top += targetHeight;
1375
1401
  tAttachment.top = 'bottom';
1376
1402
 
1377
1403
  top += height;
1378
1404
  eAttachment.top = 'top';
1379
- } else if (eAttachment.top === 'top') {
1380
- top += targetHeight;
1405
+ } else if (eAttachment.top === 'top' && top + height > bounds[3] && top - (height - targetHeight) >= bounds[1]) {
1406
+ top -= height - targetHeight;
1381
1407
  tAttachment.top = 'bottom';
1382
1408
 
1383
- top -= height;
1384
1409
  eAttachment.top = 'bottom';
1385
1410
  }
1386
1411
  }
1387
1412
 
1388
- if (top + height > bounds[3] && tAttachment.top === 'bottom') {
1389
- if (eAttachment.top === 'top') {
1413
+ if (tAttachment.top === 'bottom') {
1414
+ if (eAttachment.top === 'top' && top + height > bounds[3]) {
1390
1415
  top -= targetHeight;
1391
1416
  tAttachment.top = 'top';
1392
1417
 
1393
1418
  top -= height;
1394
1419
  eAttachment.top = 'bottom';
1395
- } else if (eAttachment.top === 'bottom') {
1396
- top -= targetHeight;
1420
+ } else if (eAttachment.top === 'bottom' && top < bounds[1] && top + (height * 2 - targetHeight) <= bounds[3]) {
1421
+ top += height - targetHeight;
1397
1422
  tAttachment.top = 'top';
1398
1423
 
1399
- top += height;
1400
1424
  eAttachment.top = 'top';
1401
1425
  }
1402
1426
  }
@@ -1588,6 +1612,10 @@ TetherBase.modules.push({
1588
1612
 
1589
1613
  if (tAttachment.top !== targetAttachment.top || tAttachment.left !== targetAttachment.left || eAttachment.top !== _this.attachment.top || eAttachment.left !== _this.attachment.left) {
1590
1614
  _this.updateAttachClasses(eAttachment, tAttachment);
1615
+ _this.trigger('update', {
1616
+ attachment: eAttachment,
1617
+ targetAttachment: tAttachment
1618
+ });
1591
1619
  }
1592
1620
  });
1593
1621
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tether-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jake Gavin
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-03-04 00:00:00.000000000 Z
11
+ date: 2016-07-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -60,10 +60,14 @@ extensions: []
60
60
  extra_rdoc_files: []
61
61
  files:
62
62
  - ".gitignore"
63
+ - Gemfile
64
+ - LICENSE.txt
63
65
  - README.md
66
+ - Rakefile
64
67
  - lib/tether-rails.rb
65
68
  - lib/tether-rails/engine.rb
66
69
  - lib/tether-rails/version.rb
70
+ - tether-rails.gemspec
67
71
  - vendor/assets/javascripts/tether.js
68
72
  - vendor/assets/stylesheets/tether-theme-arrows-dark.css
69
73
  - vendor/assets/stylesheets/tether-theme-arrows.css