Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Solved] iPad: qTip position is incorrect, offset by scroll
18th February, 22:38 (This post was last modified: 18th February 22:40 by kiddailey.)
Post: #1
[Solved] iPad: qTip position is incorrect, offset by scroll
Craig:

Saw your twitter note about iPad compliance. Looks like you haven't had a chance to respond to my reply saying that I had one and would love to help you test, so thought I'd just start posting the bugs for you. Let me know if you'd prefer these done somewhere else, or in a different way.

In some cases, the qTip's position is offset by the scroll amount, making it disconnected from the trigger. For example, with the following init:

JS Code
$('.selector').qtip({
	content: {
		text: $(this).html()
	},
	style: {
		tip: {
			corner: true,
			width: 20,
			height: 10,
			border: 0
		}
	},
	position: {
		my: "top center",
		at: "bottom center",
		adjust: {
			y: 5,
			x: 250
		}
	},
	show: {
		event: 'click'
	},
	hide: {
		fixed: true,
		solo: true,
		event: null
	},
	prerender: false
});

If the user is at the top of the page, the tip is positioned correctly. However, if the user scrolls before opening the tooltip, the y position will be offset by the amount of scroll.
Forgot to mention that I don't see this with all tooltips. All of my center/center tooltips display with the correct positioning initially.
Find all posts by this user
Quote this message in a reply
19th February, 16:04
Post: #2
RE: iPad: qTip position is incorrect, offset by scroll
This seems like it may be connected to your other post about disconnect... wish I had an iPad of mine to test this out on! Remote debugging is such a pain heh... I'll have another look at the code tonight!

Craig Thompson
Web Developer / Designer
Craigsworks
http://www.craigsworks.com
Visit this user's website Find all posts by this user
Quote this message in a reply
19th February, 22:14 (This post was last modified: 19th February 22:15 by kiddailey.)
Post: #3
RE: iPad: qTip position is incorrect, offset by scroll
If you have an OS X machine handy, you can download the developer tools which comes with a simulator, which is almost as good as the real thing.

In any case, you are right - this might be related, but i'm not entirely sure. I was planning on putting together a little video of the interaction so you could see just what's going on. Much better than trying to explain.
Find all posts by this user
Quote this message in a reply
20th February, 01:55
Post: #4
RE: iPad: qTip position is incorrect, offset by scroll
FYI: Sent you a PM with a link to the video.
Find all posts by this user
Quote this message in a reply
21st February, 11:08
Post: #5
RE: iPad: qTip position is incorrect, offset by scroll
Great, thanks kiddailey. This is definitely a scroll problem with the position calculations. Can you test to make sure this returns true when pasted into the iPad location bar on a page with qTip:

JS Code
j avascript:alert($.fn.qtip.plugins.iOS);


If true, could you test to see if this fixes the scroll issue (can also paste it into the location bar, no need to refresh the page, just paste and re-test positioning):

JS Code
j avascript:$.fn.qtip.plugins.offset = function(elem, container) {  var pos = elem.offset(),  parent = container,  deep = 0,  docBody = document.body,  coffset;   function scroll(e) {  pos.left -= e.scrollLeft();  pos.top -= e.scrollTop();  }   if(parent) {  do {  if(parent[0] === docBody) { break; }  else if(parent.css('position') !== 'static') {  coffset = parent.position();  pos.left -= coffset.left;  pos.top -= coffset.top;   deep++;  }  }  while(parent = parent.offsetParent());   if(container[0] !== docBody) { scroll( container ); }  if($.fn.qtip.plugins.iOS) { scroll( $(window) ); }  }   return pos;  }

Craig Thompson
Web Developer / Designer
Craigsworks
http://www.craigsworks.com
Visit this user's website Find all posts by this user
Quote this message in a reply
22nd February, 02:32
Post: #6
RE: iPad: qTip position is incorrect, offset by scroll
Got "true" on the first one and the second one definitely fixes it! Hooray!! Big Grin

The only thing I will say is that the center/center viewport adjusting on the iPad in landscape mode causes the tips to feel "jumpy" as it did on my netbook -- because they align to the top/bottom of the trigger rather than the screen. The reasoning ties back to my last couple of posts in the ominous "adjusts too far" thread, which I'm not sure you saw.
Find all posts by this user
Quote this message in a reply
23rd February, 00:28
Post: #7
RE: [Solved] iPad: qTip position is incorrect, offset by scroll
Awesome! I'm taking a look into that now.

Craig Thompson
Web Developer / Designer
Craigsworks
http://www.craigsworks.com
Visit this user's website Find all posts by this user
Quote this message in a reply
23rd February, 01:41
Post: #8
RE: [Solved] iPad: qTip position is incorrect, offset by scroll
Just wanted to say that with these last few iOS tweaks, it's looking pretty soild from a functional standpoint on the iPad/iPhone. There are a few things I haven't tested yet that might have some quirks (eg. modal dialogs, specifically the background shading because I know other plugins have issues with that), but I'll let you know if I see anything else.
Find all posts by this user
Quote this message in a reply
23rd February, 03:22
Post: #9
RE: [Solved] iPad: qTip position is incorrect, offset by scroll
Update: Just tested the modal stuff and it positions and displays perfectly on iOS.

You're going to have to spill your secrets about how you not only got the dark overlay to cover the entire body height, but also positioned the qTip in the center of the viewport! Wink Typically, modal stuff always appears at the top of the page with the overlay only covering the height of the viewport.
Find all posts by this user
Quote this message in a reply
23rd February, 18:06
Post: #10
RE: [Solved] iPad: qTip position is incorrect, offset by scroll
Here's the magic sauce you're looking for... straight from the horses mouth:

JS Code
// Create document overlay
overlay = elems.overlay = $('<div />', {
	id: selector.substr(1),
	css: {
		position: 'absolute',
		top: 0,
		left: 0,
		display: 'none'
	},
	mousedown: function() { return FALSE; }
})
.appendTo(document.body);
 
// Update position on window resize or scroll
$(window).bind('resize'+namespace, function() {
	overlay.css({
		height: Math.max( $(window).height(), $(document).height() ),
		width: Math.max( $(window).width(), $(document).width() )
	});
})
.trigger('resize');

Craig Thompson
Web Developer / Designer
Craigsworks
http://www.craigsworks.com
Visit this user's website Find all posts by this user
Quote this message in a reply
5th September, 15:57
Post: #11
RE: [Solved] iPad: qTip position is incorrect, offset by scroll
Hi,

I'm sorry for revisiting this 7 month old issue, but I'm experiencing this problem with qtip2 on the iPad2 using the SVG plugin.

I have quite a complicated SVG store plan, which I'm using qtip2 to display details about each store element (path) when moused over. Everything is working brilliantly on our desktop machines (mac/win) in all browsers.

However, on the iPad/iPhone (both running iOS 4.3) The positioning is perfect if the page is not scrolled. If I tap the element to show the tooltip, it appears where I expect it. It also tracks and moves with the target correctly when the page is scrolled. However, once I've scrolled down the page a little, if I show another tooltip, the positioning is offset on the y axis by the same amount as the page has been scrolled.

I attempted to run the code suggestions above, but instead of 'true', I get '4.3' when running the first example and the second example does nothing at all.

I have made sure that I have the latest version of the code and downloaded again today to double check but the problem persists.

Is this fix supposed to be in the current code or is there something I need to do at my end to achieve the correct positioning or am I missing something else?

Thanks, in advance, for any help you can offer.

Matt
Find all posts by this user
Quote this message in a reply
5th September, 16:21
Post: #12
RE: [Solved] iPad: qTip position is incorrect, offset by scroll
Can you post the results of tryping this in the address bar of your iPhone/iPad and hitting enter please?
JS Code
alert($.fn.qtip.plugins.iOS)


Also, what happens if you set $.fn.qtip.plugins.iOS to true and before creating your qTips? Usually the issue is fixed, but then the offset is off on the desktop browsers instead.

Craig Thompson
Web Developer / Designer
Craigsworks
http://www.craigsworks.com
Visit this user's website Find all posts by this user
Quote this message in a reply
6th September, 08:35 (This post was last modified: 6th September 08:37 by mkeeble.)
Post: #13
RE: [Solved] iPad: qTip position is incorrect, offset by scroll
(5th September 16:21)Craig Wrote:  Can you post the results of tryping this in the address bar of your iPhone/iPad and hitting enter please?
JS Code
alert($.fn.qtip.plugins.iOS)


Also, what happens if you set $.fn.qtip.plugins.iOS to true and before creating your qTips? Usually the issue is fixed, but then the offset is off on the desktop browsers instead.

Hi Craig,

