Skip to content

Commit 99258ad

Browse files
committed
Fix tooltip position problem with left and right, related to usablica#115
1 parent 3b0fb0f commit 99258ad

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

intro.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -247,36 +247,35 @@
247247
* @param {Object} arrowLayer
248248
*/
249249
function _placeTooltip(targetElement, tooltipLayer, arrowLayer) {
250-
var tooltipLayerPosition = _getOffset(tooltipLayer);
251250
//reset the old style
252251
tooltipLayer.style.top = null;
253252
tooltipLayer.style.right = null;
254253
tooltipLayer.style.bottom = null;
255254
tooltipLayer.style.left = null;
256255

257-
//prevent error when `this._currentStep` in undefined
256+
//prevent error when `this._currentStep` is undefined
258257
if(!this._introItems[this._currentStep]) return;
259258

260259
var currentTooltipPosition = this._introItems[this._currentStep].position;
261260
switch (currentTooltipPosition) {
262261
case 'top':
263262
tooltipLayer.style.left = '15px';
264-
tooltipLayer.style.top = '-' + (tooltipLayerPosition.height + 10) + 'px';
263+
tooltipLayer.style.top = '-' + (_getOffset(tooltipLayer).height + 10) + 'px';
265264
arrowLayer.className = 'introjs-arrow bottom';
266265
break;
267266
case 'right':
268-
tooltipLayer.style.right = '-' + (tooltipLayerPosition.width + 10) + 'px';
267+
tooltipLayer.style.left = (_getOffset(targetElement).width + 20) + 'px';
269268
arrowLayer.className = 'introjs-arrow left';
270269
break;
271270
case 'left':
272271
tooltipLayer.style.top = '15px';
273-
tooltipLayer.style.left = '-' + (tooltipLayerPosition.width + 10) + 'px';
272+
tooltipLayer.style.right = (_getOffset(targetElement).width + 20) + 'px';
274273
arrowLayer.className = 'introjs-arrow right';
275274
break;
276275
case 'bottom':
277276
// Bottom going to follow the default behavior
278277
default:
279-
tooltipLayer.style.bottom = '-' + (tooltipLayerPosition.height + 10) + 'px';
278+
tooltipLayer.style.bottom = '-' + (_getOffset(tooltipLayer).height + 10) + 'px';
280279
arrowLayer.className = 'introjs-arrow top';
281280
break;
282281
}

introjs.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@
117117
padding: 10px;
118118
background-color: white;
119119
min-width: 200px;
120+
max-width: 300px;
120121
border-radius: 3px;
121122
box-shadow: 0 1px 10px rgba(0,0,0,.4);
122123
-webkit-transition: opacity 0.1s ease-out;

0 commit comments

Comments
 (0)