Skip to content

Commit 0d5b1eb

Browse files
author
Yaron Nachshon
committed
bug fixes
1 parent 035efd7 commit 0d5b1eb

File tree

1 file changed

+27
-8
lines changed

1 file changed

+27
-8
lines changed

intro.js

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@
9696
function convertOuterPositionToOffset(element, target, position){
9797
var targetBoundingClientRect = $(target).get(0).getBoundingClientRect();
9898
var offset = {};
99-
10099
if(position === 'top'){
101100
offset.left = (targetBoundingClientRect.left + (targetBoundingClientRect.width / 2)) - (element.outerWidth() / 2);
102101
offset.top = targetBoundingClientRect.top - element.outerHeight();
@@ -118,21 +117,33 @@
118117
var delta;
119118
if((offset.left + width) > bodyBoundingClientRect.right){
120119
delta = (bodyBoundingClientRect.right - (offset.left + width));
121-
offset.left = offset.left + delta;
120+
offset.left = offset.left + delta - 30;
122121
}else if(offset.left < bodyBoundingClientRect.left){
123122
delta = bodyBoundingClientRect.left - offset.left;
124-
offset.left = offset.left + delta;
123+
offset.left = offset.left + delta + 30;
125124
}
126125
return offset;
127126
}
128127

129128
// refactor
130129
function outerPositionElement(element, target, position, offsetX, offsetY){
130+
$(element).css({
131+
left: 0
132+
});
133+
$(element).css({
134+
width: $(element).outerWidth()
135+
});
136+
131137
var offset = convertOuterPositionToOffset(element, target, position);
132138
offset.left += Number(offsetX || 0);
133139
offset.top += Number(offsetY || 0);
134140
offset = fitOffsetToScreen(offset, element.outerWidth());
135-
return element.offset(offset);
141+
142+
$(element).css({
143+
left: '',
144+
width: ''
145+
});
146+
return element.css(offset);
136147
}
137148

138149
function Modal(){
@@ -191,7 +202,7 @@
191202

192203
function repositionTooltipArrow(){
193204
var tooltipArrowElement = getTooltipArrowElement();
194-
var elementBoundingClientRect = that.element.get(0).getBoundingClientRect();
205+
var elementBoundingClientRect = targetElement.get(0).getBoundingClientRect();
195206
var left;
196207
var top;
197208

@@ -386,7 +397,9 @@
386397
unhighlighElement(element);
387398
});
388399
}
389-
hint && hint.hideTooltip();
400+
if(hint){
401+
hint.hideTooltip();
402+
}
390403
if(modal){
391404
modal.destroy();
392405
}
@@ -400,7 +413,9 @@
400413
}
401414

402415
function cleanup(){
403-
hint.destroy();
416+
if(hint){
417+
hint.destroy();
418+
}
404419
backdrop.remove();
405420
if(base.currentStep.element){
406421
unhighlighElement(base.currentStep.element);
@@ -458,7 +473,11 @@
458473
});
459474
}
460475

461-
476+
if(step.backdrop){
477+
backdrop.show();
478+
}else{
479+
backdrop.hide();
480+
}
462481

463482
if(!step.modal){
464483
return hint.render();

0 commit comments

Comments
 (0)