Comments (4)
Thanks for explaining this well! 👏
I understand the problem, and I agree we should find a solution to make it work.
The solution your proposed works for me. We can let users start the drag sequence manually. This can also solve other use cases, so it will be a positive addition.
The only thing I am not totally convinced about is using the Input enableManualDragEvents
. What about solving it by just using the function onManualDragStart(event)
?
(I also would suggest rename this function to something like startDragManually(event)
or startDrag(event)
)
And if you want to disable the default dragging, you can always set the grid item to be [draggable]="false"
The usage may look like this 👇
Angular Grid Layout template:
<ktd-grid [cols]="cols"
[rowHeight]="rowHeight"
[layout]="layout"
(layoutUpdated)="onLayoutUpdated($event)">
<ktd-grid-item *ngFor="let item of layout; trackBy:trackById" [id]="item.id" [draggable]="false">
<my-grid-item>
</my-grid-item>
</ktd-grid-item>
</ktd-grid>
MyGridItemComponent:
@Component({
selector: 'my-grid-item'
})
export class MyGridItemComponent {
constructor(@Optional() gridItem: KtdGridItemComponent) { }
onDragStart(event) {
gridItem.startDragManually(event);
}
}
What are your thoughts about it?
from angular-grid-layout.
I originally did not have the enableManualDragEvents
flag, but then I realized I still wanted to be able to toggle dragging on and off in the grid while using manual dragging, which doesn't work if you need to set draggable
to false to use manual dragging. So the flag seemed like the most straight forward way to switch between dragging modes while still allowing switching dragging on and off. It also seemed confusing to set draggable
to false but still have dragging enabled in a way.
I can of course change the method name.
from angular-grid-layout.
@pcurrivan It would be really nice to avoid another input. I understand that it makes sense for your use case, but in my opinion, it seems like too much for the overall Angular Grid Layout API.
If I understood correctly, you want to toggle dragging on and off while using manual dragging. Currently, it may not work, but I think the key is to change the code to allow it. In my opinion, manual dragging should work independently of the value of draggable
. So, even if draggable
is false, you should still be able to use manual dragging.
I drafted a possible solution:
return merge(
this._manualDragEvents$,
this._draggable$.pipe(
switchMap((draggable) => {
if (!draggable) {
return NEVER;
} else {
return this._dragHandles.changes.pipe(
startWith(this._dragHandles),
switchMap((dragHandles: QueryList<KtdGridDragHandle>) => {
return iif(
() => dragHandles.length > 0,
merge(...dragHandles.toArray().map(dragHandle => ktdMouseOrTouchDown(dragHandle.element.nativeElement, 1))),
ktdMouseOrTouchDown(this.elementRef.nativeElement, 1)
).pipe(
exhaustMap((startEvent) => {
return this._applyDragThreshold$(startEvent);
})
);
})
);
}
}
))
).pipe(
exhaustMap(e => this._applyDragThreshold$(e))
);
Let me know your thoughts about it!
from angular-grid-layout.
@llorenspujol I removed the Input as requested and updated the comments.
from angular-grid-layout.
Related Issues (20)
- Add v0 branch HOT 1
- Angular 16 support to use standalone component and signals HOT 6
- Have you supported feature related in drag and drop to add new item in grid and nested grid?
- How to auto adjust the grid height based on content
- Dragging and Resizing not working on windows touch screen
- Can I give specific colour to the cell from database?
- Feature to download whole layout as a pdf
- Grid items not resizing if container is resized
- Lack of Auto-Reversion to Default Position in 'Compact type none' Mode HOT 1
- Feature Request - New Directive for Dragging Items into Grid HOT 2
- Documentation for backgroundConfig HOT 1
- Change color of Placeholder on v1.2.0 HOT 1
- Turn off drag and resize feature HOT 1
- Add all other resize options (now is only available 'se-resize'). HOT 3
- How can I lock down a ktd-grid-item? Preventing any movement or replacement! HOT 6
- Support for Angular 16? HOT 1
- RTL direction HOT 2
- Setting Max-height for grid HOT 1
- Drag doesn't work properly when the drag handle is in a child component HOT 1
- Responsive number of columns HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from angular-grid-layout.