From 51895cc465ff71b057d5388636b0fcbf3ebadf95 Mon Sep 17 00:00:00 2001 From: Nicolas Carlo Date: Thu, 4 Feb 2016 11:08:55 +0100 Subject: [PATCH 1/7] Scale canvas after transformations --- src/gitgraph.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/gitgraph.js b/src/gitgraph.js index 3ff00117..d8f4811b 100644 --- a/src/gitgraph.js +++ b/src/gitgraph.js @@ -283,8 +283,6 @@ this.canvas.width = unscaledResolution.x * scalingFactor; this.canvas.height = unscaledResolution.y * scalingFactor; - this.context.scale( scalingFactor, scalingFactor ); - // Clear All this.context.clearRect( 0, 0, this.canvas.width, this.canvas.height ); @@ -301,6 +299,9 @@ this.offsetX = this.canvas.width - this.marginX * 2; } + // Scale the context when every transformations have been made. + this.context.scale( scalingFactor, scalingFactor ); + // Render branches for ( var i = this.branches.length - 1, branch; !!(branch = this.branches[ i ]); i-- ) { branch.render(); From 69fa7a3f144f22871f6281946b955034a3064398 Mon Sep 17 00:00:00 2001 From: Nicolas Carlo Date: Thu, 4 Feb 2016 11:09:18 +0100 Subject: [PATCH 2/7] Update example --- examples/index.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/examples/index.js b/examples/index.js index f6cefa69..1100191e 100644 --- a/examples/index.js +++ b/examples/index.js @@ -32,6 +32,7 @@ var myTemplate = new GitGraph.Template( myTemplateConfig ); var config = { template: "metro" // could be: "blackarrow" or "metro" or `myTemplate` (custom Template object) + //, orientation: "vertical-reverse" //, mode: "compact" // special compact mode : hide messages & compact graph }; var gitGraph = new GitGraph( config ); @@ -114,11 +115,11 @@ test.commit( {message:"It works !"} ); * TAGS * ***********************/ - // Add a tag to a commit - test.commit( {message:"Here you can see something", tag: "a-tag"} ); +// Add a tag to a commit +test.commit( {message:"Here you can see something", tag: "a-tag"} ); - // Perform a merge, with a tag - test.merge(master, {message: "New release", tag: "v1.0.0"}); +// Perform a merge, with a tag +test.merge(master, {message: "New release", tag: "v1.0.0"}); /*********************** From ad8d196cf9a5c021264226ca93ad581e00d1d051 Mon Sep 17 00:00:00 2001 From: Nicolas Carlo Date: Thu, 4 Feb 2016 11:36:15 +0100 Subject: [PATCH 3/7] Extract scaling ratio calculation into _getScale() So we can re-use it --- src/gitgraph.js | 44 +++++++++++++++++++++++++++++--------------- 1 file changed, 29 insertions(+), 15 deletions(-) diff --git a/src/gitgraph.js b/src/gitgraph.js index d8f4811b..0f6723fe 100644 --- a/src/gitgraph.js +++ b/src/gitgraph.js @@ -29,6 +29,34 @@ } } + /** + * Returns the scaling factor of given canvas `context`. + * Handles high-resolution displays. + * + * @param {Object} context + * @returns {Number} + * @private + */ + function _getScale ( context ) { + var backingStorePixelRatio; + var scalingFactor; + + // Account for high-resolution displays + scalingFactor = 1; + + if ( window.devicePixelRatio ) { + backingStorePixelRatio = context.webkitBackingStorePixelRatio || + context.mozBackingStorePixelRatio || + context.msBackingStorePixelRatio || + context.oBackingStorePixelRatio || + context.backingStorePixelRatio || 1; + + scalingFactor *= window.devicePixelRatio / backingStorePixelRatio; + } + + return scalingFactor; + } + /** * GitGraph * @@ -245,21 +273,7 @@ * @this GitGraph **/ GitGraph.prototype.render = function () { - var backingStorePixelRatio; - var scalingFactor; - - // Account for high-resolution displays - scalingFactor = 1; - - if ( window.devicePixelRatio ) { - backingStorePixelRatio = this.context.webkitBackingStorePixelRatio || - this.context.mozBackingStorePixelRatio || - this.context.msBackingStorePixelRatio || - this.context.oBackingStorePixelRatio || - this.context.backingStorePixelRatio || 1; - - scalingFactor *= window.devicePixelRatio / backingStorePixelRatio; - } + var scalingFactor = _getScale( this.context ); // Resize canvas var unscaledResolution = { From 455736739b55af45bd1a523fe6627050006fc3b0 Mon Sep 17 00:00:00 2001 From: Nicolas Carlo Date: Thu, 4 Feb 2016 11:37:28 +0100 Subject: [PATCH 4/7] Apply scale ratio to fix commit hovering on high resolution --- src/gitgraph.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/gitgraph.js b/src/gitgraph.js index 0f6723fe..ac7956fa 100644 --- a/src/gitgraph.js +++ b/src/gitgraph.js @@ -351,10 +351,11 @@ event.x = event.x ? event.x : event.clientX; event.y = event.y ? event.y : event.clientY; } + var scalingFactor = _getScale( this.context ); for ( var i = 0, commit; !!(commit = this.commits[ i ]); i++ ) { - var distanceX = (commit.x + this.offsetX + this.marginX - event.offsetX); - var distanceY = (commit.y + this.offsetY + this.marginY - event.offsetY); + var distanceX = (commit.x + (this.offsetX + this.marginX) / scalingFactor - event.offsetX); + var distanceY = (commit.y + (this.offsetY + this.marginY) / scalingFactor - event.offsetY); var distanceBetweenCommitCenterAndMouse = Math.sqrt( Math.pow( distanceX, 2 ) + Math.pow( distanceY, 2 ) ); var isOverCommit = distanceBetweenCommitCenterAndMouse < this.template.commit.dot.size; From 6b62fda370052d77622cde2677cb5c303d71d6f6 Mon Sep 17 00:00:00 2001 From: Nicolas Carlo Date: Thu, 4 Feb 2016 11:52:30 +0100 Subject: [PATCH 5/7] Move Firefox fallback where it's actually needed It worked because we modify a reference and applyCommit() was executed before showCommitTooltip(). But it was error prone. event.x / y are used in showCommitTooltip(), so the fallback should belong there too. --- src/gitgraph.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/gitgraph.js b/src/gitgraph.js index ac7956fa..9ad32cf1 100644 --- a/src/gitgraph.js +++ b/src/gitgraph.js @@ -346,11 +346,6 @@ * @self Gitgraph **/ GitGraph.prototype.applyCommits = function(event, callbackFn) { - // Fix firefox MouseEvent - if ( typeof InstallTrigger !== "undefined" )/* == (is Firefox) */ { - event.x = event.x ? event.x : event.clientX; - event.y = event.y ? event.y : event.clientY; - } var scalingFactor = _getScale( this.context ); for ( var i = 0, commit; !!(commit = this.commits[ i ]); i++ ) { @@ -375,6 +370,12 @@ var isOut = true; function showCommitTooltip (commit) { + // Fix firefox MouseEvent + if ( typeof InstallTrigger !== "undefined" )/* == (is Firefox) */ { + event.x = event.x ? event.x : event.clientX; + event.y = event.y ? event.y : event.clientY; + } + self.tooltip.style.left = event.x + "px"; // TODO Scroll bug self.tooltip.style.top = event.y + "px"; // TODO Scroll bug if (self.template.commit.tooltipHTMLFormatter !== null) { From 933d50156f4fd9377cf80d6a0c4e381d8f84026c Mon Sep 17 00:00:00 2001 From: Nicolas Carlo Date: Thu, 4 Feb 2016 11:52:52 +0100 Subject: [PATCH 6/7] Code reformat --- src/gitgraph.js | 87 +++++++++++++++++++++++++------------------------ 1 file changed, 44 insertions(+), 43 deletions(-) diff --git a/src/gitgraph.js b/src/gitgraph.js index 9ad32cf1..50a9209a 100644 --- a/src/gitgraph.js +++ b/src/gitgraph.js @@ -3,6 +3,7 @@ /** * Emit an event on the given element. + * * @param {HTMLElement} element - DOM element to trigger the event on. * @param {String} eventName - Name of the triggered event. * @param {Object} [data={}] - Custom data to attach to the event. @@ -343,9 +344,9 @@ * @param {MouseEvent} event - Mouse event * @param {commitCallback} callbackFn - A callback function that will be called for each commit * - * @self Gitgraph + * @this GitGraph **/ - GitGraph.prototype.applyCommits = function(event, callbackFn) { + GitGraph.prototype.applyCommits = function ( event, callbackFn ) { var scalingFactor = _getScale( this.context ); for ( var i = 0, commit; !!(commit = this.commits[ i ]); i++ ) { @@ -354,7 +355,7 @@ var distanceBetweenCommitCenterAndMouse = Math.sqrt( Math.pow( distanceX, 2 ) + Math.pow( distanceY, 2 ) ); var isOverCommit = distanceBetweenCommitCenterAndMouse < this.template.commit.dot.size; - callbackFn(commit, isOverCommit); + callbackFn( commit, isOverCommit ); } }; @@ -363,13 +364,13 @@ * * @param {MouseEvent} event - Mouse event * - * @self Gitgraph + * @this GitGraph **/ GitGraph.prototype.hover = function ( event ) { var self = this.gitgraph; var isOut = true; - function showCommitTooltip (commit) { + function showCommitTooltip ( commit ) { // Fix firefox MouseEvent if ( typeof InstallTrigger !== "undefined" )/* == (is Firefox) */ { event.x = event.x ? event.x : event.clientX; @@ -378,15 +379,15 @@ self.tooltip.style.left = event.x + "px"; // TODO Scroll bug self.tooltip.style.top = event.y + "px"; // TODO Scroll bug - if (self.template.commit.tooltipHTMLFormatter !== null) { - self.tooltip.innerHTML = self.template.commit.tooltipHTMLFormatter(commit); + if ( self.template.commit.tooltipHTMLFormatter !== null ) { + self.tooltip.innerHTML = self.template.commit.tooltipHTMLFormatter( commit ); } else { self.tooltip.textContent = commit.sha1 + " - " + commit.message; } self.tooltip.style.display = "block"; } - function emitMouseoverEvent (commit) { + function emitMouseoverEvent ( commit ) { var mouseoverEventOptions = { author: commit.author, message: commit.message, @@ -397,14 +398,14 @@ _emitEvent( self.canvas, "commit:mouseover", mouseoverEventOptions ); } - self.applyCommits(event, function(commit, isOverCommit) { + self.applyCommits( event, function ( commit, isOverCommit ) { if ( isOverCommit ) { if ( !self.template.commit.message.display ) { - showCommitTooltip(commit); + showCommitTooltip( commit ); } if ( !commit.isMouseover ) { - emitMouseoverEvent(commit); + emitMouseoverEvent( commit ); } isOut = false; @@ -412,7 +413,7 @@ } else { commit.isMouseover = false; } - }); + } ); if ( isOut ) { self.tooltip.style.display = "none"; @@ -424,18 +425,18 @@ * * @param {MouseEvent} event - Mouse event * - * @self Gitgraph + * @this GitGraph **/ GitGraph.prototype.click = function ( event ) { - this.gitgraph.applyCommits(event, function(commit, isOverCommit) { - if (!isOverCommit) { + this.gitgraph.applyCommits( event, function ( commit, isOverCommit ) { + if ( !isOverCommit ) { return; } - if (commit.onClick !== null) { - commit.onClick(commit, true); + if ( commit.onClick !== null ) { + commit.onClick( commit, true ); } - }); + } ); }; // -------------------------------------------------------------------- @@ -469,7 +470,7 @@ this.template = this.parent.template; this.lineWidth = options.lineWidth || this.template.branch.lineWidth; this.lineDash = options.lineDash || this.template.branch.lineDash; - this.showLabel = booleanOptionOr(options.showLabel, this.template.branch.showLabel); + this.showLabel = booleanOptionOr( options.showLabel, this.template.branch.showLabel ); this.spacingX = this.template.branch.spacingX; this.spacingY = this.template.branch.spacingY; this.size = 0; @@ -640,8 +641,8 @@ options.showLabel = (isPathBeginning && this.showLabel) ? true : false; if ( options.showLabel ) { - options.x -= this.template.commit.spacingX; - options.y -= this.template.commit.spacingY; + options.x -= this.template.commit.spacingX; + options.y -= this.template.commit.spacingY; } var commit = new Commit( options ); @@ -785,7 +786,7 @@ this.column = 0; for ( ; ; this.column++ ) { if ( !( this.column in candidates ) || candidates[ this.column ] === 0 ) { - break; + break; } } }; @@ -879,7 +880,7 @@ // Label if ( this.showLabel ) { - drawTextBG( this.context, this.x + this.template.commit.spacingX, this.y + this.template.commit.spacingY, this.branch.name, "black", this.labelColor, this.labelFont, this.template.branch.labelRotation); + drawTextBG( this.context, this.x + this.template.commit.spacingX, this.y + this.template.commit.spacingY, this.branch.name, "black", this.labelColor, this.labelFont, this.template.branch.labelRotation ); } // Dot @@ -907,17 +908,17 @@ var tagWidth = this.template.commit.tag.spacingX; if ( this.tag !== null ) { this.parent.tagNum++; - var textWidth = this.context.measureText(this.tag).width; + var textWidth = this.context.measureText( this.tag ).width; if ( this.template.branch.labelRotation !== 0 ) { - var textHeight = getFontHeight(this.tagFont); + var textHeight = getFontHeight( this.tagFont ); drawTextBG( this.context, - this.x - this.dotSize/2, - ((this.parent.columnMax + 1) * this.template.commit.tag.spacingY) - this.template.commit.tag.spacingY/2 + (this.parent.tagNum % 2) * textHeight * 1.5, + this.x - this.dotSize / 2, + ((this.parent.columnMax + 1) * this.template.commit.tag.spacingY) - this.template.commit.tag.spacingY / 2 + (this.parent.tagNum % 2) * textHeight * 1.5, this.tag, "black", this.tagColor, this.tagFont, 0 ); } else { drawTextBG( this.context, - ((this.parent.columnMax + 1) * this.template.commit.tag.spacingX) - this.template.commit.tag.spacingX/2 + textWidth/2, - this.y - this.dotSize/2, + ((this.parent.columnMax + 1) * this.template.commit.tag.spacingX) - this.template.commit.tag.spacingX / 2 + textWidth / 2, + this.y - this.dotSize / 2, this.tag, "black", this.tagColor, this.tagFont, 0 ); } tagWidth = (tagWidth < textWidth) ? textWidth : tagWidth; @@ -946,7 +947,7 @@ } this.context.fillStyle = this.messageColor; - this.context.fillText( message, commitOffsetLeft, this.y + this.dotSize / 2); + this.context.fillText( message, commitOffsetLeft, this.y + this.dotSize / 2 ); } }; @@ -1179,14 +1180,14 @@ // -------------------------------------------------------------------- var getFontHeight = function ( font ) { - var body = document.getElementsByTagName("body")[0]; - var dummy = document.createElement("div"); - var dummyText = document.createTextNode("Mg"); - dummy.appendChild(dummyText); - dummy.setAttribute("style", "font: " + font + ";"); - body.appendChild(dummy); + var body = document.getElementsByTagName( "body" )[ 0 ]; + var dummy = document.createElement( "div" ); + var dummyText = document.createTextNode( "Mg" ); + dummy.appendChild( dummyText ); + dummy.setAttribute( "style", "font: " + font + ";" ); + body.appendChild( dummy ); var result = dummy.offsetHeight; - body.removeChild(dummy); + body.removeChild( dummy ); return result; }; @@ -1196,16 +1197,16 @@ function drawTextBG ( context, x, y, text, fgcolor, bgcolor, font, angle ) { context.save(); - context.translate(x, y); - context.rotate(angle*(Math.PI/180)); + context.translate( x, y ); + context.rotate( angle * (Math.PI / 180) ); context.textAlign = "center"; context.font = font; - var width = context.measureText(text).width; - var height = getFontHeight(font); + var width = context.measureText( text ).width; + var height = getFontHeight( font ); context.beginPath(); - context.rect(-(width/2)-4, -(height/2)+2, width+8, height+2); + context.rect( -(width / 2) - 4, -(height / 2) + 2, width + 8, height + 2 ); context.fillStyle = bgcolor; context.fill(); context.lineWidth = 2; @@ -1213,7 +1214,7 @@ context.stroke(); context.fillStyle = fgcolor; - context.fillText(text, 0, height/2); + context.fillText( text, 0, height / 2 ); context.restore(); } From 4e71f84d46bd7b920b324a8e5d4175a47b76d8b1 Mon Sep 17 00:00:00 2001 From: Nicolas Carlo Date: Thu, 4 Feb 2016 11:54:13 +0100 Subject: [PATCH 7/7] Bump version and compile --- bower.json | 2 +- build/gitgraph.js | 154 +++++++++++++++++++++++------------------ build/gitgraph.min.js | 4 +- docs/Branch.html | 20 +++--- docs/Commit.html | 10 +-- docs/GitGraph.html | 31 ++++++--- docs/Template.html | 8 +-- docs/gitgraph.js.html | 156 +++++++++++++++++++++++------------------- docs/global.html | 144 ++++++++++++++++++++++++++++++++++++-- docs/index.html | 4 +- package.json | 2 +- 11 files changed, 358 insertions(+), 177 deletions(-) diff --git a/bower.json b/bower.json index 9214150c..564dead6 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "gitgraph.js", - "version": "1.1.2", + "version": "1.1.3", "main": [ "./build/gitgraph.js", "./build/gitgraph.css" ], "ignore": [ "**/.*" diff --git a/build/gitgraph.js b/build/gitgraph.js index a0f39093..06202ef1 100644 --- a/build/gitgraph.js +++ b/build/gitgraph.js @@ -1,5 +1,5 @@ /* ========================================================== - * GitGraph v1.1.2 + * GitGraph v1.1.3 * https://github.com/nicoespeon/gitgraph.js * ========================================================== * Copyright (c) 2016 Nicolas CARLO (@nicoespeon) ٩(^‿^)۶ @@ -13,6 +13,7 @@ /** * Emit an event on the given element. + * * @param {HTMLElement} element - DOM element to trigger the event on. * @param {String} eventName - Name of the triggered event. * @param {Object} [data={}] - Custom data to attach to the event. @@ -39,6 +40,34 @@ } } + /** + * Returns the scaling factor of given canvas `context`. + * Handles high-resolution displays. + * + * @param {Object} context + * @returns {Number} + * @private + */ + function _getScale ( context ) { + var backingStorePixelRatio; + var scalingFactor; + + // Account for high-resolution displays + scalingFactor = 1; + + if ( window.devicePixelRatio ) { + backingStorePixelRatio = context.webkitBackingStorePixelRatio || + context.mozBackingStorePixelRatio || + context.msBackingStorePixelRatio || + context.oBackingStorePixelRatio || + context.backingStorePixelRatio || 1; + + scalingFactor *= window.devicePixelRatio / backingStorePixelRatio; + } + + return scalingFactor; + } + /** * GitGraph * @@ -255,21 +284,7 @@ * @this GitGraph **/ GitGraph.prototype.render = function () { - var backingStorePixelRatio; - var scalingFactor; - - // Account for high-resolution displays - scalingFactor = 1; - - if ( window.devicePixelRatio ) { - backingStorePixelRatio = this.context.webkitBackingStorePixelRatio || - this.context.mozBackingStorePixelRatio || - this.context.msBackingStorePixelRatio || - this.context.oBackingStorePixelRatio || - this.context.backingStorePixelRatio || 1; - - scalingFactor *= window.devicePixelRatio / backingStorePixelRatio; - } + var scalingFactor = _getScale( this.context ); // Resize canvas var unscaledResolution = { @@ -293,8 +308,6 @@ this.canvas.width = unscaledResolution.x * scalingFactor; this.canvas.height = unscaledResolution.y * scalingFactor; - this.context.scale( scalingFactor, scalingFactor ); - // Clear All this.context.clearRect( 0, 0, this.canvas.width, this.canvas.height ); @@ -311,6 +324,9 @@ this.offsetX = this.canvas.width - this.marginX * 2; } + // Scale the context when every transformations have been made. + this.context.scale( scalingFactor, scalingFactor ); + // Render branches for ( var i = this.branches.length - 1, branch; !!(branch = this.branches[ i ]); i-- ) { branch.render(); @@ -338,22 +354,18 @@ * @param {MouseEvent} event - Mouse event * @param {commitCallback} callbackFn - A callback function that will be called for each commit * - * @self Gitgraph + * @this GitGraph **/ - GitGraph.prototype.applyCommits = function(event, callbackFn) { - // Fix firefox MouseEvent - if ( typeof InstallTrigger !== "undefined" )/* == (is Firefox) */ { - event.x = event.x ? event.x : event.clientX; - event.y = event.y ? event.y : event.clientY; - } + GitGraph.prototype.applyCommits = function ( event, callbackFn ) { + var scalingFactor = _getScale( this.context ); for ( var i = 0, commit; !!(commit = this.commits[ i ]); i++ ) { - var distanceX = (commit.x + this.offsetX + this.marginX - event.offsetX); - var distanceY = (commit.y + this.offsetY + this.marginY - event.offsetY); + var distanceX = (commit.x + (this.offsetX + this.marginX) / scalingFactor - event.offsetX); + var distanceY = (commit.y + (this.offsetY + this.marginY) / scalingFactor - event.offsetY); var distanceBetweenCommitCenterAndMouse = Math.sqrt( Math.pow( distanceX, 2 ) + Math.pow( distanceY, 2 ) ); var isOverCommit = distanceBetweenCommitCenterAndMouse < this.template.commit.dot.size; - callbackFn(commit, isOverCommit); + callbackFn( commit, isOverCommit ); } }; @@ -362,24 +374,30 @@ * * @param {MouseEvent} event - Mouse event * - * @self Gitgraph + * @this GitGraph **/ GitGraph.prototype.hover = function ( event ) { var self = this.gitgraph; var isOut = true; - function showCommitTooltip (commit) { + function showCommitTooltip ( commit ) { + // Fix firefox MouseEvent + if ( typeof InstallTrigger !== "undefined" )/* == (is Firefox) */ { + event.x = event.x ? event.x : event.clientX; + event.y = event.y ? event.y : event.clientY; + } + self.tooltip.style.left = event.x + "px"; // TODO Scroll bug self.tooltip.style.top = event.y + "px"; // TODO Scroll bug - if (self.template.commit.tooltipHTMLFormatter !== null) { - self.tooltip.innerHTML = self.template.commit.tooltipHTMLFormatter(commit); + if ( self.template.commit.tooltipHTMLFormatter !== null ) { + self.tooltip.innerHTML = self.template.commit.tooltipHTMLFormatter( commit ); } else { self.tooltip.textContent = commit.sha1 + " - " + commit.message; } self.tooltip.style.display = "block"; } - function emitMouseoverEvent (commit) { + function emitMouseoverEvent ( commit ) { var mouseoverEventOptions = { author: commit.author, message: commit.message, @@ -390,14 +408,14 @@ _emitEvent( self.canvas, "commit:mouseover", mouseoverEventOptions ); } - self.applyCommits(event, function(commit, isOverCommit) { + self.applyCommits( event, function ( commit, isOverCommit ) { if ( isOverCommit ) { if ( !self.template.commit.message.display ) { - showCommitTooltip(commit); + showCommitTooltip( commit ); } if ( !commit.isMouseover ) { - emitMouseoverEvent(commit); + emitMouseoverEvent( commit ); } isOut = false; @@ -405,7 +423,7 @@ } else { commit.isMouseover = false; } - }); + } ); if ( isOut ) { self.tooltip.style.display = "none"; @@ -417,18 +435,18 @@ * * @param {MouseEvent} event - Mouse event * - * @self Gitgraph + * @this GitGraph **/ GitGraph.prototype.click = function ( event ) { - this.gitgraph.applyCommits(event, function(commit, isOverCommit) { - if (!isOverCommit) { + this.gitgraph.applyCommits( event, function ( commit, isOverCommit ) { + if ( !isOverCommit ) { return; } - if (commit.onClick !== null) { - commit.onClick(commit, true); + if ( commit.onClick !== null ) { + commit.onClick( commit, true ); } - }); + } ); }; // -------------------------------------------------------------------- @@ -462,7 +480,7 @@ this.template = this.parent.template; this.lineWidth = options.lineWidth || this.template.branch.lineWidth; this.lineDash = options.lineDash || this.template.branch.lineDash; - this.showLabel = booleanOptionOr(options.showLabel, this.template.branch.showLabel); + this.showLabel = booleanOptionOr( options.showLabel, this.template.branch.showLabel ); this.spacingX = this.template.branch.spacingX; this.spacingY = this.template.branch.spacingY; this.size = 0; @@ -633,8 +651,8 @@ options.showLabel = (isPathBeginning && this.showLabel) ? true : false; if ( options.showLabel ) { - options.x -= this.template.commit.spacingX; - options.y -= this.template.commit.spacingY; + options.x -= this.template.commit.spacingX; + options.y -= this.template.commit.spacingY; } var commit = new Commit( options ); @@ -778,7 +796,7 @@ this.column = 0; for ( ; ; this.column++ ) { if ( !( this.column in candidates ) || candidates[ this.column ] === 0 ) { - break; + break; } } }; @@ -872,7 +890,7 @@ // Label if ( this.showLabel ) { - drawTextBG( this.context, this.x + this.template.commit.spacingX, this.y + this.template.commit.spacingY, this.branch.name, "black", this.labelColor, this.labelFont, this.template.branch.labelRotation); + drawTextBG( this.context, this.x + this.template.commit.spacingX, this.y + this.template.commit.spacingY, this.branch.name, "black", this.labelColor, this.labelFont, this.template.branch.labelRotation ); } // Dot @@ -900,17 +918,17 @@ var tagWidth = this.template.commit.tag.spacingX; if ( this.tag !== null ) { this.parent.tagNum++; - var textWidth = this.context.measureText(this.tag).width; + var textWidth = this.context.measureText( this.tag ).width; if ( this.template.branch.labelRotation !== 0 ) { - var textHeight = getFontHeight(this.tagFont); + var textHeight = getFontHeight( this.tagFont ); drawTextBG( this.context, - this.x - this.dotSize/2, - ((this.parent.columnMax + 1) * this.template.commit.tag.spacingY) - this.template.commit.tag.spacingY/2 + (this.parent.tagNum % 2) * textHeight * 1.5, + this.x - this.dotSize / 2, + ((this.parent.columnMax + 1) * this.template.commit.tag.spacingY) - this.template.commit.tag.spacingY / 2 + (this.parent.tagNum % 2) * textHeight * 1.5, this.tag, "black", this.tagColor, this.tagFont, 0 ); } else { drawTextBG( this.context, - ((this.parent.columnMax + 1) * this.template.commit.tag.spacingX) - this.template.commit.tag.spacingX/2 + textWidth/2, - this.y - this.dotSize/2, + ((this.parent.columnMax + 1) * this.template.commit.tag.spacingX) - this.template.commit.tag.spacingX / 2 + textWidth / 2, + this.y - this.dotSize / 2, this.tag, "black", this.tagColor, this.tagFont, 0 ); } tagWidth = (tagWidth < textWidth) ? textWidth : tagWidth; @@ -939,7 +957,7 @@ } this.context.fillStyle = this.messageColor; - this.context.fillText( message, commitOffsetLeft, this.y + this.dotSize / 2); + this.context.fillText( message, commitOffsetLeft, this.y + this.dotSize / 2 ); } }; @@ -1172,14 +1190,14 @@ // -------------------------------------------------------------------- var getFontHeight = function ( font ) { - var body = document.getElementsByTagName("body")[0]; - var dummy = document.createElement("div"); - var dummyText = document.createTextNode("Mg"); - dummy.appendChild(dummyText); - dummy.setAttribute("style", "font: " + font + ";"); - body.appendChild(dummy); + var body = document.getElementsByTagName( "body" )[ 0 ]; + var dummy = document.createElement( "div" ); + var dummyText = document.createTextNode( "Mg" ); + dummy.appendChild( dummyText ); + dummy.setAttribute( "style", "font: " + font + ";" ); + body.appendChild( dummy ); var result = dummy.offsetHeight; - body.removeChild(dummy); + body.removeChild( dummy ); return result; }; @@ -1189,16 +1207,16 @@ function drawTextBG ( context, x, y, text, fgcolor, bgcolor, font, angle ) { context.save(); - context.translate(x, y); - context.rotate(angle*(Math.PI/180)); + context.translate( x, y ); + context.rotate( angle * (Math.PI / 180) ); context.textAlign = "center"; context.font = font; - var width = context.measureText(text).width; - var height = getFontHeight(font); + var width = context.measureText( text ).width; + var height = getFontHeight( font ); context.beginPath(); - context.rect(-(width/2)-4, -(height/2)+2, width+8, height+2); + context.rect( -(width / 2) - 4, -(height / 2) + 2, width + 8, height + 2 ); context.fillStyle = bgcolor; context.fill(); context.lineWidth = 2; @@ -1206,7 +1224,7 @@ context.stroke(); context.fillStyle = fgcolor; - context.fillText(text, 0, height/2); + context.fillText( text, 0, height / 2 ); context.restore(); } diff --git a/build/gitgraph.min.js b/build/gitgraph.min.js index 91b62ac8..d2d69a9d 100644 --- a/build/gitgraph.min.js +++ b/build/gitgraph.min.js @@ -1,5 +1,5 @@ /* ========================================================== - * GitGraph v1.1.2 + * GitGraph v1.1.3 * https://github.com/nicoespeon/gitgraph.js * ========================================================== * Copyright (c) 2016 Nicolas CARLO (@nicoespeon) ٩(^‿^)۶ @@ -7,4 +7,4 @@ * * GitGraph.js may be freely distributed under the MIT Licence * ========================================================== */ -!function(){"use strict";function a(a,b,c){var d;document.createEvent?(d=document.createEvent("HTMLEvents"),d.initEvent(b,!0,!0)):(d=document.createEventObject(),d.eventType=b),d.eventName=b,d.data=c||{},document.createEvent?a.dispatchEvent(d):a.fireEvent("on"+d.eventType,d)}function b(a){switch(a="object"==typeof a?a:{},this.elementId="string"==typeof a.elementId?a.elementId:"gitGraph",this.author="string"==typeof a.author?a.author:"Sergio Flores ",this.template="string"==typeof a.template||"object"==typeof a.template?this.newTemplate(a.template):a.template instanceof e?a.template:this.newTemplate("metro"),this.mode=a.mode||null,"compact"===this.mode&&(this.template.commit.message.display=!1),a.orientation){case"vertical-reverse":this.template.commit.spacingY*=-1,this.orientation="vertical-reverse",this.template.branch.labelRotation=0,this.template.commit.tag.spacingY*=-1;break;case"horizontal":this.template.commit.message.display=!1,this.template.commit.spacingX=this.template.commit.spacingY,this.template.branch.spacingY=this.template.branch.spacingX,this.template.commit.spacingY=0,this.template.branch.spacingX=0,this.orientation="horizontal",this.template.branch.labelRotation=-90,this.template.commit.tag.spacingX=-this.template.commit.spacingX,this.template.commit.tag.spacingY=this.template.branch.spacingY;break;case"horizontal-reverse":this.template.commit.message.display=!1,this.template.commit.spacingX=-this.template.commit.spacingY,this.template.branch.spacingY=this.template.branch.spacingX,this.template.commit.spacingY=0,this.template.branch.spacingX=0,this.orientation="horizontal-reverse",this.template.branch.labelRotation=90,this.template.commit.tag.spacingX=-this.template.commit.spacingY,this.template.commit.tag.spacingY=this.template.branch.spacingY;break;default:this.orientation="vertical",this.template.branch.labelRotation=0}this.marginX=this.template.branch.spacingX+2*this.template.commit.dot.size,this.marginY=this.template.branch.spacingY+2*this.template.commit.dot.size,this.offsetX=0,this.offsetY=0,this.canvas=document.getElementById(this.elementId)||a.canvas,this.context=this.canvas.getContext("2d"),this.context.textBaseline="center",this.tooltip=document.createElement("div"),this.tooltip.className="gitgraph-tooltip",this.tooltip.style.position="fixed",this.tooltip.style.display="none",document.body.appendChild(this.tooltip),this.HEAD=null,this.branches=[],this.commits=[],this.columnMax=0,this.commitOffsetX=0,this.commitOffsetY=0;var b={handleEvent:this.hover,gitgraph:this};this.canvas.addEventListener("mousemove",b,!1);var c={handleEvent:this.click,gitgraph:this};this.canvas.addEventListener("mousedown",c,!1),window.onresize=this.render.bind(this)}function c(a){if(a.parent instanceof b!=!1){a="object"==typeof a?a:{},this.parent=a.parent,this.parentBranch=a.parentBranch,this.name="string"==typeof a.name?a.name:"no-name",this.context=this.parent.context,this.template=this.parent.template,this.lineWidth=a.lineWidth||this.template.branch.lineWidth,this.lineDash=a.lineDash||this.template.branch.lineDash,this.showLabel=f(a.showLabel,this.template.branch.showLabel),this.spacingX=this.template.branch.spacingX,this.spacingY=this.template.branch.spacingY,this.size=0,this.height=0,this.width=0,this.commits=[],this.path=[],"number"==typeof a.column?this.column=a.column:(this.column=0,this.calculColumn()),this.parent.columnMax=this.column>this.parent.columnMax?this.column:this.parent.columnMax,this.offsetX=this.column*this.spacingX,this.offsetY=this.column*this.spacingY;var c=this.column%this.template.colors.length;this.color=a.color||this.template.branch.color||this.template.colors[c],this.checkout()}}function d(a){a.parent instanceof b!=!1&&(a="object"==typeof a?a:{},this.parent=a.parent,this.template=this.parent.template,this.context=this.parent.context,this.branch=a.branch,this.author=a.author||this.parent.author,this.date=a.date||(new Date).toUTCString(),this.detail=a.detail||null,this.tag=a.tag||null,this.tagColor=a.tagColor||a.color,this.tagFont=a.tagFont||this.template.commit.tag.font,this.sha1=a.sha1||Math.random(100).toString(16).substring(3,10),this.message=a.message||"He doesn't like George Michael! Boooo!",this.arrowDisplay=a.arrowDisplay,this.messageDisplay=f(a.messageDisplay,this.template.commit.message.display),this.messageAuthorDisplay=f(a.messageAuthorDisplay,this.template.commit.message.displayAuthor),this.messageBranchDisplay=f(a.messageBranchDisplay,this.template.commit.message.displayBranch),this.messageHashDisplay=f(a.messageHashDisplay,this.template.commit.message.displayHash),this.messageColor=a.messageColor||a.color,this.messageFont=a.messageFont||this.template.commit.message.font,this.dotColor=a.dotColor||a.color,this.dotSize=a.dotSize||this.template.commit.dot.size,this.dotStrokeWidth=a.dotStrokeWidth||this.template.commit.dot.strokeWidth,this.dotStrokeColor=a.dotStrokeColor||this.template.commit.dot.strokeColor||a.color,this.type=a.type||null,this.onClick=a.onClick||null,this.representedObject=a.representedObject||null,this.parentCommit=a.parentCommit,this.x=a.x,this.y=a.y,this.showLabel=a.showLabel,this.labelColor=a.labelColor||a.color,this.labelFont=a.labelFont||this.template.branch.labelFont,this.parent.commits.push(this))}function e(a){a="object"==typeof a?a:{},a.branch=a.branch||{},a.arrow=a.arrow||{},a.commit=a.commit||{},a.commit.dot=a.commit.dot||{},a.commit.tag=a.commit.tag||{},a.commit.message=a.commit.message||{},this.colors=a.colors||["#6963FF","#47E8D4","#6BDB52","#E84BA5","#FFA657"],this.branch={},this.branch.color=a.branch.color||null,this.branch.lineWidth=a.branch.lineWidth||2,this.branch.lineDash=a.branch.lineDash||[],this.branch.showLabel=a.branch.showLabel||!1,this.branch.labelColor=a.branch.labelColor||null,this.branch.labelFont=a.branch.labelFont||"normal 8pt Calibri",this.branch.labelRotation=a.branch.labelRotation||0,this.branch.mergeStyle=a.branch.mergeStyle||"bezier",this.branch.spacingX="number"==typeof a.branch.spacingX?a.branch.spacingX:20,this.branch.spacingY=a.branch.spacingY||0,this.arrow={},this.arrow.size=a.arrow.size||null,this.arrow.color=a.arrow.color||null,this.arrow.active="number"==typeof this.arrow.size,this.arrow.offset=a.arrow.offset||2,this.commit={},this.commit.spacingX=a.commit.spacingX||0,this.commit.spacingY="number"==typeof a.commit.spacingY?a.commit.spacingY:25,this.commit.widthExtension="number"==typeof a.commit.widthExtension?a.commit.widthExtension:0,this.commit.tooltipHTMLFormatter=a.commit.tooltipHTMLFormatter||null,this.commit.color=a.commit.color||null,this.commit.dot={},this.commit.dot.color=a.commit.dot.color||null,this.commit.dot.size=a.commit.dot.size||3,this.commit.dot.strokeWidth=a.commit.dot.strokeWidth||null,this.commit.dot.strokeColor=a.commit.dot.strokeColor||null,this.commit.tag={},this.commit.tag.color=a.commit.tag.color||this.commit.dot.color,this.commit.tag.font=a.commit.tag.font||a.commit.message.font||"normal 10pt Calibri",this.commit.tag.spacingX=this.branch.spacingX,this.commit.tag.spacingY=this.commit.spacingY,this.commit.message={},this.commit.message.display=f(a.commit.message.display,!0),this.commit.message.displayAuthor=f(a.commit.message.displayAuthor,!0),this.commit.message.displayBranch=f(a.commit.message.displayBranch,!0),this.commit.message.displayHash=f(a.commit.message.displayHash,!0),this.commit.message.color=a.commit.message.color||null,this.commit.message.font=a.commit.message.font||"normal 12pt Calibri"}function f(a,b){return"boolean"==typeof a?a:b}function g(a,b,c,d,e,f,g,i){a.save(),a.translate(b,c),a.rotate(i*(Math.PI/180)),a.textAlign="center",a.font=g;var j=a.measureText(d).width,k=h(g);a.beginPath(),a.rect(-(j/2)-4,-(k/2)+2,j+8,k+2),a.fillStyle=f,a.fill(),a.lineWidth=2,a.strokeStyle="black",a.stroke(),a.fillStyle=e,a.fillText(d,0,k/2),a.restore()}b.prototype.branch=function(a){if("string"==typeof a){var b=a;a={},a.name=b}a="object"==typeof a?a:{},a.parent=this,a.parentBranch=a.parentBranch||this.HEAD;var d=new c(a);return this.branches.push(d),d},b.prototype.orphanBranch=function(a){if("string"==typeof a){var b=a;a={},a.name=b}a="object"==typeof a?a:{},a.parent=this;var d=new c(a);return this.branches.push(d),d},b.prototype.commit=function(a){return this.HEAD.commit(a),this},b.prototype.newTemplate=function(a){return"string"==typeof a?(new e).get(a):new e(a)},b.prototype.render=function(){var a,b;b=1,window.devicePixelRatio&&(a=this.context.webkitBackingStorePixelRatio||this.context.mozBackingStorePixelRatio||this.context.msBackingStorePixelRatio||this.context.oBackingStorePixelRatio||this.context.backingStorePixelRatio||1,b*=window.devicePixelRatio/a);var c={x:Math.abs((this.columnMax+1)*this.template.branch.spacingX)+Math.abs(this.commitOffsetX)+2*this.marginX,y:Math.abs((this.columnMax+1)*this.template.branch.spacingY)+Math.abs(this.commitOffsetY)+2*this.marginY};this.template.commit.message.display&&(c.x+=800),c.x+=this.template.commit.widthExtension,this.canvas.style.width=c.x+"px",this.canvas.style.height=c.y+"px",this.canvas.width=c.x*b,this.canvas.height=c.y*b,this.context.scale(b,b),this.context.clearRect(0,0,this.canvas.width,this.canvas.height),this.context.translate(this.marginX,this.marginY),this.template.commit.spacingY>0&&(this.context.translate(0,this.canvas.height-2*this.marginY),this.offsetY=this.canvas.height-2*this.marginY),this.template.commit.spacingX>0&&(this.context.translate(this.canvas.width-2*this.marginX,0),this.offsetX=this.canvas.width-2*this.marginX);for(var d,e=this.branches.length-1;d=this.branches[e];e--)d.render();this.tagNum=0;for(var f,g=0;f=this.commits[g];g++)f.render()},b.prototype.applyCommits=function(a,b){"undefined"!=typeof InstallTrigger&&(a.x=a.x?a.x:a.clientX,a.y=a.y?a.y:a.clientY);for(var c,d=0;c=this.commits[d];d++){var e=c.x+this.offsetX+this.marginX-a.offsetX,f=c.y+this.offsetY+this.marginY-a.offsetY,g=Math.sqrt(Math.pow(e,2)+Math.pow(f,2)),h=ga?b:a}var e=(this.parent.columnMax+1)*this.template.branch.spacingX+a;if(null!==this.detail&&(this.detail.style.left=this.parent.canvas.offsetLeft+e+this.x+30+"px",this.detail.style.top=this.parent.canvas.offsetTop+this.y+40+"px",this.detail.width=30),this.messageDisplay){var f=this.message;this.messageHashDisplay&&(f=this.sha1+" "+f),this.messageAuthorDisplay&&(f+=this.author?" - "+this.author:""),this.messageBranchDisplay&&(f=(this.branch.name?"["+this.branch.name+"] ":"")+f),this.context.fillStyle=this.messageColor,this.context.fillText(f,e,this.y+this.dotSize/2)}},d.prototype.arrow=function(){var a=this.template.arrow.size,b=this.template.arrow.color||this.branch.color,c=Math.atan2(this.parentCommit.y-this.y,this.parentCommit.x-this.x);("mergeCommit"===this.type||this===this.branch.commits[0])&&(c=Math.atan2(this.template.branch.spacingY*(this.parentCommit.branch.column-this.branch.column)+this.template.commit.spacingY*(this.showLabel?2:1),this.template.branch.spacingX*(this.parentCommit.branch.column-this.branch.column)+this.template.commit.spacingX*(this.showLabel?2:1)),b=this.parentCommit.branch.color);var d=Math.PI/7,e=this.template.commit.dot.size+this.template.arrow.offset,f=e*Math.cos(c)+this.x,g=e*Math.sin(c)+this.y,h=(e+a)*Math.cos(c-d)+this.x,i=(e+a)*Math.sin(c-d)+this.y,j=(e+a/2)*Math.cos(c)+this.x,k=(e+a/2)*Math.sin(c)+this.y,l=(e+a)*Math.cos(c+d)+this.x,m=(e+a)*Math.sin(c+d)+this.y;this.context.beginPath(),this.context.fillStyle=b,this.context.moveTo(f,g),this.context.lineTo(h,i),this.context.quadraticCurveTo(j,k,l,m),this.context.lineTo(l,m),this.context.fill()},e.prototype.get=function(a){var b={};switch(a){case"blackarrow":b={branch:{color:"#000000",lineWidth:4,spacingX:50,mergeStyle:"straight"},commit:{spacingY:-60,dot:{size:12,strokeColor:"#000000",strokeWidth:7},message:{color:"black"}},arrow:{size:16,offset:2.5}};break;case"metro":default:b={colors:["#979797","#008fb5","#f1c109"],branch:{lineWidth:10,spacingX:50},commit:{spacingY:-80,dot:{size:14},message:{font:"normal 14pt Arial"}}}}return new e(b)};var h=function(a){var b=document.getElementsByTagName("body")[0],c=document.createElement("div"),d=document.createTextNode("Mg");c.appendChild(d),c.setAttribute("style","font: "+a+";"),b.appendChild(c);var e=c.offsetHeight;return b.removeChild(c),e};window.GitGraph=b,window.GitGraph.Branch=c,window.GitGraph.Commit=d,window.GitGraph.Template=e}(); \ No newline at end of file +!function(){"use strict";function a(a,b,c){var d;document.createEvent?(d=document.createEvent("HTMLEvents"),d.initEvent(b,!0,!0)):(d=document.createEventObject(),d.eventType=b),d.eventName=b,d.data=c||{},document.createEvent?a.dispatchEvent(d):a.fireEvent("on"+d.eventType,d)}function b(a){var b,c;return c=1,window.devicePixelRatio&&(b=a.webkitBackingStorePixelRatio||a.mozBackingStorePixelRatio||a.msBackingStorePixelRatio||a.oBackingStorePixelRatio||a.backingStorePixelRatio||1,c*=window.devicePixelRatio/b),c}function c(a){switch(a="object"==typeof a?a:{},this.elementId="string"==typeof a.elementId?a.elementId:"gitGraph",this.author="string"==typeof a.author?a.author:"Sergio Flores ",this.template="string"==typeof a.template||"object"==typeof a.template?this.newTemplate(a.template):a.template instanceof f?a.template:this.newTemplate("metro"),this.mode=a.mode||null,"compact"===this.mode&&(this.template.commit.message.display=!1),a.orientation){case"vertical-reverse":this.template.commit.spacingY*=-1,this.orientation="vertical-reverse",this.template.branch.labelRotation=0,this.template.commit.tag.spacingY*=-1;break;case"horizontal":this.template.commit.message.display=!1,this.template.commit.spacingX=this.template.commit.spacingY,this.template.branch.spacingY=this.template.branch.spacingX,this.template.commit.spacingY=0,this.template.branch.spacingX=0,this.orientation="horizontal",this.template.branch.labelRotation=-90,this.template.commit.tag.spacingX=-this.template.commit.spacingX,this.template.commit.tag.spacingY=this.template.branch.spacingY;break;case"horizontal-reverse":this.template.commit.message.display=!1,this.template.commit.spacingX=-this.template.commit.spacingY,this.template.branch.spacingY=this.template.branch.spacingX,this.template.commit.spacingY=0,this.template.branch.spacingX=0,this.orientation="horizontal-reverse",this.template.branch.labelRotation=90,this.template.commit.tag.spacingX=-this.template.commit.spacingY,this.template.commit.tag.spacingY=this.template.branch.spacingY;break;default:this.orientation="vertical",this.template.branch.labelRotation=0}this.marginX=this.template.branch.spacingX+2*this.template.commit.dot.size,this.marginY=this.template.branch.spacingY+2*this.template.commit.dot.size,this.offsetX=0,this.offsetY=0,this.canvas=document.getElementById(this.elementId)||a.canvas,this.context=this.canvas.getContext("2d"),this.context.textBaseline="center",this.tooltip=document.createElement("div"),this.tooltip.className="gitgraph-tooltip",this.tooltip.style.position="fixed",this.tooltip.style.display="none",document.body.appendChild(this.tooltip),this.HEAD=null,this.branches=[],this.commits=[],this.columnMax=0,this.commitOffsetX=0,this.commitOffsetY=0;var b={handleEvent:this.hover,gitgraph:this};this.canvas.addEventListener("mousemove",b,!1);var c={handleEvent:this.click,gitgraph:this};this.canvas.addEventListener("mousedown",c,!1),window.onresize=this.render.bind(this)}function d(a){if(a.parent instanceof c!=!1){a="object"==typeof a?a:{},this.parent=a.parent,this.parentBranch=a.parentBranch,this.name="string"==typeof a.name?a.name:"no-name",this.context=this.parent.context,this.template=this.parent.template,this.lineWidth=a.lineWidth||this.template.branch.lineWidth,this.lineDash=a.lineDash||this.template.branch.lineDash,this.showLabel=g(a.showLabel,this.template.branch.showLabel),this.spacingX=this.template.branch.spacingX,this.spacingY=this.template.branch.spacingY,this.size=0,this.height=0,this.width=0,this.commits=[],this.path=[],"number"==typeof a.column?this.column=a.column:(this.column=0,this.calculColumn()),this.parent.columnMax=this.column>this.parent.columnMax?this.column:this.parent.columnMax,this.offsetX=this.column*this.spacingX,this.offsetY=this.column*this.spacingY;var b=this.column%this.template.colors.length;this.color=a.color||this.template.branch.color||this.template.colors[b],this.checkout()}}function e(a){a.parent instanceof c!=!1&&(a="object"==typeof a?a:{},this.parent=a.parent,this.template=this.parent.template,this.context=this.parent.context,this.branch=a.branch,this.author=a.author||this.parent.author,this.date=a.date||(new Date).toUTCString(),this.detail=a.detail||null,this.tag=a.tag||null,this.tagColor=a.tagColor||a.color,this.tagFont=a.tagFont||this.template.commit.tag.font,this.sha1=a.sha1||Math.random(100).toString(16).substring(3,10),this.message=a.message||"He doesn't like George Michael! Boooo!",this.arrowDisplay=a.arrowDisplay,this.messageDisplay=g(a.messageDisplay,this.template.commit.message.display),this.messageAuthorDisplay=g(a.messageAuthorDisplay,this.template.commit.message.displayAuthor),this.messageBranchDisplay=g(a.messageBranchDisplay,this.template.commit.message.displayBranch),this.messageHashDisplay=g(a.messageHashDisplay,this.template.commit.message.displayHash),this.messageColor=a.messageColor||a.color,this.messageFont=a.messageFont||this.template.commit.message.font,this.dotColor=a.dotColor||a.color,this.dotSize=a.dotSize||this.template.commit.dot.size,this.dotStrokeWidth=a.dotStrokeWidth||this.template.commit.dot.strokeWidth,this.dotStrokeColor=a.dotStrokeColor||this.template.commit.dot.strokeColor||a.color,this.type=a.type||null,this.onClick=a.onClick||null,this.representedObject=a.representedObject||null,this.parentCommit=a.parentCommit,this.x=a.x,this.y=a.y,this.showLabel=a.showLabel,this.labelColor=a.labelColor||a.color,this.labelFont=a.labelFont||this.template.branch.labelFont,this.parent.commits.push(this))}function f(a){a="object"==typeof a?a:{},a.branch=a.branch||{},a.arrow=a.arrow||{},a.commit=a.commit||{},a.commit.dot=a.commit.dot||{},a.commit.tag=a.commit.tag||{},a.commit.message=a.commit.message||{},this.colors=a.colors||["#6963FF","#47E8D4","#6BDB52","#E84BA5","#FFA657"],this.branch={},this.branch.color=a.branch.color||null,this.branch.lineWidth=a.branch.lineWidth||2,this.branch.lineDash=a.branch.lineDash||[],this.branch.showLabel=a.branch.showLabel||!1,this.branch.labelColor=a.branch.labelColor||null,this.branch.labelFont=a.branch.labelFont||"normal 8pt Calibri",this.branch.labelRotation=a.branch.labelRotation||0,this.branch.mergeStyle=a.branch.mergeStyle||"bezier",this.branch.spacingX="number"==typeof a.branch.spacingX?a.branch.spacingX:20,this.branch.spacingY=a.branch.spacingY||0,this.arrow={},this.arrow.size=a.arrow.size||null,this.arrow.color=a.arrow.color||null,this.arrow.active="number"==typeof this.arrow.size,this.arrow.offset=a.arrow.offset||2,this.commit={},this.commit.spacingX=a.commit.spacingX||0,this.commit.spacingY="number"==typeof a.commit.spacingY?a.commit.spacingY:25,this.commit.widthExtension="number"==typeof a.commit.widthExtension?a.commit.widthExtension:0,this.commit.tooltipHTMLFormatter=a.commit.tooltipHTMLFormatter||null,this.commit.color=a.commit.color||null,this.commit.dot={},this.commit.dot.color=a.commit.dot.color||null,this.commit.dot.size=a.commit.dot.size||3,this.commit.dot.strokeWidth=a.commit.dot.strokeWidth||null,this.commit.dot.strokeColor=a.commit.dot.strokeColor||null,this.commit.tag={},this.commit.tag.color=a.commit.tag.color||this.commit.dot.color,this.commit.tag.font=a.commit.tag.font||a.commit.message.font||"normal 10pt Calibri",this.commit.tag.spacingX=this.branch.spacingX,this.commit.tag.spacingY=this.commit.spacingY,this.commit.message={},this.commit.message.display=g(a.commit.message.display,!0),this.commit.message.displayAuthor=g(a.commit.message.displayAuthor,!0),this.commit.message.displayBranch=g(a.commit.message.displayBranch,!0),this.commit.message.displayHash=g(a.commit.message.displayHash,!0),this.commit.message.color=a.commit.message.color||null,this.commit.message.font=a.commit.message.font||"normal 12pt Calibri"}function g(a,b){return"boolean"==typeof a?a:b}function h(a,b,c,d,e,f,g,h){a.save(),a.translate(b,c),a.rotate(h*(Math.PI/180)),a.textAlign="center",a.font=g;var j=a.measureText(d).width,k=i(g);a.beginPath(),a.rect(-(j/2)-4,-(k/2)+2,j+8,k+2),a.fillStyle=f,a.fill(),a.lineWidth=2,a.strokeStyle="black",a.stroke(),a.fillStyle=e,a.fillText(d,0,k/2),a.restore()}c.prototype.branch=function(a){if("string"==typeof a){var b=a;a={},a.name=b}a="object"==typeof a?a:{},a.parent=this,a.parentBranch=a.parentBranch||this.HEAD;var c=new d(a);return this.branches.push(c),c},c.prototype.orphanBranch=function(a){if("string"==typeof a){var b=a;a={},a.name=b}a="object"==typeof a?a:{},a.parent=this;var c=new d(a);return this.branches.push(c),c},c.prototype.commit=function(a){return this.HEAD.commit(a),this},c.prototype.newTemplate=function(a){return"string"==typeof a?(new f).get(a):new f(a)},c.prototype.render=function(){var a=b(this.context),c={x:Math.abs((this.columnMax+1)*this.template.branch.spacingX)+Math.abs(this.commitOffsetX)+2*this.marginX,y:Math.abs((this.columnMax+1)*this.template.branch.spacingY)+Math.abs(this.commitOffsetY)+2*this.marginY};this.template.commit.message.display&&(c.x+=800),c.x+=this.template.commit.widthExtension,this.canvas.style.width=c.x+"px",this.canvas.style.height=c.y+"px",this.canvas.width=c.x*a,this.canvas.height=c.y*a,this.context.clearRect(0,0,this.canvas.width,this.canvas.height),this.context.translate(this.marginX,this.marginY),this.template.commit.spacingY>0&&(this.context.translate(0,this.canvas.height-2*this.marginY),this.offsetY=this.canvas.height-2*this.marginY),this.template.commit.spacingX>0&&(this.context.translate(this.canvas.width-2*this.marginX,0),this.offsetX=this.canvas.width-2*this.marginX),this.context.scale(a,a);for(var d,e=this.branches.length-1;d=this.branches[e];e--)d.render();this.tagNum=0;for(var f,g=0;f=this.commits[g];g++)f.render()},c.prototype.applyCommits=function(a,c){for(var d,e=b(this.context),f=0;d=this.commits[f];f++){var g=d.x+(this.offsetX+this.marginX)/e-a.offsetX,h=d.y+(this.offsetY+this.marginY)/e-a.offsetY,i=Math.sqrt(Math.pow(g,2)+Math.pow(h,2)),j=ia?b:a}var d=(this.parent.columnMax+1)*this.template.branch.spacingX+a;if(null!==this.detail&&(this.detail.style.left=this.parent.canvas.offsetLeft+d+this.x+30+"px",this.detail.style.top=this.parent.canvas.offsetTop+this.y+40+"px",this.detail.width=30),this.messageDisplay){var f=this.message;this.messageHashDisplay&&(f=this.sha1+" "+f),this.messageAuthorDisplay&&(f+=this.author?" - "+this.author:""),this.messageBranchDisplay&&(f=(this.branch.name?"["+this.branch.name+"] ":"")+f),this.context.fillStyle=this.messageColor,this.context.fillText(f,d,this.y+this.dotSize/2)}},e.prototype.arrow=function(){var a=this.template.arrow.size,b=this.template.arrow.color||this.branch.color,c=Math.atan2(this.parentCommit.y-this.y,this.parentCommit.x-this.x);("mergeCommit"===this.type||this===this.branch.commits[0])&&(c=Math.atan2(this.template.branch.spacingY*(this.parentCommit.branch.column-this.branch.column)+this.template.commit.spacingY*(this.showLabel?2:1),this.template.branch.spacingX*(this.parentCommit.branch.column-this.branch.column)+this.template.commit.spacingX*(this.showLabel?2:1)),b=this.parentCommit.branch.color);var d=Math.PI/7,e=this.template.commit.dot.size+this.template.arrow.offset,f=e*Math.cos(c)+this.x,g=e*Math.sin(c)+this.y,h=(e+a)*Math.cos(c-d)+this.x,i=(e+a)*Math.sin(c-d)+this.y,j=(e+a/2)*Math.cos(c)+this.x,k=(e+a/2)*Math.sin(c)+this.y,l=(e+a)*Math.cos(c+d)+this.x,m=(e+a)*Math.sin(c+d)+this.y;this.context.beginPath(),this.context.fillStyle=b,this.context.moveTo(f,g),this.context.lineTo(h,i),this.context.quadraticCurveTo(j,k,l,m),this.context.lineTo(l,m),this.context.fill()},f.prototype.get=function(a){var b={};switch(a){case"blackarrow":b={branch:{color:"#000000",lineWidth:4,spacingX:50,mergeStyle:"straight"},commit:{spacingY:-60,dot:{size:12,strokeColor:"#000000",strokeWidth:7},message:{color:"black"}},arrow:{size:16,offset:2.5}};break;case"metro":default:b={colors:["#979797","#008fb5","#f1c109"],branch:{lineWidth:10,spacingX:50},commit:{spacingY:-80,dot:{size:14},message:{font:"normal 14pt Arial"}}}}return new f(b)};var i=function(a){var b=document.getElementsByTagName("body")[0],c=document.createElement("div"),d=document.createTextNode("Mg");c.appendChild(d),c.setAttribute("style","font: "+a+";"),b.appendChild(c);var e=c.offsetHeight;return b.removeChild(c),e};window.GitGraph=c,window.GitGraph.Branch=d,window.GitGraph.Commit=e,window.GitGraph.Template=f}(); \ No newline at end of file diff --git a/docs/Branch.html b/docs/Branch.html index 6b95f48a..a55bf634 100644 --- a/docs/Branch.html +++ b/docs/Branch.html @@ -271,7 +271,7 @@
Properties
Source:
@@ -412,7 +412,7 @@
Parameters:
Source:
@@ -513,7 +513,7 @@
This:
Source:
@@ -585,7 +585,7 @@
This:
Source:
@@ -780,7 +780,7 @@
Properties
Source:
@@ -859,7 +859,7 @@
This:
Source:
@@ -1039,7 +1039,7 @@
Parameters:
Source:
@@ -1133,7 +1133,7 @@
This:
Source:
@@ -1174,13 +1174,13 @@
This:

- Documentation generated by JSDoc 3.2.2 on Sat Jan 23 2016 19:40:19 GMT+0100 (CET) + Documentation generated by JSDoc 3.2.2 on Thu Feb 04 2016 11:54:00 GMT+0100 (CET)
diff --git a/docs/Commit.html b/docs/Commit.html index 7edce3fc..0967b36b 100644 --- a/docs/Commit.html +++ b/docs/Commit.html @@ -1025,7 +1025,7 @@
Properties
Source:
@@ -1115,7 +1115,7 @@
This:
Source:
@@ -1187,7 +1187,7 @@
This:
Source:
@@ -1228,13 +1228,13 @@
This:

- Documentation generated by JSDoc 3.2.2 on Sat Jan 23 2016 19:40:19 GMT+0100 (CET) + Documentation generated by JSDoc 3.2.2 on Thu Feb 04 2016 11:54:00 GMT+0100 (CET)
diff --git a/docs/GitGraph.html b/docs/GitGraph.html index f673b53f..57f9f1bf 100644 --- a/docs/GitGraph.html +++ b/docs/GitGraph.html @@ -396,7 +396,7 @@
Properties
Source:
@@ -457,6 +457,9 @@

applyComm +

This:
+ +
Parameters:
@@ -554,7 +557,7 @@
Parameters:
Source:
@@ -677,7 +680,7 @@
Parameters:
Source:
@@ -749,6 +752,9 @@

clickThis:

+ +
Parameters:
@@ -823,7 +829,7 @@
Parameters:
Source:
@@ -943,7 +949,7 @@
Parameters:
Source:
@@ -1015,6 +1021,9 @@

hoverThis:

+ +
Parameters:
@@ -1089,7 +1098,7 @@
Parameters:
Source:
@@ -1209,7 +1218,7 @@
Parameters:
Source:
@@ -1350,7 +1359,7 @@
Parameters:
Source:
@@ -1451,7 +1460,7 @@
This:
Source:
@@ -1492,13 +1501,13 @@
This:

- Documentation generated by JSDoc 3.2.2 on Sat Jan 23 2016 19:40:19 GMT+0100 (CET) + Documentation generated by JSDoc 3.2.2 on Thu Feb 04 2016 11:54:00 GMT+0100 (CET)
diff --git a/docs/Template.html b/docs/Template.html index 0579f6d0..800a1847 100644 --- a/docs/Template.html +++ b/docs/Template.html @@ -1054,7 +1054,7 @@
Properties
Source:
@@ -1189,7 +1189,7 @@
Parameters:
Source:
@@ -1252,13 +1252,13 @@
Returns:

- Documentation generated by JSDoc 3.2.2 on Sat Jan 23 2016 19:40:19 GMT+0100 (CET) + Documentation generated by JSDoc 3.2.2 on Thu Feb 04 2016 11:54:00 GMT+0100 (CET)
diff --git a/docs/gitgraph.js.html b/docs/gitgraph.js.html index 997b64f4..c7aa4b6f 100644 --- a/docs/gitgraph.js.html +++ b/docs/gitgraph.js.html @@ -30,6 +30,7 @@

Source: gitgraph.js

/** * Emit an event on the given element. + * * @param {HTMLElement} element - DOM element to trigger the event on. * @param {String} eventName - Name of the triggered event. * @param {Object} [data={}] - Custom data to attach to the event. @@ -56,6 +57,34 @@

Source: gitgraph.js

} } + /** + * Returns the scaling factor of given canvas `context`. + * Handles high-resolution displays. + * + * @param {Object} context + * @returns {Number} + * @private + */ + function _getScale ( context ) { + var backingStorePixelRatio; + var scalingFactor; + + // Account for high-resolution displays + scalingFactor = 1; + + if ( window.devicePixelRatio ) { + backingStorePixelRatio = context.webkitBackingStorePixelRatio || + context.mozBackingStorePixelRatio || + context.msBackingStorePixelRatio || + context.oBackingStorePixelRatio || + context.backingStorePixelRatio || 1; + + scalingFactor *= window.devicePixelRatio / backingStorePixelRatio; + } + + return scalingFactor; + } + /** * GitGraph * @@ -272,21 +301,7 @@

Source: gitgraph.js

* @this GitGraph **/ GitGraph.prototype.render = function () { - var backingStorePixelRatio; - var scalingFactor; - - // Account for high-resolution displays - scalingFactor = 1; - - if ( window.devicePixelRatio ) { - backingStorePixelRatio = this.context.webkitBackingStorePixelRatio || - this.context.mozBackingStorePixelRatio || - this.context.msBackingStorePixelRatio || - this.context.oBackingStorePixelRatio || - this.context.backingStorePixelRatio || 1; - - scalingFactor *= window.devicePixelRatio / backingStorePixelRatio; - } + var scalingFactor = _getScale( this.context ); // Resize canvas var unscaledResolution = { @@ -310,8 +325,6 @@

Source: gitgraph.js

this.canvas.width = unscaledResolution.x * scalingFactor; this.canvas.height = unscaledResolution.y * scalingFactor; - this.context.scale( scalingFactor, scalingFactor ); - // Clear All this.context.clearRect( 0, 0, this.canvas.width, this.canvas.height ); @@ -328,6 +341,9 @@

Source: gitgraph.js

this.offsetX = this.canvas.width - this.marginX * 2; } + // Scale the context when every transformations have been made. + this.context.scale( scalingFactor, scalingFactor ); + // Render branches for ( var i = this.branches.length - 1, branch; !!(branch = this.branches[ i ]); i-- ) { branch.render(); @@ -355,22 +371,18 @@

Source: gitgraph.js

* @param {MouseEvent} event - Mouse event * @param {commitCallback} callbackFn - A callback function that will be called for each commit * - * @self Gitgraph + * @this GitGraph **/ - GitGraph.prototype.applyCommits = function(event, callbackFn) { - // Fix firefox MouseEvent - if ( typeof InstallTrigger !== "undefined" )/* == (is Firefox) */ { - event.x = event.x ? event.x : event.clientX; - event.y = event.y ? event.y : event.clientY; - } + GitGraph.prototype.applyCommits = function ( event, callbackFn ) { + var scalingFactor = _getScale( this.context ); for ( var i = 0, commit; !!(commit = this.commits[ i ]); i++ ) { - var distanceX = (commit.x + this.offsetX + this.marginX - event.offsetX); - var distanceY = (commit.y + this.offsetY + this.marginY - event.offsetY); + var distanceX = (commit.x + (this.offsetX + this.marginX) / scalingFactor - event.offsetX); + var distanceY = (commit.y + (this.offsetY + this.marginY) / scalingFactor - event.offsetY); var distanceBetweenCommitCenterAndMouse = Math.sqrt( Math.pow( distanceX, 2 ) + Math.pow( distanceY, 2 ) ); var isOverCommit = distanceBetweenCommitCenterAndMouse < this.template.commit.dot.size; - callbackFn(commit, isOverCommit); + callbackFn( commit, isOverCommit ); } }; @@ -379,24 +391,30 @@

Source: gitgraph.js

* * @param {MouseEvent} event - Mouse event * - * @self Gitgraph + * @this GitGraph **/ GitGraph.prototype.hover = function ( event ) { var self = this.gitgraph; var isOut = true; - function showCommitTooltip (commit) { + function showCommitTooltip ( commit ) { + // Fix firefox MouseEvent + if ( typeof InstallTrigger !== "undefined" )/* == (is Firefox) */ { + event.x = event.x ? event.x : event.clientX; + event.y = event.y ? event.y : event.clientY; + } + self.tooltip.style.left = event.x + "px"; // TODO Scroll bug self.tooltip.style.top = event.y + "px"; // TODO Scroll bug - if (self.template.commit.tooltipHTMLFormatter !== null) { - self.tooltip.innerHTML = self.template.commit.tooltipHTMLFormatter(commit); + if ( self.template.commit.tooltipHTMLFormatter !== null ) { + self.tooltip.innerHTML = self.template.commit.tooltipHTMLFormatter( commit ); } else { self.tooltip.textContent = commit.sha1 + " - " + commit.message; } self.tooltip.style.display = "block"; } - function emitMouseoverEvent (commit) { + function emitMouseoverEvent ( commit ) { var mouseoverEventOptions = { author: commit.author, message: commit.message, @@ -407,14 +425,14 @@

Source: gitgraph.js

_emitEvent( self.canvas, "commit:mouseover", mouseoverEventOptions ); } - self.applyCommits(event, function(commit, isOverCommit) { + self.applyCommits( event, function ( commit, isOverCommit ) { if ( isOverCommit ) { if ( !self.template.commit.message.display ) { - showCommitTooltip(commit); + showCommitTooltip( commit ); } if ( !commit.isMouseover ) { - emitMouseoverEvent(commit); + emitMouseoverEvent( commit ); } isOut = false; @@ -422,7 +440,7 @@

Source: gitgraph.js

} else { commit.isMouseover = false; } - }); + } ); if ( isOut ) { self.tooltip.style.display = "none"; @@ -434,18 +452,18 @@

Source: gitgraph.js

* * @param {MouseEvent} event - Mouse event * - * @self Gitgraph + * @this GitGraph **/ GitGraph.prototype.click = function ( event ) { - this.gitgraph.applyCommits(event, function(commit, isOverCommit) { - if (!isOverCommit) { + this.gitgraph.applyCommits( event, function ( commit, isOverCommit ) { + if ( !isOverCommit ) { return; } - if (commit.onClick !== null) { - commit.onClick(commit, true); + if ( commit.onClick !== null ) { + commit.onClick( commit, true ); } - }); + } ); }; // -------------------------------------------------------------------- @@ -479,7 +497,7 @@

Source: gitgraph.js

this.template = this.parent.template; this.lineWidth = options.lineWidth || this.template.branch.lineWidth; this.lineDash = options.lineDash || this.template.branch.lineDash; - this.showLabel = booleanOptionOr(options.showLabel, this.template.branch.showLabel); + this.showLabel = booleanOptionOr( options.showLabel, this.template.branch.showLabel ); this.spacingX = this.template.branch.spacingX; this.spacingY = this.template.branch.spacingY; this.size = 0; @@ -650,8 +668,8 @@

Source: gitgraph.js

options.showLabel = (isPathBeginning && this.showLabel) ? true : false; if ( options.showLabel ) { - options.x -= this.template.commit.spacingX; - options.y -= this.template.commit.spacingY; + options.x -= this.template.commit.spacingX; + options.y -= this.template.commit.spacingY; } var commit = new Commit( options ); @@ -795,7 +813,7 @@

Source: gitgraph.js

this.column = 0; for ( ; ; this.column++ ) { if ( !( this.column in candidates ) || candidates[ this.column ] === 0 ) { - break; + break; } } }; @@ -889,7 +907,7 @@

Source: gitgraph.js

// Label if ( this.showLabel ) { - drawTextBG( this.context, this.x + this.template.commit.spacingX, this.y + this.template.commit.spacingY, this.branch.name, "black", this.labelColor, this.labelFont, this.template.branch.labelRotation); + drawTextBG( this.context, this.x + this.template.commit.spacingX, this.y + this.template.commit.spacingY, this.branch.name, "black", this.labelColor, this.labelFont, this.template.branch.labelRotation ); } // Dot @@ -917,17 +935,17 @@

Source: gitgraph.js

var tagWidth = this.template.commit.tag.spacingX; if ( this.tag !== null ) { this.parent.tagNum++; - var textWidth = this.context.measureText(this.tag).width; + var textWidth = this.context.measureText( this.tag ).width; if ( this.template.branch.labelRotation !== 0 ) { - var textHeight = getFontHeight(this.tagFont); + var textHeight = getFontHeight( this.tagFont ); drawTextBG( this.context, - this.x - this.dotSize/2, - ((this.parent.columnMax + 1) * this.template.commit.tag.spacingY) - this.template.commit.tag.spacingY/2 + (this.parent.tagNum % 2) * textHeight * 1.5, + this.x - this.dotSize / 2, + ((this.parent.columnMax + 1) * this.template.commit.tag.spacingY) - this.template.commit.tag.spacingY / 2 + (this.parent.tagNum % 2) * textHeight * 1.5, this.tag, "black", this.tagColor, this.tagFont, 0 ); } else { drawTextBG( this.context, - ((this.parent.columnMax + 1) * this.template.commit.tag.spacingX) - this.template.commit.tag.spacingX/2 + textWidth/2, - this.y - this.dotSize/2, + ((this.parent.columnMax + 1) * this.template.commit.tag.spacingX) - this.template.commit.tag.spacingX / 2 + textWidth / 2, + this.y - this.dotSize / 2, this.tag, "black", this.tagColor, this.tagFont, 0 ); } tagWidth = (tagWidth < textWidth) ? textWidth : tagWidth; @@ -956,7 +974,7 @@

Source: gitgraph.js

} this.context.fillStyle = this.messageColor; - this.context.fillText( message, commitOffsetLeft, this.y + this.dotSize / 2); + this.context.fillText( message, commitOffsetLeft, this.y + this.dotSize / 2 ); } }; @@ -1189,14 +1207,14 @@

Source: gitgraph.js

// -------------------------------------------------------------------- var getFontHeight = function ( font ) { - var body = document.getElementsByTagName("body")[0]; - var dummy = document.createElement("div"); - var dummyText = document.createTextNode("Mg"); - dummy.appendChild(dummyText); - dummy.setAttribute("style", "font: " + font + ";"); - body.appendChild(dummy); + var body = document.getElementsByTagName( "body" )[ 0 ]; + var dummy = document.createElement( "div" ); + var dummyText = document.createTextNode( "Mg" ); + dummy.appendChild( dummyText ); + dummy.setAttribute( "style", "font: " + font + ";" ); + body.appendChild( dummy ); var result = dummy.offsetHeight; - body.removeChild(dummy); + body.removeChild( dummy ); return result; }; @@ -1206,16 +1224,16 @@

Source: gitgraph.js

function drawTextBG ( context, x, y, text, fgcolor, bgcolor, font, angle ) { context.save(); - context.translate(x, y); - context.rotate(angle*(Math.PI/180)); + context.translate( x, y ); + context.rotate( angle * (Math.PI / 180) ); context.textAlign = "center"; context.font = font; - var width = context.measureText(text).width; - var height = getFontHeight(font); + var width = context.measureText( text ).width; + var height = getFontHeight( font ); context.beginPath(); - context.rect(-(width/2)-4, -(height/2)+2, width+8, height+2); + context.rect( -(width / 2) - 4, -(height / 2) + 2, width + 8, height + 2 ); context.fillStyle = bgcolor; context.fill(); context.lineWidth = 2; @@ -1223,7 +1241,7 @@

Source: gitgraph.js

context.stroke(); context.fillStyle = fgcolor; - context.fillText(text, 0, height/2); + context.fillText( text, 0, height / 2 ); context.restore(); } @@ -1243,13 +1261,13 @@

Source: gitgraph.js


- Documentation generated by JSDoc 3.2.2 on Sat Jan 23 2016 19:40:18 GMT+0100 (CET) + Documentation generated by JSDoc 3.2.2 on Thu Feb 04 2016 11:54:00 GMT+0100 (CET)
diff --git a/docs/global.html b/docs/global.html index 1be01734..e577c9e2 100644 --- a/docs/global.html +++ b/docs/global.html @@ -270,7 +270,7 @@
Parameters:
Source:
@@ -293,6 +293,142 @@
Parameters:
+ + + + +
+

<private> _getScale(context) → {Number}

+ + +
+
+ + +
+

Returns the scaling factor of given canvas context. +Handles high-resolution displays.

+
+ + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
context + + +Object + + + +
+ + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + +
+
+ Type +
+
+ +Number + + +
+
+ + + +
@@ -416,7 +552,7 @@
Parameters:
Source:
@@ -455,13 +591,13 @@
Parameters:

- Documentation generated by JSDoc 3.2.2 on Sat Jan 23 2016 19:40:19 GMT+0100 (CET) + Documentation generated by JSDoc 3.2.2 on Thu Feb 04 2016 11:54:00 GMT+0100 (CET)
diff --git a/docs/index.html b/docs/index.html index 0d550675..1e34ffba 100644 --- a/docs/index.html +++ b/docs/index.html @@ -108,13 +108,13 @@

Copyright and License


- Documentation generated by JSDoc 3.2.2 on Sat Jan 23 2016 19:40:19 GMT+0100 (CET) + Documentation generated by JSDoc 3.2.2 on Thu Feb 04 2016 11:54:00 GMT+0100 (CET)
diff --git a/package.json b/package.json index 60854f79..73a4bf14 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "gitgraph.js", - "version": "1.1.2", + "version": "1.1.3", "author": "Nicolas Carlo ", "description": "A JavaScript library to draw pretty git graphs in the browser", "contributors": [