Socket
Socket
Sign inDemoInstall

altpro

Package Overview
Dependencies
1
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.1.0 to 0.1.1

lib/find-segment.js

6

History.md
0.1.1 / 2019-01-31
==================
* use binary search to find segment to select
* move canvas painting to requestAnimationFrame
0.1.0 / 2019-01-30

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

21

lib/altpro.js

@@ -0,1 +1,2 @@

const findSegment = require('./find-segment');
const matrix2d = require('./matrix2d');

@@ -5,2 +6,4 @@

const raf = window.requestAnimationFrame || (fn => fn() || false);
function prepare(data) {

@@ -153,2 +156,3 @@ return data.reduce((r, { elevation, distance }) => {

let selectedIndex = -1; // nothing selected
let animationFrame;

@@ -182,3 +186,3 @@ return {

const [ distance ] = unproject(point);
return items.findIndex(item => distance < item.distance);
return findSegment(items, distance);
}

@@ -197,9 +201,16 @@

}
clear(fgCtx, { w, h });
drawSelected(fgCtx, items[index - 1], items[index]);
displayLabel(items[index]);
notify(index);
selectedIndex = index;
if (!animationFrame) {
animationFrame = raf(refreshSelected);
}
}
function refreshSelected() {
animationFrame = undefined;
clear(fgCtx, { w, h });
drawSelected(fgCtx, items[selectedIndex - 1], items[selectedIndex]);
displayLabel(items[selectedIndex]);
notify(selectedIndex);
}
function displayLabel({ elevation }) {

@@ -206,0 +217,0 @@ if (unit === 'ft') {

{
"name": "altpro",
"version": "0.1.0",
"version": "0.1.1",
"description": "Elevation profile widget.",

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

],
"dependencies": {
"binary-search": "~1"
},
"devDependencies": {

@@ -19,0 +22,0 @@ "browserify": "~16",

@@ -69,4 +69,4 @@ [![NPM version][npm-image]][npm-url]

[travis-url]: https://travis-ci.org/pirxpilot/altpro
[travis-image]: https://img.shields.io/travis/pirxpilot/altpro.svg
[travis-url]: https://travis-ci.com/pirxpilot/altpro
[travis-image]: https://img.shields.io/travis/com/pirxpilot/altpro.svg

@@ -73,0 +73,0 @@ [deps-image]: https://img.shields.io/david/pirxpilot/altpro.svg

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