If I simply type in
JS Code
j avascript:alert($.fn.qtip.plugins.iOS);
I get the response "4.3" (the version of iOS that is running on my iPad/iPhone.

If I explicitly set the parameter to 'true' it makes no difference unfortunately. I don't know if this is relevant but I am testing on iPad 2 and iPhone 4... I don't have any earlier versions to test on at present...
Find all posts by this user
Quote this message in a reply
6th September, 12:28
Post: #14
RE: [Solved] iPad: qTip position is incorrect, offset by scroll
Huh that's odd... it gives out 4.3? It should be a boolean that's output... are you sure you're using the latest code?

Craig Thompson
Web Developer / Designer
Craigsworks
http://www.craigsworks.com
Visit this user's website Find all posts by this user
Quote this message in a reply
6th September, 12:34
Post: #15
RE: [Solved] iPad: qTip position is incorrect, offset by scroll
Absolutely - I downloaded a fresh copy yesterday as that was the first thought that crossed my mind. But it definitely produces "4.3" (ie: the version of the OS) rather than 'true' unless I explicitly set it as 'true'
Find all posts by this user
Quote this message in a reply
6th September, 12:58
Post: #16
RE: [Solved] iPad: qTip position is incorrect, offset by scroll
Oh sorry my bad it should only a be a bool if it isn't iOS. So you're saying the offset bug isn't fixed in 4.3? What happens if you set it to 4.0 and then try the positioning?

Craig Thompson
Web Developer / Designer
Craigsworks
http://www.craigsworks.com
Visit this user's website Find all posts by this user
Quote this message in a reply
6th September, 13:00
Post: #17
RE: [Solved] iPad: qTip position is incorrect, offset by scroll
I do get 'false' if I test it in my desktop browser.

Not quite sure I understand Craig. Do you mean revertt my iPad to 4.0? or manually set the value in my code?
Find all posts by this user
Quote this message in a reply
6th September, 13:38
Post: #18
RE: [Solved] iPad: qTip position is incorrect, offset by scroll
Oh no just set the $.fn.plugins.iOS value to 4.0, which should trigger the repositioning fix for that version. I was led to understand that is bug as fixed in 4.2 but perhaps not...

Craig Thompson
Web Developer / Designer
Craigsworks
http://www.craigsworks.com
Visit this user's website Find all posts by this user
Quote this message in a reply
6th September, 13:39 (This post was last modified: 6th September 13:44 by mkeeble.)
Post: #19
RE: [Solved] iPad: qTip position is incorrect, offset by scroll
I'll check it out and let you know Smile

UPDATE:
I'm afraid that hasn't fixed it Craig. I've verified that the '4.0' value is now reaching the page, but the positioning is still incorrect when the page is scrolled at all (by the amount of the scroll it would seem).

Could it be anything to do with the fact that the tips have SVG paths as their targets? I don't know if that would make a difference, but I've read elsewhere on the forum that this bug was fixed and it seems strange that I'm still having it. Just a thought...
Find all posts by this user
Quote this message in a reply
6th September, 15:04
Post: #20
RE: [Solved] iPad: qTip position is incorrect, offset by scroll
Hmm can you try out the latest commit please and see if that fixes it? The previous commits only applied the iOS fix to regular elements, not imagemap or SVG elements, which was probably causing the problem. I also added a clause to include 4.3 in the iOS fix, so hopefully you should just be able to call it regularly without any need to set the $.fn.qtip.plugins.iOS value.

Craig Thompson
Web Developer / Designer
Craigsworks
http://www.craigsworks.com
Visit this user's website Find all posts by this user
Quote this message in a reply
6th September, 15:05 (This post was last modified: 6th September 15:08 by mkeeble.)
Post: #21
RE: [Solved] iPad: qTip position is incorrect, offset by scroll
I will have a look now Craig and let you know how I get on. Thanks
Craig, just looked on github and the last commit I can see is from 30 August... am I in the right place? Could you post a link?

Thanks
Find all posts by this user
Quote this message in a reply
6th September, 16:47
Post: #22
RE: [Solved] iPad: qTip position is incorrect, offset by scroll
Sorry that's my bad, had some unstaged changes that were preventing my push. It should be up now.

Craig Thompson
Web Developer / Designer
Craigsworks
http://www.craigsworks.com
Visit this user's website Find all posts by this user
Quote this message in a reply
6th September, 20:59
Post: #23
RE: [Solved] iPad: qTip position is incorrect, offset by scroll
Craig, sorry for the delay - I've checked the update now and it works great. Thanks so much!
Find all posts by this user
Quote this message in a reply
30th September, 04:40
Post: #24
RE: [Solved] iPad: qTip position is incorrect, offset by scroll
Craig,

Somehow I am still seeing the problem reported in the original post, i.e., the qTip's position is offset by certain scroll amount on iPad. The same page otherwise works fine in IE/FF/Chrome. I am using the latest qtip2 from the github dated Sep 20 based on the timestamp inside the JS/CSS files. I setup a simple example at http://jsfiddle.net/fDavN/1856/ and somehow I am not seeing the same problem there. Wonder if you could help pointing me in the right direction? Thanks.

Kaihu
Find all posts by this user
Quote this message in a reply
30th September, 14:57
Post: #25
RE: [Solved] iPad: qTip position is incorrect, offset by scroll
What is your $.fn.plugins.iOS set to? (Paste jalert($.fn.plugins.iOS)) into your location bar when on the page containing the qTip script)

Craig Thompson
Web Developer / Designer
Craigsworks
http://www.craigsworks.com
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  [Solved] qTip Position not working? jvanr 2 161 23rd April 13:58
Last Post: jvanr
  [Solved] Qtip position when link gets bocken between lines fspade 2 228 13th March 06:49
Last Post: fspade
  [Solved] Problem with horizontal scroll evaliauka 12 595 8th February 04:37
Last Post: evaliauka
  qTip Position based on screen location Big Al 3 582 14th January 15:58
Last Post: Craig
  [Solved] Position ccdavies 1 270 16th December 09:01
Last Post: Craig
  [Solved] Help with position redmile 2 452 24th November 18:13
Last Post: redmile
  [Solved] qtip on gmap v3 - position adjustment elgransan 2 897 13th September 16:11
Last Post: elgransan
  iPad Bug ( solo: true ) medj 1 705 7th September 21:17
Last Post: Craig
  [Solved] how to position mmjaeger 1 348 20th August 17:29
Last Post: Craig
  [Solved] iPad: qTips become disconnected when scrolling kiddailey 6 1,441 16th August 12:34
Last Post: Craig



User(s) browsing this thread: 1 Guest(s)