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

Unified Diff: third_party/polymer/components/core-splitter/core-splitter.html

Issue 582873003: Polymer elements added to third_party/polymer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: third_party/polymer/components/core-splitter/core-splitter.html
diff --git a/third_party/polymer/components/core-splitter/core-splitter.html b/third_party/polymer/components/core-splitter/core-splitter.html
new file mode 100644
index 0000000000000000000000000000000000000000..391349c8399803637737a6d0c984df4a0b10d772
--- /dev/null
+++ b/third_party/polymer/components/core-splitter/core-splitter.html
@@ -0,0 +1,147 @@
+<!--
+Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
+This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
+The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
+The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
+Code distributed by Google as part of the polymer project is also
+subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
+-->
+
+<!--
+`core-splitter` provides a split bar and dragging on the split bar
+will resize the sibling element. Use its `direction` property to indicate
+which sibling element to be resized and the orientation. Usually you would want
+to use `core-splitter` along with flex layout so that the other sibling
+element can be _flexible_.
+
+Example:
+
+ <div horizontal layout>
+ <div>left</div>
+ <core-splitter direction="left"></core-splitter>
+ <div flex>right</div>
+ </div>
+
+In the above example, dragging the splitter will resize the _left_ element. And
+since the parent container is a flexbox and the _right_ element has
+`flex`, the _right_ element will be auto-resized.
+
+For horizontal splitter set `direction` to "up" or "down".
+
+Example:
+
+ <div vertical layout>
+ <div>top</div>
+ <core-splitter direction="up"></core-splitter>
+ <div flex>bottom</div>
+ </div>
+
+@group Polymer Core Elements
+@element core-splitter
+@homepage github.io
+-->
+
+<link rel="import" href="../polymer/polymer.html">
+
+<polymer-element name="core-splitter" attributes="direction locked minSize allowOverflow"
+ on-trackstart="{{trackStart}}" on-track="{{track}}" on-down="{{preventSelection}}">
+
+<template>
+
+ <link rel="stylesheet" href="core-splitter.css">
+
+</template>
+<script>
+
+ Polymer('core-splitter', {
+
+ /**
+ * Possible values are "left", "right", "up" and "down".
+ *
+ * @attribute direction
+ * @type string
+ * @default 'left'
+ */
+ direction: 'left',
+
+ /**
+ * Minimum width to which the splitter target can be sized
+ *
+ * @attribute minSize
+ * @type number
+ * @default 0
+ */
+ minSize: 0,
+
+ /**
+ * Locks the split bar so it can't be dragged.
+ *
+ * @attribute locked
+ * @type boolean
+ * @default false
+ */
+ locked: false,
+
+ /**
+ * By default the parent and siblings of the splitter are set to overflow hidden. This helps
+ * avoid elements bleeding outside the splitter regions. Set this property to true to allow
+ * these elements to overflow.
+ *
+ * @attribute allowOverflow
+ * @type boolean
+ * @default false
+ */
+ allowOverflow: false,
+
+ ready: function() {
+ this.directionChanged();
+ },
+
+ domReady: function() {
+ if (!this.allowOverflow) {
+ this.parentNode.style.overflow = this.nextElementSibling.style.overflow =
+ this.previousElementSibling.style.overflow = 'hidden';
+ }
+ },
+
+ directionChanged: function() {
+ this.isNext = this.direction === 'right' || this.direction === 'down';
+ this.horizontal = this.direction === 'up' || this.direction === 'down';
+ this.update();
+ },
+
+ update: function() {
+ this.target = this.isNext ? this.nextElementSibling : this.previousElementSibling;
+ this.dimension = this.horizontal ? 'height' : 'width';
+ this.classList.toggle('horizontal', this.horizontal);
+ },
+
+ targetChanged: function(old) {
+ if (old) {
+ old.style[old.__splitterMinSize] = '';
+ }
+ var min = this.target.__splitterMinSize = this.horizontal ? 'minHeight' : 'minWidth';
+ this.target.style[min] = this.minSize + 'px';
+ },
+
+ trackStart: function() {
+ this.update();
+ this.size = parseInt(getComputedStyle(this.target)[this.dimension]);
+ },
+
+ track: function(e) {
+ if (this.locked) {
+ return;
+ }
+ var d = e[this.horizontal ? 'dy' : 'dx'];
+ this.target.style[this.dimension] =
+ this.size + (this.isNext ? -d : d) + 'px';
+ },
+
+ preventSelection: function(e) {
+ e.preventDefault();
+ }
+ });
+
+</script>
+</polymer-element>
« no previous file with comments | « third_party/polymer/components/core-splitter/core-splitter.css ('k') | third_party/polymer/components/core-splitter/demo.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698