Git Product home page Git Product logo

angular-dnd's Introduction

Join the chat at https://gitter.im/Tuch/angular-dnd

Angular-DND 0.1.25

Features:

  • Not jQueryUI wrapper
  • Support touch events

Directives:

dnd-draggable [expression]

Provides movement ability to the element. Parameter 'false' disables the directive.

dnd-draggable-opts [object] - directive options:

  • layer[string]: What would droppable elements react to draggable elements, they must be in a single layer. By default, layer = 'common'
  • useAsPoint[boolean]: Droppable area will interact with the item only if the manipulator cursor will be within the droppable element
  • helper[string]: 'clone' or templateUrl - allow to move to use helper, instead of the element
  • handle[string]: Selector of handle element to be used for pulling element

watching attributes:

  • dnd-on-dragstart [function()]: Triggered at the start of drag element
  • dnd-on-drag [function()]: Triggered at the process of drag element
  • dnd-on-dragend [function()]: Triggered at the end of drag element

scope:

  • $dragged [boolean] - Register that lets you know whether the movement element during the last cycle of events (the last ~ 5ms). Convenient to use for example in ng-click (see. Example).
  • $dropmodel [string] - Droppable element model defined in the dnd-model directive

dnd-pointer-none

Attribute operates similar to the pointer-events: none - ignoring the event, but in relation to dnd- directives (see Example 2 sortable directive - the text field)

dnd-droppable [expression]

Create targets for draggable elements. Parameter 'false' disables the directive.

dnd-droppable-opts [object]:

  • layer[string]: What would droppable elements react to draggable elements, they must be in a single layer. By default, layer = 'common'

watching attributes:

  • dnd-on-dragenter [function()]: Triggered when hit draggable within the droppable
  • dnd-on-dragover [function()]: Triggered when an accepted draggable is dragged over the droppable
  • dnd-on-dragleave [function()]: Triggered when leave draggable within the droppable
  • dnd-on-drop [function()]: Triggered when an accepted draggable is dropped on the droppable

scope:

  • $dragmodel [string] Draggable element model defined in the dnd-model directive

dnd-rotatable [expression]

Provides rotate ability to the element. Parameter 'false' disables the directive.

watching attributes:

  • dnd-on-dragstart [function()]: Triggered at the start of element rotation
  • dnd-on-drag [function()]: Triggered at the process of element rotation
  • dnd-on-dragend [function()]: Triggered at the end of element rotation

scope:

  • $rotated [boolean] - Register that lets you know whether the element rotation during the last cycle of events (the last ~ 5ms). Convenient to use for example in ng-click (see. Example).

dnd-resizable [expression]

Provides resize ability to the element. Parameter 'false' disables the directive.

watching attributes:

  • dnd-on-dragstart [function()]: Triggered at the start of resizing element
  • dnd-on-drag [function()]: Triggered at the process of resizing element
  • dnd-on-dragend [function()]: Triggered at the end of resizing element

scope:

  • $resized [boolean] - Register that lets you know whether the element resizing during the last cycle of events (the last ~ 5ms). Convenient to use for example in ng-click (see. Example).

dnd-sortable-list [expression]

List of sortable items

dnd-sortable [expression]

Reorder elements in a list or grid.

watching attributes:

  • dnd-on-sortstart [function()]: Triggered at the start of sorting element
  • dnd-on-sort [function()]: Triggered at the process of sorting element
  • dnd-on-sortchange [function()]: This event is triggered during sorting, but only when the DOM position has changed
  • dnd-on-sortend [function()]: Triggered at the end of sorting element

dnd-lasso-area [expression]

This Directive is to create rect models with lasso tool. Also, this directive can work with a selectable directive (as a container) (see. Example). Parameter 'false' disables the directive.

watching attributes:

  • dnd-on-lassostart [function()]: Triggered at the start of lasso change size
  • dnd-on-lasso [function([rect])]: Triggered at process of lasso change size
  • dnd-on-lassoend [function([rect])]: Triggered at end of lasso change size

scope:

  • $dragged [boolean] - Register that lets you know whether the movement leasso during the last cycle of events (the last ~ 5ms). Convenient to use for example in ng-click (see. Example).

dnd-selectable [expression]

Use manipulator to select elements, individually or in a group.

Requirements:

  • dnd-lasso-area как родительский элемент

watching attributes:

  • dnd-on-selected [function([$keyPressed])]: interrupt after changing selected value (dnd-model-selected) from false to true.
  • dnd-on-unselected [function([$keyPressed])]: interrupt after changing selected value (dnd-model-selected) from true на false.
  • dnd-on-selecting [function([$keyPressed])]: interrupt after changing selecting value (dnd-model-selecting) from false на true.
  • dnd-on-unselecting [function([$keyPressed])]: interrupt after changing selecting value (dnd-model-selecting) from true на false.

model attributes:

  • dnd-model-selected: varibale name of selected state
  • dnd-model-selecting: varibale name of selecting state

scope:

  • $keypressed - Register that indicates whether the button is pressed ctrl, shift or cmd during the event

Sequence of events:

  • if click - selected(true/false).
  • If not click - selecting(true) -> selected(true/false) -> selecting(false)

dnd-rect (string)

Model of element rectangle (top, left, width, height, transform). Core directive. Use with dnd-draggable, dnd-resizable, dnd-rotatable, dnd-fittext, dnd-sortable, and also dnd-selectable(optional) work with dnd-rect.

dnd-containment(string, selector)

Containment work area of draggable/resizable/rotatable elements. By default containment is body.

dnd-fittext (mix)

Directive for text fitting under element sizes.

dnd-fittext parameter:

  • Value, change which triggers resizing text. (ex: {width: rect.width, height: rect.height, text: rect.text}. see example)

  • dnd-fittext-min - min font size in px

  • dnd-fittext-max - max font size in px

Services:

DndLasso

Service-Class to provide directives interface of the rectangular lasso tool

dndKey

Service for control key pressing

Methods

  • get(): get array of pressed keys
  • isset(code): check key state by key code

Examples

  • All examples inside demo folder
  • Also available link

Plunkers

TODO:

  • more options
    • ensure rapid expandability options
  • supporting touch specific events (rotate, resize)
  • supporting dynamic options
  • supporting ng-animate
  • supporting HTML5 dnd events

PS:

Sorry for bad translation. Waiting for your pull requests.

Join the chat at https://gitter.im/Tuch/angular-dnd

angular-dnd's People

Contributors

liollury avatar mih-kopylov avatar petah avatar tuch avatar

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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

angular-dnd's Issues

dndDraggable not allow touch scroll

When I disable draggable with angular directive like :

       <button  dnd-draggable="editionMode()"></button>

I can't scroll on mobile device with touch event.
I resolve problem with add a condition on Touch prototype "preventDefault" :

touchmove: function(event) {
            if (this.manipulator.isTarget()) {
                event.preventDefault();
            }

            this.manipulator.progress(event);
        },

I don't know if it's the best solution but can you take minutes to fix this issues plz ?
I don't want to fork your project just for it :-D

Ошибка при перетаскивании

Привет, у меня создан объект такого плана:

<div class="gem"
                                     ng-repeat="gem in getGems(gemFilter) track by $index"
                                     ng-style="{'background-image': gem.image,
                                                    'background-color': gem.bgColor}"
                                     uib-tooltip-html="getGemTooltip(gem)"
                                     tooltip-placement="top"
                                     tooltip-append-to-body="true"
                                     tooltip-animation="false"

                                     dnd-draggable="true"
                                     dnd-draggable-opts = "{layer: 'layer1', helper : 'clone'}"
                                     dnd-on-dragstart = "inventoryDragStart(gem)"
                                     dnd-on-dragend = "inventoryDragEnd()">
                                </div>

При перетаскивании появляется ошибка:
Uncaught TypeError: Cannot read property '$$phase' of null
drag @ angular-dnd.js:1913
Dnd.trigger @ angular-dnd.js:943
Manipulator.progress @ angular-dnd.js:1230
Mouse.mousemove @ angular-dnd.js:1341
(anonymous function) @ angular-dnd.js:83
n.event.dispatch @ jquery.js:4435
r.handle @ jquery.js:4121

Добавилась эта прелесть в 0.1.20, раньше всё было норм. Точно не знаю, чем это вызвано, но вот тут похожая вещь: angular-ui/ui-tinymce#82

npm cache clear breaks on npm5+

Get an error trying to install on npm5+

As of npm@5, the npm cache self-heals from corruption issues and data extracted from the cache is guaranteed to be valid. If you want to make sure everything is consistent, use 'npm cache verify' instead.

Droppable на несколько областей.

Здравствуйте! В моем проекте необходимо реализовать перетаскивание элементов в 2 области, а не в одну, как у вас в примере. Не могли бы вы привести пример с ondrop($dragtarget) для нескольких областей. Заранее благодарен.

Handling only left mouse button

Попытка перетаскивания по правой кнопке мыши приводит к появлению контекстного меню браузера и непонятному поведению. Нужно ограничиться только левой кнопкой.

Cloning sortable items

Hi!
This could be that I did something wrong, but I suppose that it's bug. Sometime, when I'm draging sortable items, it's cloning - item left on its position plus adding new one.
Here is markup:

<div dnd-container dnd-sortable-list="properties.form_values">
    <div flex layout="column" style="overflow: auto; height: 100%;" ng-repeat="value in properties.form_values track by $index" dnd-sortable dnd-on-sortend="onSortEnd()">
        <md-input-container layout="row" class="md-icon-float md-icon-right md-block flex-box" ng-mouseover="hovering=true" ng-mouseleave="hovering=false">
            <input type="text" ng-model="value" ng-change="onChangeFieldValue($index, value)" />
            <md-icon md-font-set="material-icons" ng-show="hovering" ng-click="onDeleteFieldValue($index, $event)">clear</md-icon>
            <md-icon class="ng-isolate-scope" md-font-set="material-icons" ng-show="hovering" style="cursor: move;">format_line_spacing</md-icon>
        </md-input-container>
    </div>
</div>

P.S. I'm using angular 1.4.8
P.P.S. I'm Russian, but it's international web site, so let's use English - it will make search of issue for other developer easier.

Quick start

Очень сложно начать пользоваться библиотекой без QuickStart Guide.
Может стоит добавить пример минимального использования drag-n-drop элементов без лишних css и js.
Может какой то такой вариант: http://embed.plnkr.co/ElwZjFIQh3N2HHe18Gse/preview ?

Nesting?

Does this support nesting? I.e. dragging lists from a innner list to a parent list?

array indexes

Отличная директива, единственное если вдруг у тебя есть в коде раширения для масива вот токого типа:

Array.prototype.getObjByValue = function(key, value) {
  if (!this) return null;
  if (!value) return null;
  for (var ii in this) {
    if (this[ii][key] == value) {
      return this[ii];
    }
  }
  return null;
};

то, возникет конфликт в позициях где масив обрабатывается как объект
for(var key in regions) { ...
в какой-то момент regions[key] возвращает функцию getObjByValue и выдает ошибку.
с for (var key=0; key<regions.length; key++) {} было бы более правильно

Спасибо

Strange behavior when resizing

Hi again!
Very often after changing the block size it is stretched to a huge size.
Here's my code:

<div class="design-parent" ng-class="variable.opt.allowResize"  ng-controller="HelpController as Helper"
     dnd-draggable      = "true"
     dnd-draggable-opts = "{ layer: 'design-area' }"
     dnd-on-dragend     = "Main.dragEnd(variable)"

     dnd-resizable    = "true"
     dnd-on-resizeend = "Main.resizeEnd(variable)"

     dnd-rect  = "variable.env"
     dnd-model = "variable">
    <div class="design-children">
        <design-control></design-control>
        <div ng-include="Tpl.getObject(variable)"></div>
    </div>
</div>

Main.resizeEnd is:

self.resizeEnd = function (object, isGrid) {
    if(showLogs) { console.group('resizeEnd'); }

    isGrid = isGrid ? isGrid : false;

    var coords = getRoundedNumbers(object.env.width, object.env.height),
        minWidth, minHeight, maxWidth, maxHeight;


    if (isGrid) {
        minWidth  = 380;
        minHeight = 140;
        maxWidth  = 2600;
        maxHeight = 1400;
    } else {
        minWidth  = 180;
        minHeight = 40;
        maxWidth  = 600;
        maxHeight = 400;
    }

    // Here we limit the maximum size
    if (coords[0] < minWidth)  { coords[0] = minWidth;  debugIt(coords[0], '@resize.end.min-width'); console.log('wr1'); }
    if (coords[1] < minHeight) { coords[1] = minHeight; debugIt(coords[1], '@resize.end.min-height'); console.log('wr2'); }

    if (coords[0] > maxWidth)  { coords[0] = maxWidth;  debugIt(coords[0], '@resize.end.max-width'); console.log('wr3'); }
    if (coords[1] > maxHeight) { coords[1] = maxHeight; debugIt(coords[1], '@resize.end.max-height'); console.log('wr4'); }


    object.env.width  = coords[0];
    object.env.height = coords[1];
}

I do not understand why 😞

Dragenter run before dragleave

If droppable-elements are right next to each other, the situation often arises when the dragenter event is invoked before the dragleave event. Because of this, there is an error in logic. ctrl.dropmodel overwritten with the new value, then the event is triggered dragleave with this value at the end of sets ctrl.dropmodel = undefined. As a result, we have a onedroppable-element in target array, but dropmodel = undefined.

See example: http://plnkr.co/edit/tdBHyg032OEK3Kn8ZQZw?p=preview

dnd-sortable

Мне нужно, чтобы свойство position перетаскиваемой модели менялось в соответствии с сортировкой (и других моделей, которые меняют при этом позицию). Могу ли я реализовать это с помощью вашего модуля?

Могу ли я повесть обработчики на событие завершения сортировки? Я пробовал сделать это через dnd-on-dragend, но в ответ в консоль падала ошибка.

It only moves horizontally not vertically

I add the dnd-draggable directive to a div and it moves perfect in a horizontal way but it doesn't move at all vertically. I'm pretty sure it's an issue with my code but it's been a couple of days now and I can't find it. Can you suggest me what might be the problem?

Issue with dnd-fitted text

1 How to get the font size set by the dnd-fitted with rect model object.
2 When placing only the glyphicons icon inside the div with dnd, its not re-sizing it

Is it real use sortable feat. draggable?

Hi all!
Is it possible to use simultaneously two properties: dnd-sortable and dnd-draggable?

After i try to use them - i'm getting error in console, that says:

Error: $compile:multidir
Multiple Directive Resource Contention

Description
This error occurs when multiple directives are applied to the same DOM element, and processing them would result in a collision or an unsupported configuration.

To resolve this issue remove one of the directives which is causing the collision.

Example scenarios of multiple incompatible directives applied to the same element include:

Multiple directives requesting isolated scope.
Multiple directives publishing a controller under the same name.
Multiple directives declared with the transclusion option.
Multiple directives attempting to define a template or templateURL.

It's me doing something wrong, or is this not possible?

P.S. Sorry for bad English ^_^

Input in a draggable container is not focusable

Hello!
If place tag input[type=text] in draggable container, it can't be focused. We discowered that it happens because of #1047 line of code:

event.preventDefault();

in mousedown function of Mouse.prototype.

dndResizable - Изменить размер за уголочки

Всем добрый день,
невозможно изменить размер потянув за уголки,
т.к. уголки спрятаны за горизонталями/вертикалями и недоступны для нажатия.
Для объекта
var defaults = {
handles: 'ne, se, sw, nw, n, e, s, w',
minWidth: 20,
minHeight: 20,
maxWidth: 10000,
maxHeight: 10000
};
нужно изменить handles, на:
handles: 'n, e, s, w, ne, se, sw, nw',
и они будут работать.

Еще, для уголков, горизонталей и вертикалей неплохо бы установить свои css курсоры:
s-resize, w-resize, nw-resize, ne-resize, только это я не знаю как.

Перетаскивание блока только за один элемент

Допустим, что у меня есть такая разметка:

<div id="draggable">
    <div id="drag-control"></div>
</div>

Элемент #draggable я делаю перетаскиваемым. Он занимает всю ширину экрана, и высотой 100 пикселей. Внутри него #drag-control, который размером 10 на 10 пикселей. Могу ли я сделать так, чтобы элемент #draggable перетаскивался только тогда, когда мы тащим за #drag-control?

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.