Comparing version 0.2.1 to 1.0.0
1.0.0 / 2019-02-09 | ||
================== | ||
* improve graph for hi/res devices | ||
0.2.1 / 2019-02-07 | ||
@@ -3,0 +8,0 @@ ================== |
@@ -27,3 +27,3 @@ const findSegment = require('./find-segment'); | ||
function initMatrix({ w, h }, { x, y, min }) { | ||
function initMatrix({ w, h }, { x, y, min }, dpr) { | ||
const horizontalPadding = 0; | ||
@@ -39,2 +39,3 @@ const verticalPadding = 15; | ||
return matrix2d() | ||
.scale(dpr, dpr) | ||
.translate(horizontalPadding, verticalPadding) | ||
@@ -86,6 +87,6 @@ .scale(horizontalScaling, -verticalScaling) | ||
function clear(ctx, { w, h }) { | ||
function clear(ctx, { w, h }, dpr) { | ||
ctx.save(); | ||
ctx.setTransform(1, 0, 0, 1, 0, 0); | ||
ctx.clearRect(0, 0, w, h); | ||
ctx.clearRect(0, 0, w * dpr, h * dpr); | ||
ctx.restore(); | ||
@@ -96,3 +97,3 @@ } | ||
function canvas(wrapper, w, h) { | ||
function canvas(wrapper, w, h, dpr) { | ||
const c = document.createElement('canvas'); | ||
@@ -104,4 +105,4 @@ c.style.position = 'absolute'; | ||
c.style.height = '100%'; | ||
c.width = w; | ||
c.height = h; | ||
c.width = w * dpr; | ||
c.height = h * dpr; | ||
wrapper.appendChild(c); | ||
@@ -119,5 +120,7 @@ return c; | ||
const { clientWidth: w, clientHeight: h } = wrapper; | ||
const bg = canvas(wrapper, w, h); | ||
const fg = canvas(wrapper, w, h); | ||
const dpr = window.devicePixelRatio || 1; | ||
const bg = canvas(wrapper, w, h, dpr); | ||
const fg = canvas(wrapper, w, h, dpr); | ||
if (!label) { | ||
@@ -129,3 +132,3 @@ label = document.createElement('div'); | ||
return { bg, fg, label, w, h, }; | ||
return { bg, fg, label, w, h, dpr }; | ||
} | ||
@@ -154,3 +157,3 @@ | ||
const { bg, fg, label, w, h } = create(parent, opts.label); | ||
const { bg, fg, label, w, h, dpr } = create(parent, opts.label); | ||
@@ -161,3 +164,3 @@ const ctx = bg.getContext('2d'); | ||
const transformMatric = initMatrix({ w, h }, extent); | ||
const transformMatric = initMatrix({ w, h }, extent, dpr); | ||
const invertedMatrix = transformMatric.clone().invert(); | ||
@@ -206,4 +209,4 @@ transformMatric.apply(ctx); | ||
let index = itemIndexFromPoint([ | ||
clientX - rect.left, | ||
clientY - rect.top | ||
dpr * (clientX - rect.left), | ||
dpr * (clientY - rect.top) | ||
]); | ||
@@ -215,3 +218,3 @@ select(index); | ||
label.hidden = true; | ||
clear(fgCtx, { w, h }); | ||
clear(fgCtx, { w, h }, dpr); | ||
} | ||
@@ -243,3 +246,3 @@ | ||
animationFrame = undefined; | ||
clear(fgCtx, { w, h }); | ||
clear(fgCtx, { w, h }, dpr); | ||
drawSelected(fgCtx, items[selectedIndex - 1], items[selectedIndex], ref); | ||
@@ -246,0 +249,0 @@ displayLabel(items[selectedIndex]); |
{ | ||
"name": "altpro", | ||
"version": "0.2.1", | ||
"version": "1.0.0", | ||
"description": "Elevation profile widget.", | ||
@@ -5,0 +5,0 @@ "author": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
12117
330
1