Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(16)

Side by Side Diff: bower_components/core-splitter/core-splitter.html

Issue 786953007: npm_modules: Fork bower_components into Polymer 0.4.0 and 0.5.0 versions (Closed) Base URL: https://chromium.googlesource.com/infra/third_party/npm_modules.git@master
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 <!--
2 Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
3 This code may only be used under the BSD style license found at http://polymer.g ithub.io/LICENSE.txt
4 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
5 The complete set of contributors may be found at http://polymer.github.io/CONTRI BUTORS.txt
6 Code distributed by Google as part of the polymer project is also
7 subject to an additional IP rights grant found at http://polymer.github.io/PATEN TS.txt
8 -->
9
10 <!--
11 `core-splitter` provides a split bar and dragging on the split bar
12 will resize the sibling element. Use its `direction` property to indicate
13 which sibling element to be resized and the orientation. Usually you would want
14 to use `core-splitter` along with flex layout so that the other sibling
15 element can be _flexible_.
16
17 Example:
18
19 <div horizontal layout>
20 <div>left</div>
21 <core-splitter direction="left"></core-splitter>
22 <div flex>right</div>
23 </div>
24
25 In the above example, dragging the splitter will resize the _left_ element. And
26 since the parent container is a flexbox and the _right_ element has
27 `flex`, the _right_ element will be auto-resized.
28
29 For horizontal splitter set `direction` to `up` or `down`.
30
31 Example:
32
33 <div vertical layout>
34 <div>top</div>
35 <core-splitter direction="up"></core-splitter>
36 <div flex>bottom</div>
37 </div>
38
39 @group Polymer Core Elements
40 @element core-splitter
41 @homepage github.io
42 -->
43
44 <link rel="import" href="../polymer/polymer.html">
45
46 <polymer-element name="core-splitter" attributes="direction locked minSize allow Overflow"
47 on-trackstart="{{trackStart}}" on-track="{{track}}" on-down="{{preventSelect ion}}">
48
49 <template>
50
51 <link rel="stylesheet" href="core-splitter.css">
52
53 </template>
54 <script>
55
56 Polymer('core-splitter', {
57
58 /**
59 * Possible values are `left`, `right`, `up` and `down`.
60 *
61 * @attribute direction
62 * @type string
63 * @default 'left'
64 */
65 direction: 'left',
66
67 /**
68 * Minimum width to which the splitter target can be sized, e.g.
69 * `minSize="100px"`
70 *
71 * @attribute minSize
72 * @type string
73 * @default ''
74 */
75 minSize: '',
76
77 /**
78 * Locks the split bar so it can't be dragged.
79 *
80 * @attribute locked
81 * @type boolean
82 * @default false
83 */
84 locked: false,
85
86 /**
87 * By default the parent and siblings of the splitter are set to overflow hi dden. This helps
88 * avoid elements bleeding outside the splitter regions. Set this property t o true to allow
89 * these elements to overflow.
90 *
91 * @attribute allowOverflow
92 * @type boolean
93 * @default false
94 */
95 allowOverflow: false,
96
97 ready: function() {
98 this.directionChanged();
99 },
100
101 domReady: function() {
102 if (!this.allowOverflow) {
103 this.parentNode.style.overflow = this.nextElementSibling.style.overflow =
104 this.previousElementSibling.style.overflow = 'hidden';
105 }
106 },
107
108 directionChanged: function() {
109 this.isNext = this.direction === 'right' || this.direction === 'down';
110 this.horizontal = this.direction === 'up' || this.direction === 'down';
111 this.update();
112 },
113
114 update: function() {
115 this.target = this.isNext ? this.nextElementSibling : this.previousElement Sibling;
116 this.dimension = this.horizontal ? 'height' : 'width';
117 this.classList.toggle('horizontal', this.horizontal);
118 },
119
120 targetChanged: function(old) {
121 if (old) {
122 old.style[old.__splitterMinSize] = '';
123 }
124 var min = this.target.__splitterMinSize = this.horizontal ? 'minHeight' : 'minWidth';
125 this.target.style[min] = this.minSize;
126 },
127
128 trackStart: function() {
129 this.update();
130 this.size = parseInt(getComputedStyle(this.target)[this.dimension]);
131 },
132
133 track: function(e) {
134 if (this.locked) {
135 return;
136 }
137 var d = e[this.horizontal ? 'dy' : 'dx'];
138 this.target.style[this.dimension] =
139 this.size + (this.isNext ? -d : d) + 'px';
140 },
141
142 preventSelection: function(e) {
143 e.preventDefault();
144 }
145 });
146
147 </script>
148 </polymer-element>
OLDNEW
« no previous file with comments | « bower_components/core-splitter/core-splitter.css ('k') | bower_components/core-splitter/demo.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698