Skip to content

Commit 57b08b4

Browse files
committed
implement tip
1 parent 00a3d18 commit 57b08b4

File tree

4 files changed

+40
-0
lines changed

4 files changed

+40
-0
lines changed

index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
<script src="./lib/drawingLine.js"></script>
3434
<script src="./lib/drawingPath.js"></script>
3535
<script src="./lib/drawingText.js"></script>
36+
<script src="./lib/tip.js"></script>
3637
<script src="./lib/upload.js"></script>
3738
<script src="./lib/copyPaste.js"></script>
3839

lib/core.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
o.selectable = false
5555
o.evented = false
5656
});
57+
this.updateTip('Tip: click to place points, press and pull for curves! Click outside or press Esc to cancel!');
5758
break;
5859
case 'textbox':
5960
this.canvas.isDrawingTextMode = true
@@ -68,6 +69,7 @@
6869
this.openDragDropPanel();
6970
break;
7071
default:
72+
this.updateTip('Tip: hold Shift when drawing a line for 15° angle jumps!');
7173
break;
7274
}
7375
}
@@ -155,6 +157,7 @@
155157
this.initializeTextBoxDrawing(this.canvas);
156158
this.initializeUpload(this.canvas);
157159
this.initializeCopyPaste(this.canvas);
160+
this.initializeTipSection();
158161

159162
this.initializeZoomEvents();
160163

lib/style.css

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,4 +354,12 @@ body {
354354

355355
.drag-drop-input.dragging {
356356
border-color: #4368a9;
357+
}
358+
359+
#tip-container {
360+
padding: 10px;
361+
text-align: center;
362+
touch-action: none;
363+
cursor: default;
364+
color: #888;
357365
}

lib/tip.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
(function () {
2+
'use strict';
3+
4+
function tipPanel() {
5+
const defaultTips = [
6+
'Tip: use arrows to move a selected object by 1 pixel!',
7+
'Tip: Shift + Click to select and modify multiple objects!',
8+
'Tip: hold Shift when rotating an object for 15° angle jumps!',
9+
'Tip: hold Shift when drawing a line for 15° angle jumps!',
10+
]
11+
const _self = this;
12+
$(`${this.containerSelector} .canvas-holder .content`).append(`
13+
<div id="tip-container">${defaultTips[parseInt(Math.random() * defaultTips.length)]}</div>`)
14+
this.hideTip = function () {
15+
$(`${_self.containerSelector} .canvas-holder .content #tip-container`).hide();
16+
}
17+
18+
this.showTip = function () {
19+
$(`${_self.containerSelector} .canvas-holder .content #tip-container`).show();
20+
}
21+
22+
this.updateTip = function (str) {
23+
typeof str === 'string' && $(`${_self.containerSelector} .canvas-holder .content #tip-container`).html(str);
24+
}
25+
}
26+
27+
window.ImageEditor.prototype.initializeTipSection = tipPanel;
28+
})();

0 commit comments

Comments
 (0)