From 6ea647dc914b2059c7873368eb66211e95a8fe9c Mon Sep 17 00:00:00 2001 From: ianwith Date: Mon, 23 Apr 2018 19:01:58 +0800 Subject: [PATCH] add Object.assign transform --- lib/PinchableMixin.js | 6 ++++-- lib/TapAndPinchable.js | 4 +++- lib/getComponent.js | 6 ++++-- package.json | 4 ++++ 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/lib/PinchableMixin.js b/lib/PinchableMixin.js index a837352..668273a 100644 --- a/lib/PinchableMixin.js +++ b/lib/PinchableMixin.js @@ -1,5 +1,7 @@ 'use strict'; +var _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; }; + var PropTypes = require('prop-types'); var React = require('react'); @@ -28,7 +30,7 @@ var Mixin = { } var touches = event.touches; this._initialPinch = getPinchProps(touches); - this._initialPinch = Object.assign(this._initialPinch, { + this._initialPinch = _extends(this._initialPinch, { displacement: { x: 0, y: 0 }, displacementVelocity: { x: 0, y: 0 }, rotation: 0, @@ -80,7 +82,7 @@ var Mixin = { onPinchEnd: function onPinchEnd(event) { // TODO use helper to order touches by identifier and use actual values on touchEnd. - var currentPinch = Object.assign({}, this._lastPinch); + var currentPinch = _extends({}, this._lastPinch); currentPinch.time = Date.now(); if (currentPinch.time - this._lastPinch.time > 16) { diff --git a/lib/TapAndPinchable.js b/lib/TapAndPinchable.js index cb3271b..7fff1ce 100644 --- a/lib/TapAndPinchable.js +++ b/lib/TapAndPinchable.js @@ -1,5 +1,7 @@ 'use strict'; +var _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; }; + var TappableMixin = require('./TappableMixin'); var PinchableMixin = require('./PinchableMixin'); var getComponent = require('./getComponent'); @@ -9,7 +11,7 @@ var Component = getComponent([TappableMixin, PinchableMixin]); module.exports = Component; module.exports.touchStyles = touchStyles; -module.exports.Mixin = Object.assign({}, TappableMixin, { +module.exports.Mixin = _extends({}, TappableMixin, { onPinchStart: PinchableMixin.onPinchStart, onPinchMove: PinchableMixin.onPinchMove, onPinchEnd: PinchableMixin.onPinchEnd diff --git a/lib/getComponent.js b/lib/getComponent.js index b2e0384..6fe9796 100644 --- a/lib/getComponent.js +++ b/lib/getComponent.js @@ -1,5 +1,7 @@ 'use strict'; +var _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; }; + var createReactClass = require('create-react-class'); var PropTypes = require('prop-types'); var React = require('react'); @@ -44,9 +46,9 @@ module.exports = function (mixins) { } var style = {}; - Object.assign(style, touchStyles, props.style); + _extends(style, touchStyles, props.style); - var newComponentProps = Object.assign({}, props, { + var newComponentProps = _extends({}, props, { style: style, className: className, disabled: props.disabled, diff --git a/package.json b/package.json index 27a57ed..80b5ec4 100644 --- a/package.json +++ b/package.json @@ -19,6 +19,7 @@ "babel-cli": "^6.26.0", "babel-core": "^6.26.0", "babel-eslint": "^4.1.3", + "babel-plugin-transform-object-assign": "^6.22.0", "babel-preset-es2015": "^6.24.1", "babel-preset-react": "^6.24.1", "babelify": "^8.0.0", @@ -35,6 +36,9 @@ "presets": [ "es2015", "react" + ], + "plugins": [ + "transform-object-assign" ] }, "browserify-shim": {