-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Update project to react16, jest, enzyme3 (#103)
BREAKING CHANGE: This version is only compatible with React >= 16
- Loading branch information
Showing
14 changed files
with
461 additions
and
462 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,9 @@ | ||
{ | ||
"presets": [ | ||
"latest", | ||
"env", | ||
"react" | ||
], | ||
"plugins": [ | ||
"transform-object-rest-spread", | ||
], | ||
"env": { | ||
"test": { | ||
"plugins": ["istanbul"] | ||
} | ||
} | ||
"transform-object-rest-spread" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,9 @@ | ||
root = true | ||
|
||
[*] | ||
end_of_line = lf | ||
insert_final_newline = true | ||
charset = utf-8 | ||
indent_style = space | ||
indent_size = 4 | ||
|
||
[*.{json,yml}] | ||
indent_size = 2 | ||
|
||
[.*] | ||
indent_size = 2 | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
module.exports = { | ||
root: true, | ||
extends: ['eslint:recommended', 'plugin:react/recommended'], | ||
parserOptions: { | ||
ecmaVersion: 2018, | ||
sourceType: 'module', | ||
ecmaFeatures: { | ||
jsx: true, | ||
}, | ||
}, | ||
rules: { | ||
'react/no-find-dom-node': '0', | ||
}, | ||
globals: { | ||
document: true, | ||
MouseEvent: true, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,3 @@ npm-debug.log | |
|
||
/lib | ||
coverage/ | ||
.nyc_output |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
package-lock=false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
singleQuote: true | ||
printWidth: 100 | ||
trailingComma: es5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,44 @@ | ||
'use strict'; | ||
|
||
var React = require('react'); | ||
var clickDrag = require('../../lib/clickdrag'); | ||
|
||
var ExampleComponent = React.createClass({ | ||
|
||
getInitialState: function() { | ||
return { | ||
lastPositionX: 0, | ||
lastPositionY: 0, | ||
currentX: 0, | ||
currentY: 0 | ||
}; | ||
}, | ||
|
||
componentWillReceiveProps: function(nextProps) { | ||
if(nextProps.dataDrag.isMoving) { | ||
this.setState({ | ||
currentX: this.state.lastPositionX + nextProps.dataDrag.moveDeltaX, | ||
currentY: this.state.lastPositionY + nextProps.dataDrag.moveDeltaY | ||
}); | ||
} | ||
else { | ||
this.setState({ | ||
lastPositionX: this.state.currentX, | ||
lastPositionY: this.state.currentY | ||
}); | ||
} | ||
}, | ||
|
||
render: function () { | ||
var translation = 'translate('+this.state.currentX+'px, '+this.state.currentY+'px)'; | ||
|
||
return React.createElement('div', { | ||
style: {width: '200px', height: '200px', backgroundColor: 'red', transform: translation} | ||
}); | ||
var { render } = require('react-dom'); | ||
var clickDrag = require('../../lib/clickdrag').default; | ||
|
||
class ExampleComponent extends React.Component { | ||
constructor(props) { | ||
super(props); | ||
|
||
this.state = { | ||
lastPositionX: 0, | ||
lastPositionY: 0, | ||
currentX: 0, | ||
currentY: 0, | ||
}; | ||
} | ||
|
||
componentWillReceiveProps(nextProps) { | ||
if (nextProps.dataDrag.isMoving) { | ||
this.setState({ | ||
currentX: this.state.lastPositionX + nextProps.dataDrag.moveDeltaX, | ||
currentY: this.state.lastPositionY + nextProps.dataDrag.moveDeltaY, | ||
}); | ||
} else { | ||
this.setState({ | ||
lastPositionX: this.state.currentX, | ||
lastPositionY: this.state.currentY, | ||
}); | ||
} | ||
}); | ||
} | ||
|
||
var ClickDragExample = clickDrag(ExampleComponent, {touch: true}); | ||
render() { | ||
var translation = 'translate(' + this.state.currentX + 'px, ' + this.state.currentY + 'px)'; | ||
|
||
React.render(React.createElement(ClickDragExample), document.getElementById('App')); | ||
return React.createElement('div', { | ||
style: { width: '200px', height: '200px', backgroundColor: 'red', transform: translation }, | ||
}); | ||
} | ||
} | ||
|
||
var ClickDragExample = clickDrag(ExampleComponent, { touch: true }); | ||
|
||
render(React.createElement(ClickDragExample), document.getElementById('App')); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,11 @@ | ||
{ | ||
"scripts": { | ||
"build": "browserify app.js --debug -o app.min.js" | ||
"build": "npx browserify app.js --debug -o app.min.js" | ||
}, | ||
"devDependencies": { | ||
"babelify": "^5.0.4" | ||
}, | ||
"dependencies": { | ||
"browserify": "^16.2.2" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.