Allow attribute-level disabling of click-drag functionality

This commit is contained in:
Patrick Coffey 2017-08-15 16:44:25 -05:00
parent 9e49826865
commit 95f875e8ba
No known key found for this signature in database
GPG key ID: 870BDD7A667DB73B
2 changed files with 6 additions and 1 deletions

View file

@ -9,7 +9,7 @@
<a-sphere click-drag position="0 1.25 -1" radius="1.25" color="#EF2D5E"></a-sphere>
<a-box click-drag position="-1 0.5 1" rotation="0 45 0" width="1" height="1" depth="1" color="#4CC3D9"></a-box>
<a-cylinder click-drag position="1 0.75 1" radius="0.5" height="1.5" color="#FFC65D"></a-cylinder>
<a-plane rotation="-90 0 0" width="4" height="4" color="#7BC8A4"></a-plane>
<a-plane click-drag="enabled: false" rotation="-90 0 0" width="4" height="4" color="#7BC8A4"></a-plane>
<a-sky color="#ECECEC"></a-sky>

View file

@ -456,6 +456,11 @@ const {didMount, didUnmount} = (function getDidMountAndUnmount() {
const {depth, offset, element} = selectItem(THREE, componentName, camera, clientX, clientY);
if (element) {
// If click-drag is not enabled, return.
if (element.getAttribute('click-drag').enabled === 'false') {
return;
}
// Can only drag one item at a time, so no need to check if any
// listener is already set up
let removeDragItemListeners = dragItem(