Giter Club home page Giter Club logo

angular2-draggable's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

angular2-draggable's Issues

Snap to grid ? Resizeable ?

Hi ,
is it possible to have teh same featuites as jQuery draggable, please ? such as:

  • snap to grid
  • resizeable

?

feat(relativity): add option to translate in vw in vh

I would like the option to instead of translating using pixels, translate relative to the view, so it will be in vw and vh for x and y respectively, and will not change position relatively when window resize happens.

Initialise in the component?

How do I initialise in the component.
For example:
const video = document.createElement('video'); body.appendChild(video);

How do I add the directive to this video tag? I want to make it draggable.

z-index gets set to "auto" after dragging ends

Your directive is great, however in my use case I have layers of components that need to keep their z-index values. Using your directive, after dragging an element, its z-index is set to auto. I believe this behavior is coming from this line.

I'm not sure if this is intended behavior, but my request is to be able to keep a component's "old" z-index without having to call window. getComputedStyle.

Custom z-index

Some draggable windows should be underneath other objects such as modals. Forcing a z-index of 99999 doesn't allow this.

Focus

Hello.
First of all - This is great !! Thanks a lot.
I have a problem though : When i drag a div to be in front of another Div , i CAN NOT bring the "beckend" div to be in the front whrn i click on it.
Is it can be changed ?

Yan.

Bad positioning when multiple draggable elements in one container

If there are multiple draggable elements in the container only the first one is positioned correctly. The second ones y coordinate is not relative to the container.

public position1 = {x: 10, y: 10};
public position2 = {x: 150, y: 10};
<div class='drag-container' #myBounds>
    <div class='drag-item1' [position]="position1" [bounds]='myBounds' [inBounds]="inBounds" ngDraggable>Drag me! (1)</div>
    <div class='drag-item2' [position]="position2" [bounds]='myBounds' [inBounds]="inBounds" ngDraggable>Drag me! (2)</div>
</div>

screenshot_20180508_091103

Dragging lags and gets stuck

If a user moves a div fast enough that the cursor hovers over a button or link it will break the drag until the div is clicked to reset.

Suggestion: Multitouch

How to reproduce: Instance to divs, try to move each one with one finger.
They seal each others pointer event.

dragging is not working for ng-template

Hi
I'm using NgbModal in Angular4 application. for that modal popup drag and drop, we are using angular2-draggable. it is working fine for simple "div" and it is not working as expected with ng-template

here is my sample code
<ng-template #divBranching let-c="close" let-d="dismiss"> <div ngDraggable [handle]="divDraggable" class="card" style="resize: both; overflow:hidden"> <div #divDraggable class="card-header"> <h3>Draggable Content</h3> </div> </div> </ng-template>
angular2-draggable issue
parent items is displaying in the same position. if i apply ngDraggable and [handle] to the ng-template we are unable to drag it. please help to fix this issue

Initial position?

Is there an option to position the element in a starting position? I've tried giving it translate(posX,posY) but it just ignores it and start dragging from 0,0.

Setter for X,Y

Hello,
This is a nice directive.
I would like to have an opportunity to set initial value (or may be change) of a oldPosition property. I am not sure, but this property has values that I want to change.

I want to create a board with text cards, where each card has properties text: string, x,y:number.
I have created a card component and use this directive to change and track its position. I have find how to create dynamically multiple cards. What i miss is to position cards at their initial position on page load after a page reload. I have create save procedure, it saves cards text and coordinates.

Ability to reset position

Hi. I'm using this beautiful directive with ngx-bootstrap modals.
The issue is that if you open the modal (which opens at its default kind of centered position), drag it, close and open again it opens at the last dragged position not at default. Would be nice to be able to reset drag position so modals always open at their default.

Browser compability?

What browsers is this library compatible with?

