Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
Size: Mime:
"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});

const exotic_1 = require("exotic");

const offsetCollection = {
  startOffset: 0,
  endOffset: 0,
  itemWidth: 0,
  offsetArray: []
};

const handleTouchStart = event => {
  offsetCollection.itemWidth = event.target.clientWidth;

  if (!exotic_1.isNonEmptyArray(event.touches) === true) {
    offsetCollection.startOffset = event.touches[0].clientX;
  }
};

exports.handleTouchStart = handleTouchStart;

const handleTouchMove = event => {
  if (!exotic_1.isNonEmptyArray(event.touches) === true) {
    offsetCollection.offsetArray.push(event.touches[0].clientX);
  }
};

exports.handleTouchMove = handleTouchMove;

const handleTouchEnd = (event, state, props) => {
  const arrayLength = offsetCollection.offsetArray.length;
  offsetCollection.endOffset = offsetCollection.offsetArray[arrayLength - 1];
  performSwipe(state, props);
};

exports.handleTouchEnd = handleTouchEnd;

const handleDragStart = event => {
  event.preventDefault();
  offsetCollection.itemWidth = event.target.clientWidth;
  offsetCollection.startOffset = event.clientX;
};

exports.handleDragStart = handleDragStart;

const handleDragEnd = (event, state, props) => {
  offsetCollection.endOffset = event.clientX;
  performSwipe(state, props);
};

exports.handleDragEnd = handleDragEnd;

const performSwipe = (state, props) => {
  const {
    step,
    toNext,
    toPrevious
  } = state;
  const {
    gridGap
  } = props;
  /**
   * threshold for swiping: minimum limit 25% hence dividing it by 4
   */

  const scrollLimit = step * (offsetCollection.itemWidth + exotic_1.fromIshToNumber(gridGap)) / 4;
  const offsetDifference = offsetCollection.startOffset - offsetCollection.endOffset;

  if (offsetDifference >= scrollLimit) {
    toNext();
  } else if (-offsetDifference >= scrollLimit) {
    toPrevious();
  }
};

exports.performSwipe = performSwipe; //# sourceMappingURL=handlers.js.map