| OLD | NEW |
| (Empty) |
| 1 | |
| 2 | |
| 3 Polymer('core-splitter',Polymer.mixin({ | |
| 4 | |
| 5 /** | |
| 6 * Possible values are `left`, `right`, `up` and `down`. | |
| 7 * | |
| 8 * @attribute direction | |
| 9 * @type string | |
| 10 * @default 'left' | |
| 11 */ | |
| 12 direction: 'left', | |
| 13 | |
| 14 /** | |
| 15 * Minimum width to which the splitter target can be sized, e.g. | |
| 16 * `minSize="100px"` | |
| 17 * | |
| 18 * @attribute minSize | |
| 19 * @type string | |
| 20 * @default '' | |
| 21 */ | |
| 22 minSize: '', | |
| 23 | |
| 24 /** | |
| 25 * Locks the split bar so it can't be dragged. | |
| 26 * | |
| 27 * @attribute locked | |
| 28 * @type boolean | |
| 29 * @default false | |
| 30 */ | |
| 31 locked: false, | |
| 32 | |
| 33 /** | |
| 34 * By default the parent and siblings of the splitter are set to overflow hi
dden. This helps | |
| 35 * avoid elements bleeding outside the splitter regions. Set this property t
o true to allow | |
| 36 * these elements to overflow. | |
| 37 * | |
| 38 * @attribute allowOverflow | |
| 39 * @type boolean | |
| 40 * @default false | |
| 41 */ | |
| 42 allowOverflow: false, | |
| 43 | |
| 44 // Listen for resize requests on parent, since splitter is peer to resizable
s | |
| 45 resizerIsPeer: true, | |
| 46 | |
| 47 ready: function() { | |
| 48 this.directionChanged(); | |
| 49 }, | |
| 50 | |
| 51 attached: function() { | |
| 52 this.resizerAttachedHandler(); | |
| 53 }, | |
| 54 | |
| 55 detached: function() { | |
| 56 this.resizerDetachedHandler(); | |
| 57 }, | |
| 58 | |
| 59 domReady: function() { | |
| 60 if (!this.allowOverflow) { | |
| 61 this.parentNode.style.overflow = this.nextElementSibling.style.overflow
= | |
| 62 this.previousElementSibling.style.overflow = 'hidden'; | |
| 63 } | |
| 64 }, | |
| 65 | |
| 66 directionChanged: function() { | |
| 67 this.isNext = this.direction === 'right' || this.direction === 'down'; | |
| 68 this.horizontal = this.direction === 'up' || this.direction === 'down'; | |
| 69 this.update(); | |
| 70 }, | |
| 71 | |
| 72 update: function() { | |
| 73 this.target = this.isNext ? this.nextElementSibling : this.previousElement
Sibling; | |
| 74 this.dimension = this.horizontal ? 'height' : 'width'; | |
| 75 this.classList.toggle('horizontal', this.horizontal); | |
| 76 }, | |
| 77 | |
| 78 targetChanged: function(old) { | |
| 79 if (old) { | |
| 80 old.style[old.__splitterMinSize] = ''; | |
| 81 } | |
| 82 var min = this.target.__splitterMinSize = this.horizontal ? 'minHeight' :
'minWidth'; | |
| 83 this.target.style[min] = this.minSize; | |
| 84 }, | |
| 85 | |
| 86 trackStart: function() { | |
| 87 this.update(); | |
| 88 this.size = parseInt(getComputedStyle(this.target)[this.dimension]); | |
| 89 }, | |
| 90 | |
| 91 track: function(e) { | |
| 92 if (this.locked) { | |
| 93 return; | |
| 94 } | |
| 95 var d = e[this.horizontal ? 'dy' : 'dx']; | |
| 96 this.target.style[this.dimension] = | |
| 97 this.size + (this.isNext ? -d : d) + 'px'; | |
| 98 this.notifyResize(); | |
| 99 }, | |
| 100 | |
| 101 preventSelection: function(e) { | |
| 102 e.preventDefault(); | |
| 103 } | |
| 104 | |
| 105 }, Polymer.CoreResizer)); | |
| 106 | |
| OLD | NEW |