mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-09 19:13:08 +00:00
drag/click differensiating directive + fix for fixedheight truncatable elements
This commit is contained in:
@@ -40,6 +40,7 @@ import { SearchResultGridElementComponent } from './object-grid/search-result-gr
|
|||||||
import { ViewModeSwitchComponent } from './view-mode-switch/view-mode-switch.component';
|
import { ViewModeSwitchComponent } from './view-mode-switch/view-mode-switch.component';
|
||||||
import { GridThumbnailComponent } from './object-grid/grid-thumbnail/grid-thumbnail.component';
|
import { GridThumbnailComponent } from './object-grid/grid-thumbnail/grid-thumbnail.component';
|
||||||
import { VarDirective } from './utils/var.directive';
|
import { VarDirective } from './utils/var.directive';
|
||||||
|
import { DragClickDirective } from './utils/drag-click.directive';
|
||||||
import { TruncatePipe } from './utils/truncate.pipe';
|
import { TruncatePipe } from './utils/truncate.pipe';
|
||||||
import { TruncatableComponent } from './truncatable/truncatable.component';
|
import { TruncatableComponent } from './truncatable/truncatable.component';
|
||||||
import { TruncatableService } from './truncatable/truncatable.service';
|
import { TruncatableService } from './truncatable/truncatable.service';
|
||||||
@@ -104,7 +105,8 @@ const PROVIDERS = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
const DIRECTIVES = [
|
const DIRECTIVES = [
|
||||||
VarDirective
|
VarDirective,
|
||||||
|
DragClickDirective
|
||||||
];
|
];
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
|
@@ -49,7 +49,7 @@ $h4-factor: strip-unit($h4-font-size);
|
|||||||
.clamp-none {
|
.clamp-none {
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
@for $i from 1 through 15 {
|
@for $i from 1 through 15 {
|
||||||
&.min-#{$i} {
|
&.fixedHeight.min-#{$i} {
|
||||||
transition: height 1s;
|
transition: height 1s;
|
||||||
@include min($i);
|
@include min($i);
|
||||||
&.title {
|
&.title {
|
||||||
|
@@ -1,3 +1,3 @@
|
|||||||
<div (click)="toggle()" (mouseenter)="hoverExpand()" (mouseleave)="hoverCollapse">
|
<div dsDragClick (actualClick)="toggle()" (mouseenter)="hoverExpand()" (mouseleave)="hoverCollapse">
|
||||||
<ng-content></ng-content>
|
<ng-content></ng-content>
|
||||||
</div>
|
</div>
|
23
src/app/shared/utils/drag-click.directive.ts
Normal file
23
src/app/shared/utils/drag-click.directive.ts
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
import { Directive, EventEmitter, HostListener, Output } from '@angular/core';
|
||||||
|
|
||||||
|
@Directive({
|
||||||
|
selector: '[dsDragClick]'
|
||||||
|
})
|
||||||
|
export class DragClickDirective {
|
||||||
|
private start;
|
||||||
|
@Output() actualClick = new EventEmitter();
|
||||||
|
|
||||||
|
@HostListener('mousedown', ['$event'])
|
||||||
|
mousedownEvent(event) {
|
||||||
|
this.start = new Date();
|
||||||
|
}
|
||||||
|
|
||||||
|
@HostListener('mouseup', ['$event'])
|
||||||
|
mouseupEvent(event) {
|
||||||
|
const end: any = new Date();
|
||||||
|
const clickTime = end - this.start;
|
||||||
|
if (clickTime < 250) {
|
||||||
|
this.actualClick.emit(event)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user