Fix grid scroll position resetting to 0

The problem was that the index of the scrollbars was not being updated.
Therefore, it was always being reset to 0 each time the animation frame
is requested.

Fixed this by updating the index of the scrollbars. This also eliminates
the need to call the grid's scrollBy method.
'use strict';

var Feature = require('./Feature');

/**
 * @constructor
 * @extends Feature
 */
var TouchScrolling = Feature.extend('TouchScrolling', {
    handleTouchStart: function(grid, event) {
        this.lastTouch = this.getTouchedCell(grid, event);
    },

    handleTouchMove: function(grid, event) {
        var currentTouch = this.getTouchedCell(grid, event);
        var lastTouch = this.lastTouch;

        var xOffset = (lastTouch.x - currentTouch.x) / lastTouch.width;
        var yOffset = (lastTouch.y - currentTouch.y) / lastTouch.height;

        grid.sbHScroller.index = grid.sbHScroller.index + xOffset;
        grid.sbVScroller.index = grid.sbVScroller.index + yOffset;

        this.lastTouch = currentTouch;
    },

    getTouchedCell: function(grid, event) {
        var point = event.detail.touches[0];
        return grid.getGridCellFromMousePoint(point).cellEvent.bounds;
    }
});

module.exports = TouchScrolling;

'use strict';

var Feature = require('./Feature');

/**
 * @constructor
 * @extends Feature
 */
var TouchScrolling = Feature.extend('TouchScrolling', {
    handleTouchStart: function(grid, event) {
        this.lastTouch = this.getTouchedCell(grid, event);
    },

    handleTouchMove: function(grid, event) {
        var currentTouch = this.getTouchedCell(grid, event);

        var xOffset = this.lastTouch.x - currentTouch.x;
        var yOffset = this.lastTouch.y - currentTouch.y;

        grid.scrollBy(
            xOffset / this.lastTouch.width,
            yOffset / this.lastTouch.height
        );

        this.lastTouch = currentTouch;
    },

    getTouchedCell: function(grid, event) {
        var point = event.detail.touches[0];
        return grid.getGridCellFromMousePoint(point).cellEvent.bounds;
    }
});

module.exports = TouchScrolling;
