Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
drawing-app
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
sweng-group-15
drawing-app
Commits
6177613a
Commit
6177613a
authored
5 years ago
by
Yuriy Maksymets
Browse files
Options
Downloads
Patches
Plain Diff
Added dragging fronted elements
parent
749a5e62
No related branches found
Branches containing commit
No related tags found
1 merge request
!74
Canvas dragging
Pipeline
#109249
passed
5 years ago
Stage: fetch
Stage: deps
Stage: check
Stage: build
Stage: test
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
public/index.html
+6
-0
6 additions, 0 deletions
public/index.html
public/styles.css
+1
-1
1 addition, 1 deletion
public/styles.css
src/elements.js
+2
-0
2 additions, 0 deletions
src/elements.js
src/tool-selection.js
+33
-6
33 additions, 6 deletions
src/tool-selection.js
with
42 additions
and
7 deletions
public/index.html
+
6
−
0
View file @
6177613a
...
...
@@ -199,6 +199,12 @@
<button
id=
"eraser-tool"
class=
"selectable-tool"
>
<i
class=
"fa fa-eraser"
></i>
</button>
<button
id=
"dragging-tool"
class=
"selectable-tool"
>
<i
class=
"fa fa-hand-paper-o"
></i>
</button>
<button
id=
"canvas-center"
class=
"selectable-tool"
>
<i
class=
"fa fa-crosshairs"
></i>
</button>
<button
id=
"recognition-mode"
class=
"selectable-tool"
>
<i
class=
"fa fa-square"
></i>
</button>
...
...
This diff is collapsed.
Click to expand it.
public/styles.css
+
1
−
1
View file @
6177613a
...
...
@@ -287,7 +287,7 @@ button.selected {
}
#eraser-tool
{
margin-right
:
8px
;
/*
margin-right: 8px;
*/
}
#eraser-tool
>
i
{
...
...
This diff is collapsed.
Click to expand it.
src/elements.js
+
2
−
0
View file @
6177613a
...
...
@@ -13,6 +13,8 @@ export const canvas = document.getElementById("canvas")
export
const
penButton
=
document
.
getElementById
(
"
pen-tool
"
)
export
const
eraserButton
=
document
.
getElementById
(
"
eraser-tool
"
)
export
const
recognitionModeButton
=
document
.
getElementById
(
"
recognition-mode
"
)
export
const
draggingToolButton
=
document
.
getElementById
(
"
dragging-tool
"
)
export
const
canvasCenterToolButton
=
document
.
getElementById
(
"
canvas-center
"
)
export
const
fastUndoButton
=
document
.
getElementById
(
"
fast-undo-tool
"
)
export
const
undoButton
=
document
.
getElementById
(
"
undo-tool
"
)
...
...
This diff is collapsed.
Click to expand it.
src/tool-selection.js
+
33
−
6
View file @
6177613a
...
...
@@ -3,8 +3,10 @@ import * as HTML from "./elements.js"
export
const
Tools
=
Object
.
freeze
({
PEN
:
Symbol
(
"
pen
"
),
ERASER
:
Symbol
(
"
eraser
"
),
DRAGGER
:
Symbol
(
"
dragger
"
),
})
let
canvasOffset
=
[
0
,
0
]
let
selectedTool
=
Tools
.
PEN
let
strokeColour
=
"
#000000
"
let
strokeRadius
=
2
...
...
@@ -15,6 +17,7 @@ const ERASE_RADIUS = 20
export
const
getTool
=
()
=>
selectedTool
export
const
getStrokeColour
=
()
=>
strokeColour
export
const
getStrokeRadius
=
()
=>
strokeRadius
export
const
getCanvasOffset
=
()
=>
canvasOffset
export
const
getEraseRadius
=
()
=>
ERASE_RADIUS
export
const
isRecognitionModeSet
=
()
=>
recognitionEnabled
...
...
@@ -51,20 +54,44 @@ HTML.recognitionModeButton.addEventListener("click", () => {
}
})
const
toolElements
=
{
[
Tools
.
PEN
]:
HTML
.
penButton
,
[
Tools
.
ERASER
]:
HTML
.
eraserButton
,
[
Tools
.
DRAGGER
]:
HTML
.
draggingToolButton
,
}
function
setSelectedTool
(
newSelectedTool
)
{
selectedTool
=
newSelectedTool
Object
.
getOwnPropertySymbols
(
toolElements
).
forEach
((
e
)
=>
toolElements
[
e
].
classList
.
remove
(
"
selected
"
),
)
toolElements
[
newSelectedTool
].
classList
.
add
(
"
selected
"
)
}
function
centerCanvas
()
{
canvasOffset
=
[
0
,
0
]
}
HTML
.
penButton
.
addEventListener
(
"
click
"
,
()
=>
{
if
(
selectedTool
==
Tools
.
PEN
)
{
showElement
(
HTML
.
penProperties
)
}
else
{
selectedTool
=
Tools
.
PEN
HTML
.
penButton
.
classList
.
add
(
"
selected
"
)
HTML
.
eraserButton
.
classList
.
remove
(
"
selected
"
)
setSelectedTool
(
Tools
.
PEN
)
}
})
HTML
.
eraserButton
.
addEventListener
(
"
click
"
,
()
=>
{
selectedTool
=
Tools
.
ERASER
HTML
.
penButton
.
classList
.
remove
(
"
selected
"
)
HTML
.
eraserButton
.
classList
.
add
(
"
selected
"
)
setSelectedTool
(
Tools
.
ERASER
)
})
HTML
.
draggingToolButton
.
addEventListener
(
"
click
"
,
()
=>
{
setSelectedTool
(
Tools
.
DRAGGER
)
})
HTML
.
canvasCenterToolButton
.
addEventListener
(
"
click
"
,
()
=>
{
centerCanvas
()
})
HTML
.
strokeColorPicker
.
addEventListener
(
"
change
"
,
()
=>
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment