Skip to content

Commit

Permalink
Hide mouse layer in mobile and remove hack for file save in iOS
Browse files Browse the repository at this point in the history
  • Loading branch information
shannonlui committed May 29, 2022
1 parent 66f9d20 commit e84d0c0
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 12 deletions.
2 changes: 1 addition & 1 deletion client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"file-saver": "^2.0.2",
"file-saver": "^2.0.5",
"pica": "^9.0.1",
"react": "^16.8.6",
"react-color": "^2.19.3",
Expand Down
12 changes: 2 additions & 10 deletions client/src/pages/ImageEditor/Canvas/Canvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,16 +222,8 @@ class Canvas extends Component {
}

saveCanvas = () => {
var ua = window.navigator.userAgent;
var iOS = !!ua.match(/iPad/i) || !!ua.match(/iPhone/i);
var webkit = !!ua.match(/WebKit/i);
var iOSSafari = iOS && webkit && !ua.match(/CriOS/i);
const canvasURL = this.canvas.current.toDataURL('image/png');
if (iOSSafari) {
window.open(canvasURL, '_blank');
} else {
saveAs(canvasURL, 'pixelartify.png');
}
saveAs(canvasURL, 'pixelartify.png');
}

applyColorAdjustments = () => {
Expand All @@ -247,7 +239,7 @@ class Canvas extends Component {
<React.Fragment>
<canvas ref={this.grid} className={styles.canvas} />
<canvas ref={this.canvas} className={styles.canvas} />
<canvas ref={this.mouseLayer} className={styles.canvas} />
<canvas ref={this.mouseLayer} className={`${styles.canvas} ${styles.hideOnSmallScreen}`} />
</React.Fragment>
);
}
Expand Down
6 changes: 6 additions & 0 deletions client/src/pages/ImageEditor/Canvas/Canvas.module.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
.canvas {
position: absolute;
}

@media only screen and (max-width: 700px) {
.hideOnSmallScreen {
opacity: 0;
}
}
2 changes: 1 addition & 1 deletion client/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4312,7 +4312,7 @@ [email protected]:
loader-utils "^1.0.2"
schema-utils "^1.0.0"

file-saver@^2.0.2:
file-saver@^2.0.5:
version "2.0.5"
resolved "https://registry.yarnpkg.com/file-saver/-/file-saver-2.0.5.tgz#d61cfe2ce059f414d899e9dd6d4107ee25670c38"
integrity sha512-P9bmyZ3h/PRG+Nzga+rbdI4OEpNDzAVyy74uVO9ATgzLK6VtAsYybF/+TOCvrc0MO793d6+42lLyZTw7/ArVzA==
Expand Down

0 comments on commit e84d0c0

Please sign in to comment.