Scrollview Events


I was wondering if there was a way to get a callback when a Scrollview is done dragging so that I can center it on the nearest child.

Something along the lines of:


The only event for Scrollviews that I can find in the forums or online is ‘set:scroll’ but I just need to fire a method when the dragging is done.


There is but it’s not public API.

You can listen on the drag helpers events for drag:end

Thank you for your response!
Could you give an example of how to do that? I am not very clear what you mean by listen on the drag helpers for the scrollview.

Something like this?


Actually, just trying this myself and looking at the code, it’s not as easy as that unfortunately. Doesn’t feel like there’s a good way of doing this.

The closest I’ve got is this that uses the private API that is least likely to change:

var DragEnd = pc.createScript('dragEnd');

// initialize code called once per entity
DragEnd.prototype.initialize = function() {
    this._draggingLastFrame = this.entity.scrollview._isDragging();

// update code called every frame
DragEnd.prototype.update = function(dt) {
    var dragging = this.entity.scrollview._isDragging();
    if (this._draggingLastFrame && !dragging) {
        console.log('drag end');
    this._draggingLastFrame = dragging;

Hey thank you so much for getting a solution worked up for me! I really appreciate that!