mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-06-29 17:27:22 +02:00
better flip logic fixes Issue #73
This commit is contained in:
parent
0332d92513
commit
44db45ce0d
7 changed files with 37 additions and 16 deletions
|
@ -15671,6 +15671,7 @@ function GitVisuals(options) {
|
||||||
min: 0,
|
min: 0,
|
||||||
max: 1
|
max: 1
|
||||||
};
|
};
|
||||||
|
this.flipFraction = 0.51;
|
||||||
|
|
||||||
var Main = require('../app');
|
var Main = require('../app');
|
||||||
Main.getEvents().on('refreshTree', this.refreshTree, this);
|
Main.getEvents().on('refreshTree', this.refreshTree, this);
|
||||||
|
@ -15743,6 +15744,12 @@ GitVisuals.prototype.getScreenPadding = function() {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
GitVisuals.prototype.getFlipPos = function() {
|
||||||
|
var min = this.posBoundaries.min;
|
||||||
|
var max = this.posBoundaries.max;
|
||||||
|
return this.flipFraction * (max - min) + min;
|
||||||
|
};
|
||||||
|
|
||||||
GitVisuals.prototype.toScreenCoords = function(pos) {
|
GitVisuals.prototype.toScreenCoords = function(pos) {
|
||||||
if (!this.paper.width) {
|
if (!this.paper.width) {
|
||||||
throw new Error('being called too early for screen coords');
|
throw new Error('being called too early for screen coords');
|
||||||
|
@ -15752,7 +15759,7 @@ GitVisuals.prototype.toScreenCoords = function(pos) {
|
||||||
var shrink = function(frac, total, padding) {
|
var shrink = function(frac, total, padding) {
|
||||||
return padding + frac * (total - padding * 2);
|
return padding + frac * (total - padding * 2);
|
||||||
};
|
};
|
||||||
|
|
||||||
var asymShrink = function(frac, total, paddingTop, paddingBelow) {
|
var asymShrink = function(frac, total, paddingTop, paddingBelow) {
|
||||||
return paddingTop + frac * (total - paddingBelow - paddingTop);
|
return paddingTop + frac * (total - paddingBelow - paddingTop);
|
||||||
};
|
};
|
||||||
|
@ -16998,9 +17005,9 @@ var VisBranch = VisBase.extend({
|
||||||
var commit = this.gitEngine.getCommitFromRef(this.get('branch'));
|
var commit = this.gitEngine.getCommitFromRef(this.get('branch'));
|
||||||
var visNode = commit.get('visNode');
|
var visNode = commit.get('visNode');
|
||||||
|
|
||||||
var threshold = this.get('gitVisuals').posBoundaries.max;
|
var threshold = this.get('gitVisuals').getFlipPos();
|
||||||
// somewhat tricky flip management here
|
// somewhat tricky flip management here
|
||||||
if (visNode.get('pos').x > threshold) {
|
if (visNode.get('pos').x > threshold || this.get('isHead')) {
|
||||||
this.set('flip', -1);
|
this.set('flip', -1);
|
||||||
} else {
|
} else {
|
||||||
this.set('flip', 1);
|
this.set('flip', 1);
|
||||||
|
@ -23740,8 +23747,8 @@ var genBadKeyCommand = function(key) {
|
||||||
return 'grep -r "' + key + '" ../../';
|
return 'grep -r "' + key + '" ../../';
|
||||||
};
|
};
|
||||||
|
|
||||||
var easyRegex = /intl.str\('([a-zA-Z-]+)'/g;
|
var easyRegex = /intl.str\('([a-zA-Z\-]+)'/g;
|
||||||
var hardRegex = /\s+'([a-z-]+)',/g;
|
var hardRegex = /\s+'([a-z\-]+)',/g;
|
||||||
|
|
||||||
var findKey = function(badKey) {
|
var findKey = function(badKey) {
|
||||||
child_process.exec(genBadKeyCommand(badKey), function(err, output) {
|
child_process.exec(genBadKeyCommand(badKey), function(err, output) {
|
||||||
|
@ -29845,6 +29852,7 @@ function GitVisuals(options) {
|
||||||
min: 0,
|
min: 0,
|
||||||
max: 1
|
max: 1
|
||||||
};
|
};
|
||||||
|
this.flipFraction = 0.51;
|
||||||
|
|
||||||
var Main = require('../app');
|
var Main = require('../app');
|
||||||
Main.getEvents().on('refreshTree', this.refreshTree, this);
|
Main.getEvents().on('refreshTree', this.refreshTree, this);
|
||||||
|
@ -29917,6 +29925,12 @@ GitVisuals.prototype.getScreenPadding = function() {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
GitVisuals.prototype.getFlipPos = function() {
|
||||||
|
var min = this.posBoundaries.min;
|
||||||
|
var max = this.posBoundaries.max;
|
||||||
|
return this.flipFraction * (max - min) + min;
|
||||||
|
};
|
||||||
|
|
||||||
GitVisuals.prototype.toScreenCoords = function(pos) {
|
GitVisuals.prototype.toScreenCoords = function(pos) {
|
||||||
if (!this.paper.width) {
|
if (!this.paper.width) {
|
||||||
throw new Error('being called too early for screen coords');
|
throw new Error('being called too early for screen coords');
|
||||||
|
@ -29926,7 +29940,7 @@ GitVisuals.prototype.toScreenCoords = function(pos) {
|
||||||
var shrink = function(frac, total, padding) {
|
var shrink = function(frac, total, padding) {
|
||||||
return padding + frac * (total - padding * 2);
|
return padding + frac * (total - padding * 2);
|
||||||
};
|
};
|
||||||
|
|
||||||
var asymShrink = function(frac, total, paddingTop, paddingBelow) {
|
var asymShrink = function(frac, total, paddingTop, paddingBelow) {
|
||||||
return paddingTop + frac * (total - paddingBelow - paddingTop);
|
return paddingTop + frac * (total - paddingBelow - paddingTop);
|
||||||
};
|
};
|
||||||
|
@ -30782,9 +30796,9 @@ var VisBranch = VisBase.extend({
|
||||||
var commit = this.gitEngine.getCommitFromRef(this.get('branch'));
|
var commit = this.gitEngine.getCommitFromRef(this.get('branch'));
|
||||||
var visNode = commit.get('visNode');
|
var visNode = commit.get('visNode');
|
||||||
|
|
||||||
var threshold = this.get('gitVisuals').posBoundaries.max;
|
var threshold = this.get('gitVisuals').getFlipPos();
|
||||||
// somewhat tricky flip management here
|
// somewhat tricky flip management here
|
||||||
if (visNode.get('pos').x > threshold) {
|
if (visNode.get('pos').x > threshold || this.get('isHead')) {
|
||||||
this.set('flip', -1);
|
this.set('flip', -1);
|
||||||
} else {
|
} else {
|
||||||
this.set('flip', 1);
|
this.set('flip', 1);
|
||||||
|
|
File diff suppressed because one or more lines are too long
2
build/bundle.min.js
vendored
2
build/bundle.min.js
vendored
File diff suppressed because one or more lines are too long
|
@ -412,7 +412,7 @@
|
||||||
For a much easier time perusing the source, see the individual files at:
|
For a much easier time perusing the source, see the individual files at:
|
||||||
https://github.com/pcottle/learnGitBranching
|
https://github.com/pcottle/learnGitBranching
|
||||||
-->
|
-->
|
||||||
<script src="build/bundle.min.91593e93.js"></script>
|
<script src="build/bundle.min.af985bd7.js"></script>
|
||||||
|
|
||||||
<!-- The advantage of github pages: super-easy, simple, slick static hostic.
|
<!-- The advantage of github pages: super-easy, simple, slick static hostic.
|
||||||
The downside? No raw logs to parse for analytics, so I have to include
|
The downside? No raw logs to parse for analytics, so I have to include
|
||||||
|
|
|
@ -8,8 +8,8 @@ var genBadKeyCommand = function(key) {
|
||||||
return 'grep -r "' + key + '" ../../';
|
return 'grep -r "' + key + '" ../../';
|
||||||
};
|
};
|
||||||
|
|
||||||
var easyRegex = /intl.str\('([a-zA-Z-]+)'/g;
|
var easyRegex = /intl.str\('([a-zA-Z\-]+)'/g;
|
||||||
var hardRegex = /\s+'([a-z-]+)',/g;
|
var hardRegex = /\s+'([a-z\-]+)',/g;
|
||||||
|
|
||||||
var findKey = function(badKey) {
|
var findKey = function(badKey) {
|
||||||
child_process.exec(genBadKeyCommand(badKey), function(err, output) {
|
child_process.exec(genBadKeyCommand(badKey), function(err, output) {
|
||||||
|
|
|
@ -43,6 +43,7 @@ function GitVisuals(options) {
|
||||||
min: 0,
|
min: 0,
|
||||||
max: 1
|
max: 1
|
||||||
};
|
};
|
||||||
|
this.flipFraction = 0.51;
|
||||||
|
|
||||||
var Main = require('../app');
|
var Main = require('../app');
|
||||||
Main.getEvents().on('refreshTree', this.refreshTree, this);
|
Main.getEvents().on('refreshTree', this.refreshTree, this);
|
||||||
|
@ -115,6 +116,12 @@ GitVisuals.prototype.getScreenPadding = function() {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
GitVisuals.prototype.getFlipPos = function() {
|
||||||
|
var min = this.posBoundaries.min;
|
||||||
|
var max = this.posBoundaries.max;
|
||||||
|
return this.flipFraction * (max - min) + min;
|
||||||
|
};
|
||||||
|
|
||||||
GitVisuals.prototype.toScreenCoords = function(pos) {
|
GitVisuals.prototype.toScreenCoords = function(pos) {
|
||||||
if (!this.paper.width) {
|
if (!this.paper.width) {
|
||||||
throw new Error('being called too early for screen coords');
|
throw new Error('being called too early for screen coords');
|
||||||
|
@ -124,7 +131,7 @@ GitVisuals.prototype.toScreenCoords = function(pos) {
|
||||||
var shrink = function(frac, total, padding) {
|
var shrink = function(frac, total, padding) {
|
||||||
return padding + frac * (total - padding * 2);
|
return padding + frac * (total - padding * 2);
|
||||||
};
|
};
|
||||||
|
|
||||||
var asymShrink = function(frac, total, paddingTop, paddingBelow) {
|
var asymShrink = function(frac, total, paddingTop, paddingBelow) {
|
||||||
return paddingTop + frac * (total - paddingBelow - paddingTop);
|
return paddingTop + frac * (total - paddingBelow - paddingTop);
|
||||||
};
|
};
|
||||||
|
|
|
@ -77,9 +77,9 @@ var VisBranch = VisBase.extend({
|
||||||
var commit = this.gitEngine.getCommitFromRef(this.get('branch'));
|
var commit = this.gitEngine.getCommitFromRef(this.get('branch'));
|
||||||
var visNode = commit.get('visNode');
|
var visNode = commit.get('visNode');
|
||||||
|
|
||||||
var threshold = this.get('gitVisuals').posBoundaries.max;
|
var threshold = this.get('gitVisuals').getFlipPos();
|
||||||
// somewhat tricky flip management here
|
// somewhat tricky flip management here
|
||||||
if (visNode.get('pos').x > threshold) {
|
if (visNode.get('pos').x > threshold || this.get('isHead')) {
|
||||||
this.set('flip', -1);
|
this.set('flip', -1);
|
||||||
} else {
|
} else {
|
||||||
this.set('flip', 1);
|
this.set('flip', 1);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue