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

Replace goog.fx in sortable directive #3101

Merged
merged 11 commits into from
Dec 6, 2017

Conversation

pfirpfel
Copy link
Contributor

@pfirpfel pfirpfel commented Nov 15, 2017

contribs/gmf/src/controllers/abstractmobile.js (I'm going to do this in a separate branch/pr)

  • src/directives/sortable.js

@pfirpfel
Copy link
Contributor Author

To test sortable.js:

  • layerorder example
  • desktop app, use the demo theme

I tested debug and compile on Chrome and Firefox (desktop and mobile). Needs more testing on IE, Edge and Safari (especially mobile)

@@ -0,0 +1,180 @@
/*!
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From where does this file comes from?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

http://touchpunch.furf.com/
Jquery-ui does not support touch events. Without this patch it won't work on mobile devices.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason to not using the npm package?
https://www.npmjs.com/package/jquery-ui-touch-punch

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My reasoning was to put it to the same place as jquery-ui, since they belong together. We don't use an npm package for jquery-ui either.
The touchpunch code hasn't changed in the last four years, so I don't expect updates.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason to don't use the jquery-ui npm it to have a custom build that's not possible with the npm package...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed it.

@pfirpfel pfirpfel changed the title [WIP] Replace goog.fx Replace goog.fx in sortable directive Nov 16, 2017
@pfirpfel pfirpfel requested a review from fredj November 16, 2017 14:52
Makefile Outdated
-e 's|\.\./third-party/jquery-ui/jquery-ui.min\.css|lib/jquery-ui.min.css|' \
-e 's|\.\./node_modules/bootstrap/dist/js/bootstrap.js|lib/bootstrap.min.js|' \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is the removal of bootstrap.jswanted?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, good catch.

@fredj
Copy link
Member

fredj commented Nov 17, 2017

In comparaison to https://camptocamp.github.io/ngeo/master/examples/contribs/gmf/apps/desktop:

  • When dragging an open layertree item, it must be (temporary) closed.
  • When moving an item, there must be a "shadow" box (dotted box)
  • (new) If possible it would be nice to limit the dragging in the vertical axis only

if (dragListGroup !== null) {
dragListGroup.dispose();
}
const sortableElement = $(element[0]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor: index not need, it can be const sortableElement = $(element);

@pfirpfel
Copy link
Contributor Author

I'm looking into this.

When dragging an open layertree item, it must be (temporary) closed.

I never noticed that. I'm going to check where this happened before.

When moving an item, there must be a "shadow" box (dotted box)

Should be simple, see: http://jqueryui.com/sortable/#placeholder

@fredj
Copy link
Member

fredj commented Nov 17, 2017

Please also add this change:

diff --git a/contribs/gmf/less/desktoplayertree.less b/contribs/gmf/less/desktoplayertree.less
index 85077d1..da6741e 100644
--- a/contribs/gmf/less/desktoplayertree.less
+++ b/contribs/gmf/less/desktoplayertree.less
@@ -8,7 +8,6 @@ gmf-layertree {
   width: 100%;
   ul {
     margin-bottom: 0;
-    height: 100%;
   }
   > :first-child {
     margin-right: @half-app-margin;

It was a workaround for a limitation in goog.fx

@fredj
Copy link
Member

fredj commented Nov 17, 2017

And in addition to limit the axis to y, what about adding the containment: 'parent' option?

@pfirpfel
Copy link
Contributor Author

Axis and containment don't really complement each other. They do, in regards to the layertree, very similar things.

Containment has the issue that the layertree parent element is very "tight" and leaves no tolerance. This can make replacing the top layer impossible if you grab the layer handle at the top:

containment-issue

Axis has the issue, that you can drag the layer (but not drop) to useless areas above and below the tree:

axis-issue

But using neither is worse, because you can get the layertree tab to scroll:

neither-issue

I suggest we use the "axis: 'y'"-option. Replacing the top layer comes up often enough.

@fredj
Copy link
Member

fredj commented Nov 21, 2017

yes, go ahead with axis: 'y' only

@sbrunner sbrunner added this to the 2.3 milestone Nov 21, 2017
@pfirpfel pfirpfel force-pushed the replace-goog-fx branch 2 times, most recently from 1154fed to 8c7a85e Compare November 22, 2017 15:07
@gberaudo
Copy link
Member

@pfirpfel, what is the status here? Is it ready for merging?

@pfirpfel
Copy link
Contributor Author

I'm stuck with a CSS issue.

My goal is to collapse the layer group when it gets dragged, like it does with goog.fx.

The rules from bootstrap for the regular collapsing(-button) look like this:

.collapse {
  display: none;

  &.in      { display: block; }
  tr&.in    { display: table-row; }
  tbody&.in { display: table-row-group; }
}

This class gets added to the ul-element inside the li of the layer group.
To be more specfic than this rule, I'm currently on this:

.ui-sortable .gmf-layertree-node.gmf-layertree-dragger {
  ul.collapse.in {
    display: none;
  }
}

see: https://github.com/pfirpfel/ngeo/blob/replace-goog-fx-collapse/contribs/gmf/less/desktoplayertree.less#L112

In Chrome and Firefox it wins against the collapse.in-class, but the effect is different.
The display:none of collapse hides the element, the ul.collapse.in of mine leaves the empty space there.

I think the issue is, that the drag and drop API (HTML5) creates a picture that gets dragged around. So it isn't the actual DOM element. Or at least a ill-timed snapshot of it.

As an experiment I removed the .in class (would set display:block) from the element during drag via the drag-event-handlers. This had the same effect as the CSS stuff above.

I think I'll leave it as it is. The collapsing is only really necessary on a long list of layergroups.

@gberaudo
Copy link
Member

Yes @pfirpfel, we will improve in a second step if it is too disturbing with the new way.

@@ -1,15 +1,14 @@
goog.provide('ngeo.SortableOptions');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this line can be removed

Copy link
Member

@fredj fredj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's merge as it, thanks @pfirpfel

@fredj fredj merged commit 2999840 into camptocamp:master Dec 6, 2017
@pfirpfel pfirpfel deleted the replace-goog-fx branch April 13, 2018 13:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants