Skip to content
This repository has been archived by the owner on Mar 13, 2018. It is now read-only.

Commit

Permalink
Use preventDefault in down instead of setting style
Browse files Browse the repository at this point in the history
  • Loading branch information
frankiefu committed Aug 5, 2014
1 parent e7a33e4 commit 5c09737
Showing 1 changed file with 9 additions and 24 deletions.
33 changes: 9 additions & 24 deletions core-splitter.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
-->

<!--
`core-splitter` provides a spilt bar and dragging on the split bar
`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
Expand All @@ -24,7 +24,7 @@
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_ elemnt will be auto-resized.
`flex`, the _right_ element will be auto-resized.
For horizontal splitter set `direction` to "up" or "down".
Expand All @@ -43,7 +43,8 @@

<link rel="import" href="../polymer/polymer.html">

<polymer-element name="core-splitter" attributes="direction locked minSize allowOverflow disableSelection" on-trackstart="{{trackStart}}" on-track="{{track}}" on-trackend={{trackEnd}}>
<polymer-element name="core-splitter" attributes="direction locked minSize allowOverflow"
on-trackstart="{{trackStart}}" on-track="{{track}}" on-down="{{preventSelection}}">

<template>

Expand Down Expand Up @@ -92,15 +93,6 @@
*/
allowOverflow: false,

/**
* Disables the selection of text while the splitter is being moved
*
* @attribute disableSelection
* @type boolean
* @type default false
*/
disableSelection: false,

ready: function() {
this.directionChanged();
},
Expand Down Expand Up @@ -135,10 +127,6 @@
trackStart: function() {
this.update();
this.size = parseInt(getComputedStyle(this.target)[this.dimension]);
if (this.disableSelection) {
var s = this.parentNode.style;
s.webkitUserSelect = s.MozUserSelect = s.msUserSelect = 'none';
}
},

track: function(e) {
Expand All @@ -147,16 +135,13 @@
}
var d = e[this.horizontal ? 'dy' : 'dx'];
this.target.style[this.dimension] =
this.size + (this.isNext ? -d : d) + 'px';
this.size + (this.isNext ? -d : d) + 'px';
},
trackEnd: function (e) {
if (this.disableSelection) {
var s = this.parentNode.style;
s.webkitUserSelect = s.MozUserSelect = s.msUserSelect = '';
}
}

preventSelection: function(e) {
e.preventDefault();
}
});

</script>
</polymer-element>
</polymer-element>

0 comments on commit 5c09737

Please sign in to comment.