rails_onboarding 0.8.0 → 0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1a343a9b6bbf7c81c4fc94b106a78cede4b1b240256dbb4941a4dc872d14c796
4
- data.tar.gz: a93c58d4ef30dfe92b61d3062a3c8815cbb68b5ebc3e1aae970b5f1e497cb942
3
+ metadata.gz: 968d937235787bd7b4b096707cd9e44f2152d11c5b9d6f92f8f684d4b0807e98
4
+ data.tar.gz: f3b564a235899a551598ae48c9877ef5090261240a9e5b33cf0f63af6c155fc4
5
5
  SHA512:
6
- metadata.gz: f59b87619ce223cb9efe7e4f4c6b3445e133b1d926a21c3e387dc1d6772d6e88eb7b03fe0f195e13879aa9a8bf837530d1824e22aaf59d70de0e11f8b8644311
7
- data.tar.gz: 013a28a891c159d8867de01b83998ac5ce3bf91ab1e4c592c96f7b089df95129883f85902395b9d379603217913f841ef2b3f9b515b6ae031432c42f24a2bb19
6
+ metadata.gz: 35466bcb9f4c22021d9a8012cb4f0fc0bf3a2b3ccaeedf270f0681711d1a686e41b6a3e102b6a5084955ca7b0c2bc5ad84203b284303604b1e27c5c93a032a58
7
+ data.tar.gz: 1674b9b08636d82c3d71fb78b80d8aae49d7f7510f91ff948dbbf642c79ddf21118248d465bce33b84e5630c24ee37b04cdfc2d30542047cc50fa2469210babd
@@ -149,8 +149,8 @@ export default class extends Controller {
149
149
  </div>
150
150
  `
151
151
 
152
- // Position tooltip (top/left are viewport-relative and computed per
153
- // call, so they stay inline; everything else lives in .step-tooltip)
152
+ // Position tooltip (top/left are computed per call, so they stay inline;
153
+ // everything else lives in .step-tooltip)
154
154
  document.body.appendChild(tooltip)
155
155
  this.positionTooltip(tooltip, targetElement)
156
156
 
@@ -179,8 +179,12 @@ export default class extends Controller {
179
179
  top = rect.top - tooltipRect.height - 8
180
180
  }
181
181
 
182
- tooltip.style.top = `${top}px`
183
- tooltip.style.left = `${left}px`
182
+ // The maths above is all in viewport space (getBoundingClientRect,
183
+ // window.innerWidth/Height), but .step-tooltip is `position: absolute`
184
+ // on document.body, so add the scroll offset when applying. See the same
185
+ // conversion in tooltip_controller.js#positionTooltip.
186
+ tooltip.style.top = `${top + window.scrollY}px`
187
+ tooltip.style.left = `${left + window.scrollX}px`
184
188
  }
185
189
 
186
190
  // Advance to next step (for testing/demo purposes)
@@ -784,9 +784,16 @@ export default class extends Controller {
784
784
 
785
785
  let { position, top, left, arrowPosition } = bestPosition
786
786
 
787
- // Apply position
788
- this.tooltip.style.top = `${top}px`
789
- this.tooltip.style.left = `${left}px`
787
+ // Apply position, converting viewport coordinates to document ones.
788
+ // Everything above - getBoundingClientRect, the edge clamping in
789
+ // calculatePosition, the collision checks in scorePosition - works in
790
+ // viewport space, but .onboarding-tooltip is `position: absolute` on
791
+ // document.body, so top/left are resolved against the document. Without
792
+ // the scroll offset the tooltip lands a full scroll position away from
793
+ // its trigger. Absolute (not fixed) is deliberate: it keeps the tooltip
794
+ // glued to the trigger if the page scrolls while it's open.
795
+ this.tooltip.style.top = `${top + viewport.scrollY}px`
796
+ this.tooltip.style.left = `${left + viewport.scrollX}px`
790
797
 
791
798
  // Style arrow based on final position
792
799
  if (arrow) {
@@ -1,3 +1,3 @@
1
1
  module RailsOnboarding
2
- VERSION = "0.8.0"
2
+ VERSION = "0.8.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_onboarding
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Lewis
@@ -282,7 +282,7 @@ licenses:
282
282
  metadata:
283
283
  allowed_push_host: https://rubygems.org
284
284
  homepage_uri: https://github.com/bunnahabhain/rails_onboarding
285
- source_code_uri: https://github.com/bunnahabhain/rails_onboarding/tree/v0.8.0
285
+ source_code_uri: https://github.com/bunnahabhain/rails_onboarding/tree/v0.8.1
286
286
  changelog_uri: https://github.com/bunnahabhain/rails_onboarding/blob/master/docs/CHANGELOG.md
287
287
  rdoc_options: []
288
288
  require_paths: