Jerky NSScrollView scrolling at certain angles on Yosemite (when using layers) - cocoa

I have an NSScrollview with a large canvas that can be scrolled and zoomed etc. When I scroll diagonally at an angle of around 20 degrees from vertical it's really jerky (using a track pad.) This jerkiness even continues as the scrolling animates to rest.
All other angles of scroll are buttery smooth - which makes me think it's got something to do with a preference for vertical scrolling (predominant axis scrolling is disabled.)
The effect only seems to happen when I'm using layer backed views.
Anyone know what's going on here?
Thanks
Craig

Confirmed bug in OSX Yosemite (by Apple DTS)

Related

How to prevent jerking and horizontal drift when vertical scrolling in a MacOS NSScrollView

In a MacOS application being written in Swift, I have a vanilla, sub-classed NSScrollView that allows magnification. The documentView it presents is not very wide and completely fits horizontally within the bounds of the NSScrollView's display area. But the document is very long, and so it scrolls vertically.
When I pan slowly using a two-finger gesture on my trackpad, the NSScrollView prevents any horizontal movement (other than a little springiness). Panning vertically also works as expected.
When I pan vertically hard (with a little flick to it) and let go, the scrolling in that direction continues for a little while with virtual momentum, then slows down and stops. Again, all seems correct.
Sometimes, though, scrolling jerks to an immediate stop, based on some difference (I presume) in how Apple's internal (default) NSPanGestureRecognizer analyzes the movement. The jerking to a stop is unwanted and frustrating. It seems to only occur when the document has been zoomed out. When zoomed in, the jerking doesn't happen after a trackpad flick. So the difference likely has to do with the gesture recognizer working in the screen coordinate system, rather than the magnified coordinate system of the NSScrollView.
The other problem is that if the pan gesture is strong, and has any diagonal direction to it (which is most of the time, since it's really hard to flick on the trackpad perfectly vertically), the automatic, continual scrolling drifts the document view right or left in that diagonal direction, even though there's no reason to and it's normally pinned horizontally. For very long continuous scrolls, the document view even drifts completely outside the visible bounds, which is kind of ridiculous. Then, when the continuous scrolling stops, the NSScrollView instantly (without continuous scrolling) jumps the documentView completely back into view (horizontally).
The same drifting analogously occurs when doing horizontal continuous scrolling for documents that are very wide and not very high.
This drifting during continuous scrolling after the gesture has finished occurs regardless of whether any centering constraint is in effect, a là this stackoverflow question and answer.
So ... is there a way to prevent this jerking and this drifting during continuous scrolling in an NSScrollView?
Willeke's advice seems to be spot-on. It also solves the jerkiness problem, for reasons I don't understand. The sub-classed NSScrollView is now:
class MyScrollView : NSScrollView {
override init(frame fr: NSRect)
{
super.init(frame: fr)
prepareScrolling()
}
required init?(coder: NSCoder)
{
super.init(coder: coder)
prepareScrolling()
}
private func prepareScrolling()
{
self.allowsMagnification = true
self.usesPredominantAxisScrolling = true // <-- Added to fix the problem
self.maxMagnification = 4.0
self.minMagnification = 0.25
}
// Etc.
}

SKCameraNode positioning on Mac: non-retina vs retina

I have a game that I’m porting from iOS to MacOS. On iOS, everything functions as it should on retina and non-retina devices. On Mac, it’s a different story.
I have two class properties: upperCameraPos and lowerCameraPos
The game is in a window and the scene is twice the height of this window’s content view (SKView). When the game starts. the camera node is positioned at lowerCameraPos, revealing the bottom half of the scene. When a button is pressed, SKAction’s moveToPoint: method is used to scroll the scene up, revealing the top half. On retina and 4K Macs, this works as expected.
However, on non-retina Macs (tested on late ’07 iMac & late ’08 MacBook), the same code for setting the camera’s initial position does not reveal the lower half of the scene, but rather shows the middle of the scene (which is the camera's default position).
I’ve done a considerable amount of searching and haven’t found any explanation for this. Does anyone know if there are any issues between retina & non-retina when positioning a camera node in a scene on Mac?
I figured out what I was doing wrong. I had the scene's scale mode set to SKSceneScaleModeAspectFill. After changing the scale mode to SKSceneScaleModeResizeFill, the camera node now scales to the correct parts of the scene regardless of whether the screen is retina or non-retina.

NSImageView within NSScrollView downward drift

I have a NSScrollView with a NSImageVIew within.
I'm using magnification enabled on NSScrollView.
I'm seeing a funny downward drift of the NSImageView when scaling using a 'pinch' gesture on my MBP track pad.
If you pinch and un-pinch continuously ... zooming in and out, the image drifts downwards within the NSScrollView. Can't explain it or locate bug.
See here > https://github.com/BinaryBlobs/ScrollViewBug
What am I doing wrong ?

Adobe Edge Animation Mouse Wheel Smooth Scroll

I have made parallax scrolling by using Adobe Edge Animation there is a problem with scroll by mouse wheel. How can i make it smooth.
http://bestbuypakistan.com/Oil/Oil.html
To me it looks like your animations stall every few pixels as you're scrolling. This is simply in the fluid motion of the animation.
You'll need to redo the keyframing for the animations and it seems like you're using x and y to animate the motions. Try using motion paths instead to get a more fluid and slick feel to the effect.
I know this isn't much of an answer, but I hope I was able to help in some way! :)
Cheers!

How does UIScrollView like scrolling work?

in my opinion the iPhone has a big advantage to other smartphones because of its intuitive, smooth and good feeling scrolling components in UIKit. I want to implement a simple game with UIKit which uses this kind of scrolling, but i can't use UIScrollView because it isn't customizable enough.
I tried to implement this scrolling myself and tried two different approaches:
I used a UIPanGestureRecognizer und moved the bounds of my custom control according to the translation the recognizer delivers me. In order to get this smooth scrolling after lifting my finger during the movement I start an animation. I use the velocity the recognizer gives me and a fixed time in order to calculate how far it should scroll after I lifted my finger. I tryed a linear movement and a ease-out movement, but both looks strange. (more later on that)
I use OnTouchMoved and OnTouchEnded to implement the scrolling. In OnTouchMove I move the bounds according to the movment of the finger. While the finger moves I calculate the difference in location and time of the current and last touch in order to calculate a velocity myself. When the finger lifts I start an animation in OnTouchEnded like in 1. but I use my self-calculated velocity instead.
Both approaches are not giving me the results I want. After lifting my finger, the scrolling is not smoothly continued. There seems to be a (sharp) bend in the celocity curve.
Has anyone an idea how apple does this smooth scrolling? My current guess is that my interpolation with two really close points is to inaccurate and doesn't take the current acceleration into account.
Thx for your thoughts!
Kie
Why don't you add a UIScrollView as handle on top of your view, without visible content. Then you can use the UIScrollViewDelegate methods to update your real view on certain actions. For example: if you capture the scrolling of the UIScrollView using scrollViewDidScroll: , you can update your visible view with the offset of the scrollview. You can use the scrollViewWillEndDragging: to start synchronizing the main view with the scrollview, and scrollViewDidEndDecelerating to stop synchronizing.
I use the same approach to scroll the background of my Animix app. It has an invisible scrollview at the bottom, to give the user the feeling he can drag the grass to the left and right to move the background.

Resources