Y
Y
yarikus2015-01-25 01:15:49
JavaScript
yarikus, 2015-01-25 01:15:49

How to make scrolling for Paper.js?

I'm trying to make scrolling for Paper.js. There is a Canvas element for which the dragup and dragdown events fire. I get the event object and substitute the deltaY value as the offset for the scrollBy method.

function dragUp(event) {
        paper.view.scrollBy(new paper.Point(0, event.gesture.deltaY));
      }
      function dragDown(event) {
        paper.view.scrollBy(new paper.Point(0, event.gesture.deltaY));
      }

      element.on('dragup', dragUp).on('dragdown', dragDown);

Scrolling works, but it turns out ugly. I want kinetic scrolling like on iOS, so that everything is smooth and smooth. I didn’t go to physics at school, so I don’t even know how to approach the problem. But if it's too non-trivial, then just normal scrolling will do. What is the formula for doing this?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question