Skip to content
This repository was archived by the owner on Feb 17, 2021. It is now read-only.

Commit bc7a1ce

Browse files
author
Gordon Koo
committed
change the way top-oriented bubbles are rendered
1 parent 3955216 commit bc7a1ce

File tree

5 files changed

+46
-46
lines changed

5 files changed

+46
-46
lines changed

index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ <h2 id="subheading" class="one two three">Content</h2>
5151
<img id="wave" src="http://i.imgur.com/s632o.jpg">
5252
</div>
5353
<div class="img-container">
54-
<img id="python" src="http://i.imgur.com/mIgyw.jpg">
54+
<img id="google" src="https://www.google.com/images/srpr/logo3w.png">
5555
</div>
5656
<div class="img-container">
5757
<img class="mission" src="http://cdn.theatlanticcities.com/img/upload/2012/07/19/20120719-mission1/largest.jpg">

js/debug.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@ for (i = 0, len = booleanControls.length; i < len; i++) {
9898
id: 'mycallout',
9999
title: 'Title',
100100
content: 'Content',
101-
target: 'python',
102-
orientation: 'left',
101+
target: 'google',
102+
orientation: 'top',
103103
showNavButtons: false,
104104
showNumber: false
105105
});
@@ -138,7 +138,7 @@ var tour2 = {
138138
{
139139
title: 'Python decorator',
140140
content: 'Whoa, did you notice that the page just scrolled? If you didn\'t, you aren\'t very observant. (Or you have a very tall monitor)',
141-
targetId: 'python',
141+
targetId: 'google',
142142
orientation: 'top',
143143
xOffset: 200
144144
}

js/exampletour.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ var tour = {
7474
{
7575
title: 'Python decorator',
7676
content: 'Whoa, did you notice that the page just scrolled? If you didn\'t, you aren\'t very observant. (Or you have a very tall monitor)',
77-
target: 'python',
77+
target: 'google',
7878
orientation: 'top',
7979
xOffset: 200
8080
}

js/hopscotch-0.0.4.js

+19-19
Original file line numberDiff line numberDiff line change
@@ -526,12 +526,7 @@
526526
self.destroy();
527527
}
528528

529-
if (evt.preventDefault) {
530-
evt.preventDefault();
531-
}
532-
else if (event) {
533-
event.returnValue = false;
534-
}
529+
utils.evtPreventDefault(evt);
535530
};
536531
}
537532
return this.closeFn;
@@ -607,7 +602,7 @@
607602
* @param {Function} callback Function to be invoked after rendering is finished.
608603
*/
609604
render: function(step, idx, isLast, callback) {
610-
var self = this,
605+
var el = this.element,
611606
showNext,
612607
showPrev,
613608
bubbleWidth,
@@ -652,20 +647,25 @@
652647
this.containerEl.style.width = bubbleWidth + 'px';
653648
this.containerEl.style.padding = bubblePadding + 'px';
654649

655-
this.element.style.zIndex = (step.zindex ? step.zindex : '');
650+
el.style.zIndex = (step.zindex ? step.zindex : '');
656651

657652
if (step.orientation === 'top') {
658-
// Timeout to get correct height of bubble for positioning.
659-
setTimeout(function() {
660-
self.setPosition(step);
661-
// only want to adjust window scroll for non-fixed elements
662-
if (callback && !step.fixedElement) {
663-
callback();
664-
}
665-
else {
666-
self.show();
667-
}
668-
}, 5);
653+
// For bubbles placed on top of elements, we need to get the
654+
// bubble height to correctly calculate the bubble position.
655+
// Show it briefly offscreen to calculate height, then hide
656+
// it again.
657+
el.style.top = '-9999px';
658+
el.style.left = '-9999px';
659+
utils.removeClass(el, 'hide');
660+
this.setPosition(step);
661+
utils.addClass(el, 'hide');
662+
// only want to adjust window scroll for non-fixed elements
663+
if (callback && !step.fixedElement) {
664+
callback();
665+
}
666+
else {
667+
this.show();
668+
}
669669
}
670670
else {
671671
// Don't care about height for the other orientations.

0 commit comments

Comments
 (0)