Skip to content

Instantly share code, notes, and snippets.

@stevemayhew
Last active August 29, 2015 14:00
Show Gist options
  • Save stevemayhew/11222059 to your computer and use it in GitHub Desktop.
Save stevemayhew/11222059 to your computer and use it in GitHub Desktop.
qTip2 Flip Issue with hidden 'at' position.
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>Flip bug with Overflow</title>
<link rel="stylesheet" type="text/css" href="http://cdn.jsdelivr.net/qtip2/2.1.1/jquery.qtip.css">
<link rel="stylesheet" type="text/css" href="qtip-bug.css">
<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script type="text/javascript" src="http://cdn.jsdelivr.net/qtip2/2.1.1/jquery.qtip.js"></script>
<script type="text/javascript" src="qtip-bug.js"></script>
</head>
<body>
<h1>Overflow Flip Test</h1>
<div class="ovf-container">
<ul>
<li>One</li>
<li>Two</li>
<li>Three</li>
</ul>
</div>
</body>
</html>
div.ovf-container {
margin: 10px;
width: 200px;
height: 100px;
padding: 5px;
border: 1px solid red;
overflow: hidden;
position: relative;
}
.ovf-container ul {
list-style: none;
list-style-type: none;
position: absolute;
width: 1000px;
margin: 0;
padding: 0;
-moz-padding-start: 0;
}
.ovf-container li {
display: inline-block;
width: 90px;
height: 100px;
background: green;
}
$(function() {
$('li').qtip({
target: $('body'),
content: "I'm a Simple Tip",
style: {
classes: 'qtip-shadow qtip-rounded'
},
position: {
my: 'left center',
at: 'right center',
viewport: $(window),
adjust: {
method: 'flip shift',
resize: false,
scroll: false,
mouse: false
}
}
});
})
@stevemayhew
Copy link
Author

As you can see the 'right center' corner is hidden by overflow from (the last

  • , "three" in the carousel), but qTip2's flip algorithm does not account for this.

    While this may seem a strange case, it's a common way carousels of images are done.

    Of course the desired behavior would be a flip, even though the tooltip fits the viewport.

  • @Craga89
    Copy link

    Craga89 commented Apr 26, 2014

    You need to set the position.viewport property to the overflow container, not the window :)

    viewport: $('.ovf-container'),

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment