Skip to content
This repository has been archived by the owner on Oct 26, 2021. It is now read-only.

Commit

Permalink
Bug: slowly dragging should change marble time
Browse files Browse the repository at this point in the history
  • Loading branch information
Andre Medeiros committed Oct 19, 2014
1 parent 1c179ed commit 1e9a1fb
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 23 deletions.
16 changes: 9 additions & 7 deletions TODO
Expand Up @@ -54,17 +54,19 @@ DONE New MVI architecture for Sandbox
DONE Rename interpreters to intents
DONE Style and logic for tall/short completion element
DONE Delete old sandbox models, views and sub views
TODO Bug: slowly dragging should change marble time
DONE Bug: slowly dragging should change marble time
>>> v1.1.0

TODO Bug: some marbles can't be dragged, error 'invalid parent' is shown
TODO Build scripts to replace gulp (?)
## v1.1.0
>>> v1.1.1

TODO Build scripts to replace gulp (?)
TODO Fix referential transparency inconsistency
Replace models/sandbox-ouput combineLatest with combinePrevious
TODO Disambiguate simultaneous marbles
Vertically spread them
Change example takeLast(1) to takeLast(2)
>>> v1.1.1
>>>

TODO Embeddable rxmarbles
app.js 'exports' a function which can be called in <script> in index.html
Expand Down Expand Up @@ -96,12 +98,12 @@ TODO Allows customizing the expression in some operators
TODO Render lists of marbles for the buffer example
>>>

TODO Save a png snapshot of the sandbox
>>>

TODO Interactively add errors to an InputStream
>>>

TODO Hovering over a diagram shows mapping arrows
>>>

TODO Save a png snapshot of the sandbox
>>>

31 changes: 25 additions & 6 deletions dist/js/app.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/js/binder.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/js/renderer.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/js/utils.js

Large diffs are not rendered by default.

27 changes: 23 additions & 4 deletions src/models/sandbox-input.js
Expand Up @@ -27,6 +27,22 @@ function getNotifications(diagram) {
}
}

function cloneMarble(marble) {
return {
id: marble.id,
time: marble.time,
content: marble.content,
diagramId: marble.diagramId
}
}

function cloneDiagram(diagram) {
var newDiagram = diagram.map(cloneMarble); // copy all marble data
newDiagram.id = diagram.id;
newDiagram.end = diagram.end;
return newDiagram;
}

function prepareInputDiagram(diagram, indexInDiagramArray) {
if (indexInDiagramArray == null) {
indexInDiagramArray = 0;
Expand All @@ -51,10 +67,11 @@ function updateEachDiagram(delta) {
// Make new diagram
var newDiagram;
if (delta.type === 'marble') {
newDiagram = diagram.map(updateEachMarble(delta));
newDiagram = cloneDiagram(diagram).map(updateEachMarble(delta));
newDiagram.end = diagram.end;
newDiagram.id = diagram.id;
} else if (delta.type === 'completion') {
newDiagram = diagram.map(Rx.helpers.identity); // just copy the old diagram
newDiagram = cloneDiagram(diagram)
var newTime = diagram.end + delta.deltaTime;
if (newTime < 0) { newTime = 0; }
if (newTime > 100) { newTime = 100; }
Expand All @@ -71,8 +88,6 @@ function updateEachDiagram(delta) {
if (newDiagram.end < maxMarbleTime) {
newDiagram.end = maxMarbleTime;
}
// Set diagram id, and return
newDiagram.id = diagram.id;
return newDiagram;
};
}
Expand Down Expand Up @@ -115,6 +130,10 @@ function getInputDiagrams$(example$, inputMarbleDelta$, inputCompletionDelta$) {
.scan(initialDiagrams, function(acc, delta) {
return acc.map(updateEachDiagram(delta))
})
// Guarantee immutability
.map(function (diagrams) {
return diagrams.map(cloneDiagram);
})
// Round up all marble times and completion time
.map(function(diagrams) {
diagrams.forEach(function(diagram) {
Expand Down

0 comments on commit 1e9a1fb

Please sign in to comment.