Skip to content

Commit 3559a4e

Browse files
author
hb9cwp
committed
update component from Polymer 0.5 to 1.x
1 parent 5131776 commit 3559a4e

File tree

3 files changed

+50
-49
lines changed

3 files changed

+50
-49
lines changed

demo.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes">
55
<title>Si2 Web Components</title>
66

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

1010
</head>
@@ -14,6 +14,6 @@
1414
<p>An example of using <code>&lt;flightpanel-speed&gt;</code>:</p>
1515

1616
<flightpanel-speed id="si2speed" width=200 height=200 speed=32></flightpanel-speed>
17-
17+
1818
</body>
1919
</html>

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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<head>
55
<title>flightpanel-speed Info</title>
66

7-
<script src="../webcomponentsjs/webcomponents.js"></script>
7+
<script src="../webcomponentsjs/webcomponents-lite.js"></script>
88

99
<link rel="import" href="../polymer/polymer.html">
1010
<link rel="import" href="../core-component-page/core-component-page.html">

0 commit comments

Comments
 (0)