[
https://issues.apache.org/jira/browse/NIFI-5018?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16780876#comment-16780876
]
Matt Gilman commented on NIFI-5018:
-----------------------------------
[~john.wise] I'm not sure if this feature would help with the issue your
describing. This feature is simply adjusting the coordinates while dragging in
8 pixel chunks. To help with the problem your describing, I _think_ we'd need
to delay polling while a drag operation was occurring. This probably warrants
it's own JIRA.
> basic snap-to-grid feature for UI
> ---------------------------------
>
> Key: NIFI-5018
> URL: https://issues.apache.org/jira/browse/NIFI-5018
> Project: Apache NiFi
> Issue Type: Improvement
> Components: Core UI
> Affects Versions: 1.8.0
> Environment: Tested on Ubuntu v18.04.1
> Reporter: Ryan Bower
> Priority: Minor
> Labels: web-ui
> Attachments:
> 0001-NIFI-5018-adding-basic-snap-to-grid-functionality-fo.patch
>
> Original Estimate: 0.25h
> Time Spent: 4h 20m
> Remaining Estimate: 0h
>
>
> I've made some modifications to the Canvas UI that results in a
> "snap-to-grid" during the component drag state. See [this
> video|https://www.youtube.com/watch?v=S7lnBMMO6KE&feature=youtu.be] for an
> example of it in action.
>
> For consistency from component to component, I made minor adjustments to the
> height and width of specific components such that each divides evenly by 8
> (the pixel snap alignment value).
> nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-process-group.js
> nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-remote-process-group.js
> nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-processor.js
> nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-port.js
>
> The processor alignment is based on rounding the component's X and Y
> coordinates during the drag event. The X and Y values of each component now
> shift 8px at a time.
> nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-draggable.js:
>
> {{(function (root, factory) {}}
> ...
> {{}(this, function ($, d3, nfConnection, nfBirdseye, nfCanvasUtils,
> nfCommon, nfDialog, nfClient, nfErrorHandler) {}}
> {{ 'use strict';}}
> {{ var nfCanvas;}}
> {{ var drag;}}{{ }}
>
> {{// added for snap-to-grid feature.}}
> {{ var snapTo = 8;}}
> {{ ...}}
> {{ var nfDraggable = {}}
> {{ ...}}
> {{ if (dragSelection.empty()) }}{
>
> {{ // more code...}}
>
> {{ } else {}}
> {{ // update the position of the drag selection}}{{ }}
> {{ dragSelection.attr('x', function (d) {}}
> {{ d.x += d3.event.dx;}}
> {{ // rounding the result achieves the "snap" alignment}}
> {{ return (Math.round(d.x/snapTo) * snapTo);}}
> {{ })}}
> {{ .attr('y', function (d) {}}
> {{ d.y += d3.event.dy;}}
> {{ return (Math.round(d.y/snapTo) * snapTo);}}
> {{ });}}
> }
>
> ...
>
> {{ updateComponentPosition: function (d, delta) {}}
> {{ // perform rounding again for the update}}
> {{ var newPosition = {}}
> {{ 'x': (Math.round((d.position.x + delta.x)/snapTo) * snapTo),}}
> {{ 'y': (Math.round((d.position.y + delta.y)/snapTo) * snapTo)}}
> {{ };}}
> {{ ...}}
> }
>
>
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)