Skip to content

Commit

Permalink
v1.3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
taye committed Nov 30, 2017
1 parent 530bac6 commit 8cdf55f
Show file tree
Hide file tree
Showing 12 changed files with 99 additions and 74 deletions.
2 changes: 1 addition & 1 deletion dist/docs/Interactable.html
Original file line number Diff line number Diff line change
Expand Up @@ -1108,7 +1108,7 @@ <h4 class="name" id="dropzone"><span class="type-signature"></span>dropzone<span

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="src_actions_drop.js.html">src/actions/drop.js</a>, <a href="src_actions_drop.js.html#line320">line 320</a>
<a href="src_actions_drop.js.html">src/actions/drop.js</a>, <a href="src_actions_drop.js.html#line327">line 327</a>
</li></ul></dd>


Expand Down
8 changes: 4 additions & 4 deletions dist/docs/Interaction.html
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ <h4 class="name" id="doMove"><span class="type-signature"></span>doMove<span cla

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="src_Interaction.js.html">src/Interaction.js</a>, <a href="src_Interaction.js.html#line222">line 222</a>
<a href="src_Interaction.js.html">src/Interaction.js</a>, <a href="src_Interaction.js.html#line223">line 223</a>
</li></ul></dd>


Expand Down Expand Up @@ -308,7 +308,7 @@ <h4 class="name" id="end"><span class="type-signature"></span>end<span class="si

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="src_Interaction.js.html">src/Interaction.js</a>, <a href="src_Interaction.js.html#line279">line 279</a>
<a href="src_Interaction.js.html">src/Interaction.js</a>, <a href="src_Interaction.js.html#line280">line 280</a>
</li></ul></dd>


Expand Down Expand Up @@ -476,7 +476,7 @@ <h4 class="name" id="start"><span class="type-signature"></span>start<span class

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="src_Interaction.js.html">src/Interaction.js</a>, <a href="src_Interaction.js.html#line128">line 128</a>
<a href="src_Interaction.js.html">src/Interaction.js</a>, <a href="src_Interaction.js.html#line129">line 129</a>
</li></ul></dd>


Expand Down Expand Up @@ -685,7 +685,7 @@ <h4 class="name" id="stop"><span class="type-signature"></span>stop<span class="

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="src_Interaction.js.html">src/Interaction.js</a>, <a href="src_Interaction.js.html#line301">line 301</a>
<a href="src_Interaction.js.html">src/Interaction.js</a>, <a href="src_Interaction.js.html#line305">line 305</a>
</li></ul></dd>


Expand Down
2 changes: 1 addition & 1 deletion dist/docs/doclets.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/docs/module-interact.html
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ <h4 class="name" id=".dynamicDrop"><span class="type-signature">(static) </span>

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="src_actions_drop.js.html">src/actions/drop.js</a>, <a href="src_actions_drop.js.html#line447">line 447</a>
<a href="src_actions_drop.js.html">src/actions/drop.js</a>, <a href="src_actions_drop.js.html#line454">line 454</a>
</li></ul></dd>


Expand Down
2 changes: 1 addition & 1 deletion dist/docs/src_Interactable.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ <h1 class="page-title">src/Interactable.js</h1>

// Stop related interactions when an Interactable is unset
for (const interaction of scope.interactions || []) {
if (interaction.target === this &amp;&amp; interaction.interacting()) {
if (interaction.target === this &amp;&amp; interaction.interacting() &amp;&amp; !interaction._ending) {
interaction.stop();
}
}
Expand Down
4 changes: 4 additions & 0 deletions dist/docs/src_Interaction.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ <h1 class="page-title">src/Interaction.js</h1>
this.pointerIsDown = false;
this.pointerWasMoved = false;
this._interacting = false;
this._ending = false;

this.pointerType = pointerType;

Expand Down Expand Up @@ -320,6 +321,8 @@ <h1 class="page-title">src/Interaction.js</h1>
* @param {PointerEvent} [event]
*/
end (event) {
this._ending = true;

event = event || this.prevEvent;

if (this.interacting()) {
Expand All @@ -330,6 +333,7 @@ <h1 class="page-title">src/Interaction.js</h1>
}

this.stop();
this._ending = false;
}

currentAction () {
Expand Down
65 changes: 36 additions & 29 deletions dist/docs/src_actions_drop.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,14 @@ <h1 class="page-title">src/actions/drop.js</h1>
interaction.dropEvents = null;

if (!interaction.dynamicDrop) {
setActiveDrops(interaction, interaction.element);
setActiveDrops(interaction.activeDrops, interaction.element);
}

const dragEvent = interaction.prevEvent;
const dropEvents = getDropEvents(interaction, event, dragEvent);

if (dropEvents.activate) {
fireActiveDrops(interaction, dropEvents.activate);
fireActiveDrops(interaction.activeDrops, dropEvents.activate);
}
});

Expand Down Expand Up @@ -110,18 +110,19 @@ <h1 class="page-title">src/actions/drop.js</h1>
});

Interaction.signals.on('stop-drag', function ({ interaction }) {
interaction.activeDrops.dropzones =
interaction.activeDrops.elements =
interaction.activeDrops.rects =
interaction.dropEvents = null;
interaction.activeDrops = {
dropzones: null,
elements: null,
rects: null,
};

interaction.dropEvents = null;
});

function collectDrops (interaction, element) {
function collectDrops (activeDrops, element) {
const drops = [];
const elements = [];

element = element || interaction.element;

// collect all dropzones and their elements which qualify for a drop
for (const current of scope.interactables) {
if (!current.options.drop.enabled) { continue; }
Expand Down Expand Up @@ -155,13 +156,13 @@ <h1 class="page-title">src/actions/drop.js</h1>
};
}

function fireActiveDrops (interaction, event) {
function fireActiveDrops (activeDrops, event) {
let prevElement;

// loop through all active dropzones and trigger event
for (let i = 0; i &lt; interaction.activeDrops.dropzones.length; i++) {
const current = interaction.activeDrops.dropzones[i];
const currentElement = interaction.activeDrops.elements [i];
for (let i = 0; i &lt; activeDrops.dropzones.length; i++) {
const current = activeDrops.dropzones[i];
const currentElement = activeDrops.elements [i];

// prevent trigger of duplicate events on same element
if (currentElement !== prevElement) {
Expand All @@ -176,17 +177,16 @@ <h1 class="page-title">src/actions/drop.js</h1>
// Collect a new set of possible drops and save them in activeDrops.
// setActiveDrops should always be called when a drag has just started or a
// drag event happens while dynamicDrop is true
function setActiveDrops (interaction, dragElement) {
function setActiveDrops (activeDrops, dragElement) {
// get dropzones and their elements that could receive the draggable
const possibleDrops = collectDrops(interaction, dragElement, true);
const possibleDrops = collectDrops(activeDrops, dragElement);

interaction.activeDrops.dropzones = possibleDrops.dropzones;
interaction.activeDrops.elements = possibleDrops.elements;
interaction.activeDrops.rects = [];
activeDrops.dropzones = possibleDrops.dropzones;
activeDrops.elements = possibleDrops.elements;
activeDrops.rects = [];

for (let i = 0; i &lt; interaction.activeDrops.dropzones.length; i++) {
interaction.activeDrops.rects[i] =
interaction.activeDrops.dropzones[i].getRect(interaction.activeDrops.elements[i]);
for (let i = 0; i &lt; activeDrops.dropzones.length; i++) {
activeDrops.rects[i] = activeDrops.dropzones[i].getRect(activeDrops.elements[i]);
}
}

Expand All @@ -195,7 +195,7 @@ <h1 class="page-title">src/actions/drop.js</h1>
const validDrops = [];

if (dynamicDrop) {
setActiveDrops(interaction, dragElement);
setActiveDrops(interaction.activeDrops, dragElement);
}

// collect all dropzones and their elements which qualify for a drop
Expand Down Expand Up @@ -295,16 +295,23 @@ <h1 class="page-title">src/actions/drop.js</h1>
}

function fireDropEvents (interaction, dropEvents) {
if (dropEvents.leave) { interaction.prevDropTarget.fire(dropEvents.leave); }
if (dropEvents.move ) { interaction.dropTarget.fire(dropEvents.move ); }
if (dropEvents.enter) { interaction.dropTarget.fire(dropEvents.enter); }
if (dropEvents.drop ) { interaction.dropTarget.fire(dropEvents.drop ); }
const {
activeDrops,
prevDropTarget,
dropTarget,
dropElement,
} = interaction;

if (dropEvents.leave) { prevDropTarget.fire(dropEvents.leave); }
if (dropEvents.move ) { dropTarget.fire(dropEvents.move ); }
if (dropEvents.enter) { dropTarget.fire(dropEvents.enter); }
if (dropEvents.drop ) { dropTarget.fire(dropEvents.drop ); }
if (dropEvents.deactivate) {
fireActiveDrops(interaction, dropEvents.deactivate);
fireActiveDrops(activeDrops, dropEvents.deactivate);
}

interaction.prevDropTarget = interaction.dropTarget;
interaction.prevDropElement = interaction.dropElement;
interaction.prevDropTarget = dropTarget;
interaction.prevDropElement = dropElement;
}

/**
Expand Down
Loading

0 comments on commit 8cdf55f

Please sign in to comment.