-
Notifications
You must be signed in to change notification settings - Fork 221
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #250 from Kyusung4698/develop
0.5.18
- Loading branch information
Showing
28 changed files
with
8,233 additions
and
8,078 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/app/modules/evaluate/component/evaluate-dialog/evaluate-dialog.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
import { PriceTagType } from '@shared/module/poe/service'; | ||
import { Currency } from '@shared/module/poe/type'; | ||
|
||
export interface EvaluateResult { | ||
currency: Currency; | ||
amount: number; | ||
type: PriceTagType; | ||
} |
2 changes: 1 addition & 1 deletion
2
src/app/modules/map/component/map-dialog/map-dialog.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
src/app/shared/module/material/directive/drag.directive.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { DragDirective } from './drag.directive'; | ||
import { ElementRef } from '@angular/core'; | ||
|
||
describe('DragDirective', () => { | ||
it('should create an instance', () => { | ||
const directive = new DragDirective(new ElementRef<HTMLElement>(document.createElement('div'))); | ||
expect(directive).toBeTruthy(); | ||
}); | ||
}); |
98 changes: 98 additions & 0 deletions
98
src/app/shared/module/material/directive/drag.directive.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
import { Directive, ElementRef, Input, OnDestroy, OnInit } from '@angular/core'; | ||
import { Point } from '@app/type'; | ||
|
||
@Directive({ | ||
selector: '[appDrag]' | ||
}) | ||
export class DragDirective implements OnInit, OnDestroy { | ||
private element: HTMLElement; | ||
|
||
private pressed = false; | ||
private dragging = false; | ||
|
||
private pointerPosition: Point; | ||
private position: Point; | ||
|
||
@Input('appDrag') | ||
public rootElementSelector: string; | ||
|
||
constructor(private readonly elementRef: ElementRef<HTMLElement>) { } | ||
|
||
public ngOnInit(): void { | ||
if (this.rootElementSelector) { | ||
this.element = getClosestMatchingAncestor(this.elementRef.nativeElement, this.rootElementSelector); | ||
} | ||
this.element = this.element || this.elementRef.nativeElement; | ||
this.element.addEventListener('mousedown', this.mousedown, true); | ||
this.element.addEventListener('mouseup', this.mouseup, true); | ||
this.element.addEventListener('mousemove', this.mousemove, true); | ||
} | ||
|
||
public ngOnDestroy(): void { | ||
this.element.removeEventListener('mousedown', this.mousedown); | ||
this.element.removeEventListener('mouseup', this.mouseup); | ||
this.element.removeEventListener('mousemove', this.mousemove); | ||
} | ||
|
||
private mousedown = (event: MouseEvent) => { | ||
this.pressed = true; | ||
this.pointerPosition = { | ||
x: event.pageX, | ||
y: event.pageY, | ||
}; | ||
this.position = { | ||
x: +this.element.style['margin-left'].replace('px', ''), | ||
y: +this.element.style['margin-top'].replace('px', ''), | ||
}; | ||
}; | ||
|
||
private mouseup = () => { | ||
this.pressed = false; | ||
this.dragging = false; | ||
}; | ||
|
||
private mousemove = (event: MouseEvent) => { | ||
if (!this.pressed) { | ||
return; | ||
} | ||
|
||
if (!this.dragging) { | ||
const distanceX = Math.abs(event.pageX - this.pointerPosition.x); | ||
const distanceY = Math.abs(event.pageY - this.pointerPosition.y); | ||
|
||
const isOverThreshold = distanceX + distanceY >= 5; | ||
if (isOverThreshold) { | ||
this.dragging = true; | ||
} | ||
} | ||
|
||
if (!this.dragging) { | ||
return; | ||
} | ||
|
||
const delta: Point = { | ||
x: event.pageX - this.pointerPosition.x, | ||
y: event.pageY - this.pointerPosition.y, | ||
}; | ||
|
||
this.element.style['margin-left'] = `${this.position.x + delta.x}px`; | ||
this.element.style['margin-top'] = `${this.position.y + delta.y}px`; | ||
}; | ||
} | ||
|
||
/** Gets the closest ancestor of an element that matches a selector. */ | ||
function getClosestMatchingAncestor(element: HTMLElement, selector: string) { | ||
let currentElement = element.parentElement as HTMLElement | null; | ||
|
||
while (currentElement) { | ||
// IE doesn't support `matches` so we have to fall back to `msMatchesSelector`. | ||
if (currentElement.matches ? currentElement.matches(selector) : | ||
(currentElement as any).msMatchesSelector(selector)) { | ||
return currentElement; | ||
} | ||
|
||
currentElement = currentElement.parentElement; | ||
} | ||
|
||
return null; | ||
} |
Oops, something went wrong.