Socket
Socket
Sign inDemoInstall

altpro

Package Overview
Dependencies
0
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.0.1 to 0.1.0

6

History.md
0.1.0 / 2019-01-30
==================
* add support for `altpro-select` event
* add support for elevation label
0.0.1 / 2019-01-30

@@ -3,0 +9,0 @@ ==================

44

lib/altpro.js

@@ -79,3 +79,3 @@ const matrix2d = require('./matrix2d');

function createCanvas(parent) {
function create(parent) {

@@ -96,2 +96,3 @@ function canvas(wrapper, w, h) {

const wrapper = document.createElement('div');
wrapper.className = 'altpro-wrapper';
wrapper.style.position = 'relative';

@@ -106,3 +107,7 @@ wrapper.style.width = '100%';

return { bg, fg, w, h };
const label = document.createElement('div');
label.className = 'altpro-label';
wrapper.appendChild(label);
return { bg, fg, label, w, h, };
}

@@ -114,3 +119,4 @@

stroke = 'black',
selectedFill = 'orange'
selectedFill = 'orange',
unit = 'm'
} = opts;

@@ -130,3 +136,3 @@ const {

const { bg, fg, w, h } = createCanvas(parent);
const { bg, fg, label, w, h } = create(parent);

@@ -150,2 +156,4 @@ const ctx = bg.getContext('2d');

let selectedIndex = -1; // nothing selected
return {

@@ -172,2 +180,3 @@ select,

function onmouseleave() {
label.hidden = true;
clear(fgCtx, { w, h });

@@ -189,5 +198,32 @@ }

}
if (selectedIndex === index) {
return;
}
clear(fgCtx, { w, h });
drawSelected(fgCtx, items[index - 1], items[index]);
displayLabel(items[index]);
notify(index);
selectedIndex = index;
}
function displayLabel({ elevation }) {
if (unit === 'ft') {
elevation *= 3.28084;
}
elevation = Math.round(elevation);
label.innerText = `${elevation}${unit}`;
label.hidden = false;
}
function notify(index) {
const { distance, elevation } = items[index];
const detail = {
distance,
elevation,
index
};
const selectEvent = new CustomEvent('altpro-select', { detail });
parent.dispatchEvent(selectEvent);
}
}

6

package.json
{
"name": "altpro",
"version": "0.0.1",
"version": "0.1.0",
"description": "Elevation profile widget.",

@@ -17,5 +17,7 @@ "author": {

],
"dependencies": {},
"devDependencies": {
"browserify": "~16",
"canvas": "~2",
"jsdom": "~13",
"jsdom-global": "~3",
"jshint": "~2",

@@ -22,0 +24,0 @@ "mocha": "~5",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc