Search code examples
iosswiftscrolluiwebviewwkwebview

swift 3 - reverse scrolling. can it be done?


I have tried several options in order to implement reverse scrolling, but nothing seems to work. The best example for what I am trying to do can be found in this link:

https://codepen.io/patrikhjelm/pen/klcnj

$(document).ready(function(){ 
     $(window).scroll(function(){
       $('.right').css('transform', 'translate3d(0,' + $(this).scrollTop()*2 + 'px, 0)'); 
    }).scroll();
});  

(I would explain with words but the visual in this case is much more expressive..)

I have already tried programming in JS while using UIWebView and WKWebView - but the scroll seems really choppy (I mean like really really choppy)

I was looking into SpriteKit before I decided to write here cause things just were not adding up. Has anyone had this particular demand and managed to solve it?

Thank - you


Solution

  • problem solved!

    Just use view.frame.origin.y = scrollView.contentOffset.y * 2

    works like a charm.