Skip to content

Commit

Permalink
Fix the #34 issue [2];
Browse files Browse the repository at this point in the history
First approach was incorrect;
ToDo: cover custom renderers with tests.
  • Loading branch information
xobotyi committed Dec 24, 2018
1 parent 08030c7 commit 8eab40c
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 14 deletions.
18 changes: 12 additions & 6 deletions dist/Thumb.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ var _Track = _interopRequireDefault(require("./Track"));

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }

function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }

function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }

function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }

function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }

function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
Expand Down Expand Up @@ -160,12 +162,16 @@ function (_React$Component) {
props.className = "thumb " + (type === TYPE_X ? "thumbX" : "thumbY") + (className ? " " + className : "");
props.onMouseDown = this.handleDragStart;

props.ref = function (ref) {
typeof elementRef === "function" && elementRef(ref);
_this2.element = ref;
var ref = function ref(_ref) {
typeof elementRef === "function" && elementRef(_ref);
_this2.element = _ref;
};

return renderer ? renderer(props) : _react.default.createElement("div", props);
return renderer ? renderer(_objectSpread({}, props, {
elementRef: ref
})) : _react.default.createElement("div", _extends({}, props, {
ref: ref
}));
}
}]);

Expand Down
16 changes: 12 additions & 4 deletions dist/Track.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de

function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }

function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }

function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }

function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }

function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
Expand Down Expand Up @@ -84,12 +88,16 @@ function (_React$Component) {
props.className = "track " + (type === TYPE_X ? "trackX" : "trackY") + (className ? " " + className : "");
props.onClick = this.onClickHandler;

props.ref = function (ref) {
typeof elementRef === "function" && elementRef(ref);
_this2.element = ref;
var ref = function ref(_ref) {
typeof elementRef === "function" && elementRef(_ref);
_this2.element = _ref;
};

return renderer ? renderer(props) : _react.default.createElement("div", props);
return renderer ? renderer(_objectSpread({}, props, {
elementRef: ref
})) : _react.default.createElement("div", _extends({}, props, {
ref: ref
}));
}
}]);

Expand Down
12 changes: 10 additions & 2 deletions src/Thumb.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,19 @@ export default class Thumb extends React.Component {

props.className = "thumb " + (type === TYPE_X ? "thumbX" : "thumbY") + (className ? " " + className : "");
props.onMouseDown = this.handleDragStart;
props.ref = ref => {

const ref = ref => {
typeof elementRef === "function" && elementRef(ref);
this.element = ref;
};

return renderer ? renderer(props) : <div {...props} />;
return renderer ? (
renderer({
...props,
elementRef: ref,
})
) : (
<div {...props} ref={ref} />
);
}
}
12 changes: 10 additions & 2 deletions src/Track.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,19 @@ export default class Track extends React.Component {

props.className = "track " + (type === TYPE_X ? "trackX" : "trackY") + (className ? " " + className : "");
props.onClick = this.onClickHandler;
props.ref = ref => {

const ref = ref => {
typeof elementRef === "function" && elementRef(ref);
this.element = ref;
};

return renderer ? renderer(props) : <div {...props} />;
return renderer ? (
renderer({
...props,
elementRef: ref,
})
) : (
<div {...props} ref={ref} />
);
}
}

0 comments on commit 8eab40c

Please sign in to comment.