Skip to content

Commit 64c20d6

Browse files
author
Marek Rozmus
authored
Merge pull request #74 from sandstreamdev/fix_for_issue_72
Fix for issue 72
2 parents 5a637bc + 926c275 commit 64c20d6

6 files changed

+145
-45
lines changed

examples/package-lock.json

+109-41
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/package.json

+2
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
"@babel/plugin-proposal-class-properties": "7.7.4",
3333
"@babel/preset-env": "7.7.6",
3434
"@babel/preset-react": "7.7.4",
35+
"autoprefixer": "^9.7.3",
3536
"babel-eslint": "10.0.3",
3637
"babel-loader": "8.0.6",
3738
"css-loader": "3.3.0",
@@ -42,6 +43,7 @@
4243
"eslint-plugin-react-hooks": "2.3.0",
4344
"gh-pages": "2.1.1",
4445
"html-webpack-plugin": "3.2.0",
46+
"postcss-loader": "^3.0.0",
4547
"prettier": "1.19.1",
4648
"style-loader": "1.0.1",
4749
"stylelint": "12.0.0",

examples/postcss.config.js

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
plugins: [require('autoprefixer')]
3+
};

examples/webpack.config.dev.js

+8
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,14 @@ module.exports = {
3636
options: {
3737
modules: true
3838
}
39+
},
40+
{
41+
loader: 'postcss-loader',
42+
options: {
43+
config: {
44+
path: path.join(__dirname, 'src', 'examples')
45+
}
46+
}
3947
}
4048
]
4149
}

examples/webpack.config.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ module.exports = {
3636
options: {
3737
modules: true
3838
}
39-
}
39+
},
40+
{ loader: 'postcss-loader' }
4041
]
4142
},
4243
{

src/SwipeableListItem.js

+21-3
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,29 @@ class SwipeableListItem extends PureComponent {
102102
requestAnimationFrame(this.updatePosition);
103103
};
104104

105-
handleTouchMove = event => this.handleMove(event, event.targetTouches[0]);
105+
handleMouseMove = event => {
106+
if (this.dragStartedWithinItem()) {
107+
const { clientX, clientY } = event;
106108

107-
handleMouseMove = event => this.handleMove(event, event);
109+
this.setDragDirection(clientX, clientY);
108110

109-
handleMove = (event, { clientX, clientY }) => {
111+
if (this.isSwiping()) {
112+
event.stopPropagation();
113+
event.preventDefault();
114+
115+
const delta = clientX - this.dragStartPoint.x;
116+
117+
if (this.shouldMoveItem(delta)) {
118+
this.left = delta;
119+
}
120+
}
121+
}
122+
};
123+
124+
handleTouchMove = event => {
110125
if (this.dragStartedWithinItem()) {
126+
const { clientX, clientY } = event.targetTouches[0];
127+
111128
this.setDragDirection(clientX, clientY);
112129

113130
if (!event.cancelable) {
@@ -119,6 +136,7 @@ class SwipeableListItem extends PureComponent {
119136
event.preventDefault();
120137

121138
const delta = clientX - this.dragStartPoint.x;
139+
122140
if (this.shouldMoveItem(delta)) {
123141
this.left = delta;
124142
}

0 commit comments

Comments
 (0)