(Also, the demo site doesn't load at all with IE 11.)

this.bounds is undefined by default

Hi,
I see this.bounds = undefined by default. I have added below code to fix it. Can you recommend that is there any alternative.

private boundsCheck() { if (this.bounds == undefined || this.bounds == null) { this.bounds = this.el.nativeElement.parentElement; } let boundary = this.bounds.getBoundingClientRect(); let elem = this.el.nativeElement.getBoundingClientRect() return { 'top': boundary.top < elem.top, 'right': boundary.right > elem.right, 'bottom': boundary.bottom > elem.bottom, 'left': boundary.left < elem.left }; }

thank you

Regarding z-index

Thanks for the wonderful work. I really enjoyed reading your code.

I'm wondering whether it is possible to introduce a new input parameter for the z-index. Now when the drag stopped, the z-index is reset to its original value. To make it more intuitive in a desktop windows like environment, I'm hoping when the dragging is stopped, the most current dragged window would be on top of other windows. So in this case, users of the directive could keep a record of z-index somewhere else, and this count will be increased by 1 and be assigned to the most recent dragged window's z-index value.

Preventdefaultevent issue?

I'm using dialogs from ngx-boostrap package and make them draggable. Since version 1.1.0 I can't switch between input fields inside a dialog using mouse. Only tab key works. Reverting back to 1.1.0-beta.0 fixes the issue. Just wondering what could be the problem here?

Handle should extend to handle+child elements

The handle should really include any sub-elements of itself, so if I have a div with spans or other divs inside, those should also be part of the handle (except probably buttons).

I think this should make it behave in this way:

    // Support Mouse Events:
    @HostListener('mousedown', ['$event'])
    onMouseDown(event: any) {
        // 1. skip right click;
        // 2. if handle is set, the element can only be moved by handle (or the handle's non-button children)

        if (event.button == 2) {
            return;
        } else if (this.handle !== undefined && !this.checkChildren(event.target, this.handle)) {
            return;
        }

        this.orignal = this.getPosition(event.clientX, event.clientY);
        this.pickUp();
    }

    checkChildren(target: HTMLElement, element) {
        // Checks if the target is the element clicked, then checks each child element of element as well
        // Ignores button clicks

        // Ignore elements of type button
        if (element.tagName == 'BUTTON') return false;

        // If the target was found, return true (handle was found)
        if (element == target) return true;

        // Recursively iterate this elements children
        for (var child in element.children) {
            if (element.children.hasOwnProperty(child)) {
                if (this.checkChildren(target, element.children[child])) return true;
            }
        }

        // Handle was not found in this lineage
        // Note: return false is ignore unless it is the parent element
        return false;
    }

Limit the drag zone

Could be possible if we can limit the drag zone by a parent div or by pixels?
For example: I want to limit zone of the draggable to the #oMap

<o-map #oMap zoom="11" min-zoom="3" max-zoom="20" zoom-control="yes" search-control="yes" draw-control="no" layer-panel-visible="false" base-layer-ids="OpenStreetMap">    
</o-map>

<div ngDraggable>
drageMe
</div>

Thanks.

Problems when scale transform applied to parent

This is my first ever issue-report. Sorry if it is not appropriate for whatever reason.

As far as I can tell, If any ancestor of the div you are trying to drag has a CSS scale transform, things don't work very well (at least on Chrome on Mac - have not tested elsewhere).

It is kind of hard to describe the exact symptoms - there are different problems depending on if you scale up or scale down both for simple dragging and for bounds-checking.

These problems are easy to replicate using dev tools on your demo and editing CSS to include (say) transform: scale(.75) or (say) transform: scale(1.5).

Thanks for ngDraggable!

Updating npm

Hi,

Would you be able to update the npm version to 1.1.0 (rather that 1.1.0-beta.0). I'd like to use the new trackPosition input in a project. I've been testing with the github version but it would be great to have it on npm.

Thanks,
David

Unable to get the started and stopped events to work.

My code is as follows:

HTML
"<div ngDraggable class="col col-lg-4 col-md-4 col-sm-4 visuaItem" *ngFor="let chartItem of availableCharts; let i = index;" [ngClass]="{'showItem': chartItem.isAvailable == true}" (mousedown)="onEvent($event)" (started)="onDragBegin($event)">"

JS

onDragBegin(event){
alert("HI");
}

onEvent(event) {
event.stopPropagation();
this.flag=true;
}

Could you please tell me where I am going wrong? Any help would be highly appreciated.

Need fix X and Y positions

If I wanna set minimal and maximal values of translate positions.... i can't did it.
Please set that callback on dragging and dragEnd events

[MOBILE] Brokes elements click responce and page scroll.

On mobile, one draggable element with the

[ngDraggable] = false

seems to broke the page scroll, that eventually works using the double tap gesture, making a small scroll,
plus the clickable element inside the scrollable one don't get the click event, even if triggering css events, i wonder if this is related to the in line Z-index applied by the directive even if set to false.
removing the directive all returned to work.

tested on iOS safari

Clicking before dragging offsets the whole div

If you click on the draggable div without dragging, then you click again and drag the div, it will instantly move off from its visible position in an apparently random direction. The more clicks before dragging, the more off the div will be when you drag it.

This behavior can be reproduced on the demo page with latest Chrome or Edge

Initial Position

Is there any way to set the initial position of the draggable element?

Not able to drag to left or right if I use bounds

Hi,

I followed the instructions you gave in the demo but I am not able to drag my element to left or right. Only top and bottom movement works. Also, if I set inBounds = false, it works as expected. Please let me know where I might be making a mistake. Thanks

Provide Text inside the draggable content.

Hello, Thanks for the API which is helping me a lot. I'm just wondering how to provide a textarea and input box inside a div and be able to type in the text. Currently, which is not possible even if I place an input type text then I'm not able to enter any text. is there a solution to it?

Thanks.

Draghandler don´t work

The Draghandler don´t work. I can move the by clicking on the whole window.
Here is my code:

<div ngDraggable [handle]="DragHandle" class="window" >
  <div #DragHandle class="header blue" *ngIf="title">
      <h3>{{ title }}</h3>
  </div>
  <div>
    <ul>
        <ng-content></ng-content>
    </ul>
  </div>
</div>

No errors in browser-console or at ng build.
It´s angular cli 1.7.0 without any other packages

Here is the output code:
https://i.imgur.com/UCZqehl.png

Only appears to work in Chrome

In Chrome 58 / 59, this module works as expected.

In other browsers, I am getting variants of the same error:

  • Safari 10:

Can't find variable TouchEvent

  • Firefox 53 / 54:

TouchEvent is not defined

Removing references to angular2-draggable in my project caused these errors to disappear.
Any idea what's going on here? Have I perhaps done something wrong in the setup?

Problem when create draggable components dynamically

Hi,
When I create a draggable component with the ComponentFactoryResolver in a ViewContainerRef, I have a problem with the events of the ngDraggable directive. The console tells me this.bounds.getBoundingClientRect is not a function. So, how can I fix it ?

PS: Sorry for my bad English

Mobile scrolling block

I stumbled upon this error when testing a website using this lib. All scrolling events are disabled
I believe the root cause of this is here:
@HostListener('document:touchmove', ['$event']) onTouchMove(event: any) { event.stopPropagation(); event.preventDefault(); if (this.moving && this.allowDrag) { this.moveTo(event.changedTouches[0].clientX, event.changedTouches[0].clientY); } }
Also worth noting, the use of Renderer is deprecated in favour of Renderer2

how to configure angular2-draggable with systemJS

Hi, I have tried to configure angular2-draggable in my application's system.config.js without success. The config file has lines like following,

map {
...
'angular2-draggable': 'npm:angular2-draggable',
...
},
packages {
...
'angular2-draggable': {
main: 'index.js',
format: 'cjs',
defaultExtension: 'js'
}
...
}

Can you please advise?

Thanks!

在设置handle后,不能正确的选中文字

当preventDefaultEvent 为 true时,可以很好的解决拖动时文本被选中的情况,但是在设置了handle后,这就会出现问题。
所有的event在开始时就会执行
event.stopPropagation();
event.preventDefault();
但是这个event的范围太大了,某些情况下,我只希望在拖动handle时关闭文本选中,而点击其他位置,可以进行文本选中。
由于现在防止事件传递的代码执行在判断是否点击的是handle之前,这就会导致在preventDefaultEvent 为 true时,整个element的文本选中功能相当于被禁止了。
是否可以解决这个问题?

Allow an element to get out of bound

Hi,

Actual :
We use angular2-draggable with ng-bootstrap modal module.
We fix bound to be sure that the modal don't go out of the viewport.

Needed:
We need to be able to allow the modal to go out of the bottom edge.
Cause some of our modal are huge and we need to push it to the bottom to see what's behind (like Windows/Linux/Mac OS)

I will make you a pull request to show what I have in mind.

Great work, by the way.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.