Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into production
Browse files Browse the repository at this point in the history
  • Loading branch information
kswenson committed Jan 8, 2019
2 parents 38ae6c2 + 3a72b22 commit 9514630
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 12 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# Changelog

## Version 0.2.2 - released January 7, 2018

- Geometry: Improve initialization performance

### Asset Sizes

| File | Size | % Change from Previous Release |
|---|---|---|
| index.css | 318,477 bytes | 0.0% |
| index.js | 2,938,753 bytes | 0.0% |

## Version 0.2.1 - released January 6, 2018

- Geometry: Fix polygon edge drag bug
Expand Down
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "collaborative-learning",
"version": "0.2.1",
"version": "0.2.2",
"description": "Collaborative Learning environment",
"main": "index.js",
"jest": {
Expand Down
6 changes: 5 additions & 1 deletion src/models/tools/geometry/geometry-content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,17 +137,21 @@ export const GeometryContentModel = types
// actions
function initializeBoard(domElementID: string, onCreate?: onCreateCallback): JXG.Board | undefined {
const changes = self.changes.map(change => JSON.parse(change));
let board;
let board: JXG.Board | undefined;
applyChanges(domElementID, changes)
.filter(result => result != null)
.forEach(elt => {
if (isBoard(elt)) {
board = elt as JXG.Board;
board.suspendUpdate();
}
else if (elt && onCreate) {
onCreate(elt as JXG.GeometryElement);
}
});
if (board) {
board.unsuspendUpdate();
}
return board;
}

Expand Down
3 changes: 3 additions & 0 deletions src/models/tools/geometry/jsxgraph.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ declare namespace JXG {
container: string;
containerObj: HTMLElement;
cssTransMat: number[][];
isSuspendedUpdate: boolean;
keepaspectratio: boolean;
origin: {
usrCoords: [number, number, number],
Expand Down Expand Up @@ -64,6 +65,8 @@ declare namespace JXG {
setBoundingBox: (boundingBox: [number, number, number, number], keepaspectratio?: boolean) => JXG.Board;
showInfobox: (value: boolean) => JXG.Board;
update: (drag?: JXG.GeometryElement) => JXG.Board;
suspendUpdate: () => JXG.Board;
unsuspendUpdate: () => JXG.Board;
}

class Coords {
Expand Down
19 changes: 12 additions & 7 deletions src/models/tools/geometry/jxg-dispatcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,18 @@ const agents: JXGChangeAgents = {

export function applyChanges(board: JXG.Board|string, changes: JXGChange[]): JXGChangeResult[] {
let _board: JXG.Board | undefined;
return changes.map(change => {
const result = applyChange(_board || board, change);
if ((typeof board === "string") && isBoard(result)) {
_board = result as JXG.Board;
}
return result;
});
const results = changes.map(change => {
const result = applyChange(_board || board, change);
if ((typeof board === "string") && isBoard(result)) {
_board = result as JXG.Board;
_board.suspendUpdate();
}
return result;
});
if (_board) {
_board.unsuspendUpdate();
}
return results;
}

export function applyChange(board: JXG.Board|string, change: JXGChange): JXGChangeResult {
Expand Down

0 comments on commit 9514630

Please sign in to comment.