UNPKG

fc-react-slider

Version:
34 lines (24 loc) 1.1 kB
'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = function (e, props, sliderWidth) { // Get the offset DIRECTION relative to the viewport var coordinate = _constants2.default[props.orientation].coordinate; var direction = _constants2.default[props.orientation].direction; var ucCoordinate = (0, _utils.capitalize)(coordinate); var trackPos = props.trackOffset[direction]; var btnPos = 0; if (typeof e['page' + ucCoordinate] !== 'undefined') { btnPos = e['page' + ucCoordinate]; } else if (e && typeof e['client' + ucCoordinate] !== 'undefined') { btnPos = e['client' + ucCoordinate]; } else if (e.touches && e.touches[0] && typeof e.touches[0]['client' + ucCoordinate] !== 'undefined') { btnPos = e.touches[0]['client' + ucCoordinate]; } return btnPos - trackPos - sliderWidth / 2; }; var _utils = require('../utils'); var _constants = require('../constants'); var _constants2 = _interopRequireDefault(_constants); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }