Skip to content

Commit 1ede654

Browse files
author
Rolf Sommerhalder
committed
Merge pull request #1 from hb9cwp/updatePolymer1.x
Update polymer1.x
2 parents d52973c + 8816abc commit 1ede654

File tree

5 files changed

+66
-81
lines changed

5 files changed

+66
-81
lines changed

Readme.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#flightpanel-speed
22

3-
Re-usable Speed indicator Web Component refactored from
3+
Re-usable Speed indicator Web Component refactored from
44
[flightSimPanels](https://github.com/dmolin/flightSimPanels)
55
as Custom Element in Polymer.
66

7-
`<flightpanel-speed width=200 height=200 speed=25></flightpanel-speed>`
7+
`<flightpanel-speed id="si2speed" width=200 height=200 speed=25></flightpanel-speed>`
88

99
<p align="center">
1010
<img src="speedIndicator.png?raw=true" alt="Speed Indicator 200 x 200 px"/>
@@ -17,9 +17,9 @@ The Custom Element accepts attributes `width`, `height` (in px), and `speed` (in
1717
It watches `speed`, and adjusts the hand as it changes.
1818
See example in [demo.html](demo.html) .
1919

20-
This Custom Element is derived from Polymer's
20+
This Custom Element is derived from Polymer's
2121
[seed-element](https://github.com/PolymerLabs/seed-element)
22-
according to
23-
["Creating reusable elements:
24-
How to publish and deploy reusable Polymer elements on GitHub"]
25-
(http://www.polymer-project.org/docs/start/reusableelements.html) .
22+
according to
23+
["Create a reusable element:
24+
Publish reusable Polymer elements on GitHub"]
25+
https://www.polymer-project.org/1.0/docs/start/reusableelements.html .

bower.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "flightpanel-speed",
3-
"version": "0.1",
3+
"version": "1.0",
44
"authors": [
55
"Rolf Sommerhalder <[email protected]>"
66
],
@@ -22,7 +22,7 @@
2222
"/tests/"
2323
],
2424
"dependencies": {
25-
"polymer": "Polymer/polymer#^0.5.4"
25+
"polymer": "Polymer/polymer#^1.2.0"
2626
},
2727
"devDependencies": {
2828
"web-component-tester": "*"

demo.html

Lines changed: 0 additions & 19 deletions
This file was deleted.

flightpanel-speed.html

Lines changed: 47 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
<link rel="import" href="../polymer/polymer.html">
22

33
<!--
4-
The `flightpanel-speed` element renders an analog Speed indicator.
4+
The `flightpanel-speed` element renders an analog Speed indicator.
55
66
@element flightpanel-speed
77
@status alpha
88
@homepage https://github.com/hb9cwp/flightpanel-speed
99
-->
1010

11-
<polymer-element name="flightpanel-speed" attributes="width height speed">
11+
<dom-module id="flightpanel-speed">
1212

1313
<template>
1414
<link rel="stylesheet" href="flightpanel-speed.css">
@@ -28,66 +28,69 @@
2828
<script>
2929
'use strict';
3030
Polymer({
31-
/**
32-
* Changes `width` of the indicator from its default (in px).
33-
*
34-
* @attribute width
35-
* @type number
36-
* @default 300
37-
*/
38-
width: 300,
39-
40-
/**
41-
* Changes `height` of the indicator from its default (in px).
42-
*
43-
* @attribute height
44-
* @type number
45-
* @default 300
46-
*/
47-
height: 300,
48-
49-
/**
50-
* The hand tracks the `speed` (in kts).
51-
*
52-
* @attribute speed
53-
* @type number
54-
* @default 0
55-
*/
56-
speed: 0,
31+
is: "flightpanel-speed",
32+
properties: {
33+
/**
34+
* Changes `width` of the indicator from its default (in px).
35+
*
36+
* @attribute width
37+
* @type number
38+
* @default 300
39+
*/
40+
width: 300,
41+
42+
/**
43+
* Changes `height` of the indicator from its default (in px).
44+
*
45+
* @attribute height
46+
* @type number
47+
* @default 300
48+
*/
49+
height: 300,
50+
51+
/**
52+
* The hand tracks the `speed` (in kts).
53+
*
54+
* @attribute speed
55+
* @type number
56+
* @default 0
57+
*/
58+
speed: 0,
59+
},
5760

5861
min: 0,
5962
max: 0,
6063
angles: [],
6164

6265
created: function() {
63-
// interpolation etc.
66+
// interpolation etc.
6467
setup(this);
6568
},
66-
69+
6770
ctx1: null,
6871
hand: null,
69-
72+
7073
// on ready, not on created, unlike shown in some examples!
7174
ready: function () {
7275
var that= this
73-
76+
7477
// using label ID
7578
var canvas0 = this.$.canvas0;
7679
var canvas1 = this.$.canvas1;
7780
// or using class
7881
//var canvas= this.shadowRoot.querySelector('.canvasClass')
7982
var ctx0 = canvas0.getContext('2d')
8083
that.ctx1 = canvas1.getContext('2d')
81-
84+
8285
var dial= new Image()
8386
that.hand= new Image()
84-
87+
8588
dial.onload = function(){
8689
ctx0.drawImage(dial,0,0,that.width,that.height); // scale to canvas size
8790
}
8891
//dial.src= "../flightpanel-speed/speedDial.png"
89-
dial.src= "./bower_components/flightpanel-speed/speedDial.png"
90-
92+
dial.src= "./speedDial.png"
93+
9194
that.hand.onload = function() {
9295
/* Variant A: save/restore */
9396
// 0. save context, e.g. offset etc.
@@ -113,9 +116,9 @@
113116
*/
114117
}
115118
//that.hand.src= "../flightpanel-speed/speedHand.png"
116-
that.hand.src= "./bower_components/flightpanel-speed/speedHand.png"
119+
that.hand.src= "./speedHand.png"
117120
},
118-
121+
119122
speedChanged: function () {
120123
var speed = Math.round(this.speed)
121124
if (speed < this.min) {
@@ -139,10 +142,10 @@
139142
this.ctx1.drawImage(this.hand,0,0,this.width,this.height) // scale to canvas size
140143
*/
141144
}
142-
143-
145+
146+
144147
});
145-
148+
146149
function setup(that) {
147150
// from (scale modified for Si2)
148151
// https://github.com/dmolin/flightSimPanels/blob/master/src/services/measures/speed/client/speed.js
@@ -170,11 +173,11 @@
170173
},
171174
zeroAngle = 0,
172175
angles = [];
173-
176+
174177
var keys = Object.keys(interp).sort(function(a, b) {
175178
return parseInt(a, 10) - parseInt(b, 10);
176179
});
177-
180+
178181
var min = parseInt(keys[0], 10),
179182
max = parseInt(keys[keys.length - 1], 10);
180183

@@ -200,7 +203,5 @@
200203
that.angles = angles;
201204
console.log("setup() done!")
202205
}
203-
204206
</script>
205-
206-
</polymer-element>
207+
</dom-module>

index.html

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
1-
<!DOCTYPE html>
2-
1+
<!doctype html>
32
<html>
43
<head>
5-
<title>flightpanel-speed Info</title>
4+
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes">
5+
<title>Si2 Web Components: flightpanel-speed</title>
66

7-
<script src="../webcomponentsjs/webcomponents.js"></script>
7+
<script src="bower_components/webcomponentsjs/webcomponents-lite.min.js"></script>
8+
<link rel="import" href="flightpanel-speed.html">
89

9-
<link rel="import" href="../polymer/polymer.html">
10-
<link rel="import" href="../core-component-page/core-component-page.html">
1110
</head>
1211

1312
<body unresolved>
14-
<core-component-page></core-component-page>
13+
14+
<p>An example of using <code>&lt;flightpanel-speed&gt;</code>:</p>
15+
16+
<flightpanel-speed id="si2speed" width=200 height=200 speed=32></flightpanel-speed>
17+
1518
</body>
1619
</html>

0 commit comments

Comments
 (0)