Skip to content
This repository has been archived by the owner on Dec 29, 2022. It is now read-only.

Commit

Permalink
Make dragging function with polymer-gestures.
Browse files Browse the repository at this point in the history
  • Loading branch information
sorvell committed Apr 21, 2014
1 parent d0a65cc commit e413a57
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
13 changes: 9 additions & 4 deletions elements/x-designable/x-designable.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<link rel="import" href="../../components/polymer/polymer.html">
<link rel="import" href="../x-design-host/x-design-host.html">

<polymer-element name="x-designable" designer attributes="selected" on-keydown="{{keydown}}" on-pointerdown="{{pointerDown}}" on-pointerup="{{pointerUp}}" on-trackstart="{{trackStart}}" on-track="{{track}}" on-trackend="{{trackEnd}}">
<polymer-element name="x-designable" designer attributes="selected" on-keydown="{{keydown}}" on-down="{{down}}" on-up="{{up}}" on-trackstart="{{trackStart}}" on-track="{{track}}" on-trackend="{{trackEnd}}">

<template>

Expand Down Expand Up @@ -147,11 +147,15 @@
rule.style.left = p.x + 'px';
rule.style.top = p.y + 'px';
};
var self = this;
dragInfo.up = function(e) {
self.up(e);
}
},

drop: function(element, event) {
this.style.overflow = 'hidden';
var container = this.findContainer(element, event.target);
var container = this.findContainer(element, event.relatedTarget);
if (container && this.canContain(container, element)) {
// don't manipulate parentNode if not necessary
var sameParent = (container === element.parentNode);
Expand Down Expand Up @@ -253,11 +257,11 @@
}
},

pointerDown: function(e) {
down: function(e) {
//this.dragDisabled = e.altKey;
},

pointerUp: function(e) {
up: function(e) {
if (this.dragInfo && !this.dragInfo.dropped) {
this.dragInfo.dropped = this.drop(this.dragInfo.element, e);
} else {
Expand Down Expand Up @@ -335,6 +339,7 @@
}
container = container.parentNode;
}
return this.designHost;
},

canContain: function(container, element) {
Expand Down
1 change: 1 addition & 0 deletions elements/x-palette/x-palette.html
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
trackEnd: function(event) {
event.stopPropagation();
if (this.drag) {
this.drag.up(event);
if (!this.drag.dropped) {
this.drop(this.drag);
}
Expand Down

0 comments on commit e413a57

Please sign in to comment.