The swipe indicator appears behind content within the webview (proposed solution)
Hi,
The bug I was having was that the indicators that appear when you swipe were displaying behind certain DOM elements within my web view (I heavily use zIndex CSS properties on my elements).
In order to fix this problem I modified - (void)launchDrawTimer of DHSwipeClipView.m to the following:
- (void)launchDrawTimer
{
// a timer is needed because events are queued and processing and drawing
// takes longer than they are delivered, so the queue fills up
if(!drawTimer || ![drawTimer isValid])
{
self.drawTimer = [NSTimer scheduledTimerWithTimeInterval:1.0f/25 target:webView.swipeIndicator selector:@selector(display) userInfo:nil repeats:NO];
// keep indicators at top (I added this)
NSView *v = webView.swipeIndicator.superview;
[webView.swipeIndicator removeFromSuperview];
[v addSubview: webView.swipeIndicator];
}
}
Did I miss something? Or should I be fine doing this.
The draw timer is needed in order to delay the drawing of the swipe indicator view so that the main thread is not blocked and the events flow smoothly. By removing the swipe indicator view and re-adding it you trigger a redraw (as far as I know), which should do exactly what the timer was meant to prevent.
Is everything working smoothly after you added that?
Yes, everything seems to work smoothly.
On an unrelated note though when my cursor is active within a scrollable DOM element within the webview, two-finger swipe gestures do not work.
I just tested it and it seems to work fine on my end too. Do make sure to test it with 10.7 / 10.6 if you're targeting that.
Unrelated note: that would make sense, since it's only tracking the events of the main scroll view. I have no idea how to track events from a scroll view of a DOM element (JavaScript maybe?) I do not need that functionality though...
Sadly you cannot track a two finger scroll event in javascript using a trackpad or mouse, that's why I set out to find this library :P