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
hlgr
drawing-app
Commits
47324068
Commit
47324068
authored
5 years ago
by
Yuriy Maksymets
Browse files
Options
Downloads
Patches
Plain Diff
Merging intervals locally
parent
91c1a8c8
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/app.js
+13
-25
13 additions, 25 deletions
src/app.js
src/room.js
+2
-8
2 additions, 8 deletions
src/room.js
with
15 additions
and
33 deletions
src/app.js
+
13
−
25
View file @
47324068
...
...
@@ -36,17 +36,11 @@ function eraseAt(x, y, room) {
ERASERRADIUS
,
)
console
.
log
(
prevPathIntervals
,
newPathIntervals
)
const
erasureIntervalsForPath
=
combineErasureIntervals
(
prevPathIntervals
,
newPathIntervals
,
)
// if (!TEST_ERASE_INTERVAL[pathID]) TEST_ERASE_INTERVAL[pathID] = {}
// TEST_ERASE_INTERVAL[pathID] = erasureIntervalsForPath
console
.
log
(
"
erasureIntervalsForPath
"
)
console
.
log
(
erasureIntervalsForPath
)
Object
.
keys
(
erasureIntervalsForPath
).
forEach
((
pointID
)
=>
room
.
extendErasureIntervals
(
pathID
,
...
...
@@ -55,11 +49,6 @@ function eraseAt(x, y, room) {
),
)
// room.dispatchEvent(
// new CustomEvent("removedIntervalsChange", {
// detail: { id: pathID, points },
// }),
// )
points
.
forEach
((
point
)
=>
{
const
distanceToPoint
=
getDistance
(
mousePos
,
point
)
if
(
distanceToPoint
<=
ERASERRADIUS
)
{
...
...
@@ -184,9 +173,9 @@ function needToDrawLastPoint(points, pathID) {
function
generatePointsForPathElem
(
pathElem
,
pathID
,
dataPoints
)
{
const
points
=
dataPoints
document
.
getElementById
(
"
console
"
).
innerText
=
JSON
.
stringify
(
TEST_ERASE_INTERVAL
,
)
//
document.getElementById("console").innerText = JSON.stringify(
//
TEST_ERASE_INTERVAL,
//
)
const
appendToWholePath
=
(
subPath
)
=>
{
if
(
!
(
subPath
&&
subPath
.
length
))
return
const
subpathElem
=
generateSvgForSubpath
(
subPath
)
...
...
@@ -322,11 +311,10 @@ function handleRoomConnectionEstablished(room) {
room
.
addEventListener
(
"
removedIntervalsChange
"
,
({
detail
:
{
id
,
intervals
,
points
}
})
=>
{
console
.
log
(
"
got the event for id
"
,
id
)
console
.
log
(
intervals
)
TEST_ERASE_INTERVAL
[
id
]
=
intervals
console
.
log
(
pathElems
,
id
,
points
)
TEST_ERASE_INTERVAL
[
id
]
=
combineErasureIntervals
(
TEST_ERASE_INTERVAL
[
id
]
||
{},
intervals
,
)
addOrUpdatePathElem
(
pathElems
,
id
,
points
)
},
)
...
...
@@ -425,12 +413,12 @@ function handleRoomConnectionEstablished(room) {
}
HTML
.
roomConnectButton
.
addEventListener
(
"
click
"
,
roomConnectButtonOnClick
)
let
pid
=
room
.
addPath
([
100
,
100
])
room
.
extendPath
(
pid
,
[
800
,
200
])
room
.
extendPath
(
pid
,
[
100
,
300
])
room
.
extendPath
(
pid
,
[
800
,
400
])
room
.
extendPath
(
pid
,
[
800
,
450
])
room
.
extendPath
(
pid
,
[
800
,
500
])
//
let pid = room.addPath([100, 100])
//
room.extendPath(pid, [800, 200])
//
room.extendPath(pid, [100, 300])
//
room.extendPath(pid, [800, 400])
//
room.extendPath(pid, [800, 450])
//
room.extendPath(pid, [800, 500])
}
function
handleRoomConnectionError
(
err
)
{
...
...
This diff is collapsed.
Click to expand it.
src/room.js
+
2
−
8
View file @
47324068
...
...
@@ -49,11 +49,8 @@ class Room extends EventTarget {
const
pathIntervals
=
yGetOrSet
(
this
.
sharedMergeIntervals
,
pathID
,
Y
.
Map
)
const
pointIntervals
=
yGetOrSet
(
pathIntervals
,
pointID
,
Y
.
Array
)
// pointIntervals.delete(0, pointIntervals.length)
newIntervals
.
forEach
((
newInterval
)
=>
pointIntervals
.
push
([
newInterval
]))
console
.
log
(
"
pointIntervals
"
)
console
.
log
(
pointIntervals
.
toArray
())
pointIntervals
.
delete
(
0
,
pointIntervals
.
length
)
pointIntervals
.
push
(
newIntervals
)
}
getPaths
()
{
...
...
@@ -106,11 +103,8 @@ class Room extends EventTarget {
_generateRemovedIntervals
(
id
)
{
const
intervals
=
this
.
sharedMergeIntervals
.
get
(
id
)
if
(
!
intervals
)
return
[]
console
.
log
(
intervals
)
const
json
=
intervals
.
toJSON
()
console
.
log
(
"
json
"
)
console
.
log
(
json
)
return
typeof
json
===
"
string
"
?
JSON
.
parse
(
json
)
:
json
}
...
...
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