This repository has been archived by the owner on Mar 13, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
polymer-ui-nav-arrow.html
77 lines (76 loc) · 2.08 KB
/
polymer-ui-nav-arrow.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<!--
Copyright 2013 The Polymer Authors. All rights reserved.
Use of this source code is governed by a BSD-style
license that can be found in the LICENSE file.
-->
<!--
/**
* @module Polymer UI Elements
*/
/**
* polymer-ui-nav-arrow is a polymer-ui-arrow that can be positioned to the
* right of the target node. This element is used in
* <a href="polymer-ui-sidebar-menu.html">polymer-ui-sidebar-menu</a>.
*
* Example:
*
* <polymer-selector selectedItem="{{item}}">
* <div>Item 1</div>
* <div>Item 2</div>
* <div>Item 3</div>
* <div>Item 4</div>
* <div>Item 5</div>
* </polymer-selector>
* <polymer-ui-nav-arrow target="{{item}}"></polymer-ui-nav-arrow>
*
* @class polymer-ui-nav-arrow
* @extends polymer-ui-arrow
*/
/**
* The target element.
*
* @attribute target
* @type object
* @default null
*/
-->
<link rel="import" href="../polymer/polymer.html">
<link rel="import" href="../polymer-ui-arrow/polymer-ui-arrow.html">
<polymer-element name="polymer-ui-nav-arrow" extends="polymer-ui-arrow" attributes="target">
<template>
<link rel="stylesheet" href="polymer-ui-nav-arrow.css">
<shadow></shadow>
</template>
<script>
Polymer('polymer-ui-nav-arrow', {
direction: 'left',
size: 9,
borderColor: '#000',
show: false,
enteredView: function() {
this.showChanged();
},
showChanged: function() {
this.classList.toggle('hidden', !this.show);
},
targetChanged: function() {
this.show = !!this.target;
if (this.target) {
this.asyncMethod('move');
}
},
translateY: function(y) {
var s = this.style;
s.webkitTransform = s.mozTransform = s.msTransform = s.transform =
'translate3d(0,' + y + 'px,0)';
},
move: function() {
var t = this.target;
// if the target has getOffsetMiddle(), use that instead
var y = t.getOffsetMiddle ? t.getOffsetMiddle() :
(t.offsetTop + t.offsetHeight/2);
this.translateY(y);
}
});
</script>
</polymer-element>