Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doubts - can I change thumb before was generated? #136

Open
heltonalves99 opened this issue May 15, 2018 · 2 comments
Open

Doubts - can I change thumb before was generated? #136

heltonalves99 opened this issue May 15, 2018 · 2 comments
Assignees
Labels

Comments

@heltonalves99
Copy link

Hi guys, how are you ?

I'm trying pass more information in thumb generated by drag, is there any way to do this?

he is a print showing example how Pivotal Traacker works:
screen shot 2018-05-15 at 10 50 51

@ObaidUrRehman
Copy link
Owner

@heltonalves99 I am afraid this is not possible with this component.

@pzero24
Copy link

pzero24 commented Sep 12, 2018

Yes, you can. I am doing it in one of my projects. The secret is to create an element in Javascript, and then use setDragImage() to set it to that element. Here is an example of how this works:

dragStarted(event: DragEvent, item?: Property[]) {
    let wrapper = document.createElement('div');
    wrapper.className = 'drag-transit-wrapper pb-2 pr-2';

    let dragTransitImage = document.createElement('div');
    dragTransitImage.className = 'drag-transit-image p-2';

    let propertyFileElement = document.createElement('span');
    propertyFileElement.className = 'float-left fa fa-file p-1 pr-3';
    dragTransitImage.appendChild(propertyFileElement);

    let propertyCountElement = document.createElement('span');
    propertyCountElement.className = 'property-title ml-2 monospaced';
    if (item !== undefined) {
        propertyCountElement.innerHTML = item.length + ' properties';
    }
    dragTransitImage.appendChild(propertyCountElement);

    wrapper.appendChild(dragTransitImage);
    document.body.appendChild(wrapper);
    event.dataTransfer.setDragImage(wrapper, 0, 0);
}

dragEnded() {
    let elements = document.querySelectorAll('.drag-transit-wrapper');
    for (let index = 0; index < elements.length; index++) {
        document.body.removeChild(elements[index]);
    }
}

Note that the native drag and drop API automatically adds a transparency gradient for elements of a certain size (around 300px on X or Y axes).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants