forked from ilanddev/gibraltar
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
cho
committed
Sep 6, 2019
1 parent
3a632a9
commit 5486857
Showing
15 changed files
with
1,105 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,4 @@ coverage | |
node_modules | ||
demo/dist | ||
.netlify | ||
src/notes |
Binary file not shown.
Binary file not shown.
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
13 changes: 13 additions & 0 deletions
13
demo/src/app/components/misc-page-component/misc-page.component.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,13 @@ | ||
import { Component } from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'other-page', | ||
template: ` | ||
<div id="other-page"> | ||
<misc-scrollbar-horizontal-demo></misc-scrollbar-horizontal-demo> | ||
<misc-scrollbar-vertical-demo></misc-scrollbar-vertical-demo> | ||
</div> | ||
` | ||
}) | ||
export class MiscPageComponent { | ||
} |
85 changes: 85 additions & 0 deletions
85
.../app/components/misc-scrollbar-demo-component/misc-scrollbar-horizontal-demo.component.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,85 @@ | ||
import { AfterViewInit, Component, ViewChild } from '@angular/core'; | ||
import * as paper from 'paper'; | ||
import { DemoComponent } from '../demo-component/demo.component'; | ||
import { LIGHT_GREY, CANVAS_BACKGROUND_COLOR } from '../../../../../src/constants/colors'; | ||
import { ScrollbarComponent } from '../../../../../src/components/scrollbar'; | ||
import { DEFAULT_SCROLLBAR_THICKNESS } from '../../../../../src/constants/dimensions'; | ||
|
||
@Component({ | ||
selector: 'misc-scrollbar-horizontal-demo', | ||
template: ` | ||
<demo label="Horizontal Scrollbar" height="200" | ||
description="Scrollbar UI component for horizontal scrolling with the default scrollbar and scroll track." | ||
runnable="true" (run)="run()" (reset)="reset()"></demo> | ||
` }) | ||
export class MiscScrollbarHorizontalDemoComponent implements AfterViewInit { | ||
|
||
@ViewChild(DemoComponent) | ||
demo: DemoComponent; | ||
|
||
private fizzSize: number = 100; | ||
|
||
ngAfterViewInit() { | ||
// sets up Paper Project | ||
const proj = this.demo.getProject(); | ||
proj.activate(); | ||
proj.activeLayer.applyMatrix = false; | ||
this.demo.backgroundColor = CANVAS_BACKGROUND_COLOR; | ||
const view = paper.view; | ||
const canvas = this.demo.canvas.nativeElement; | ||
const VIEW_PADDING = 30; | ||
|
||
// create content | ||
const content = new paper.Group(); | ||
for (let i = 0; i < this.fizzSize; i++) { | ||
const textContent = i === 0 | ||
? 0 | ||
: i % 15 === 0 && 'fizzbuzz' || i % 3 === 0 && 'fizz' || i % 5 === 0 && 'buzz' || i; | ||
content.addChildren([ | ||
new paper.Path.Circle({ | ||
position: new paper.Point((100 + 15) * i + 50, view.center.y - 15), | ||
radius: 50, | ||
strokeWidth: 1, | ||
strokeColor: LIGHT_GREY | ||
}), | ||
new paper.PointText({ | ||
point: new paper.Point((100 + 15) * i + 50, view.center.y + 10 - 15), | ||
content: textContent, | ||
fillColor: LIGHT_GREY, | ||
fontSize: 25, | ||
justification: 'center' | ||
}) | ||
]); | ||
} | ||
content.translate(new paper.Point(VIEW_PADDING, 0)); | ||
|
||
// create scrollbar | ||
const scrollbar = new ScrollbarComponent( | ||
{ content: content, containerBounds: view.bounds, contentOffsetEnd: VIEW_PADDING }, | ||
new paper.Point(VIEW_PADDING, view.bounds.bottom - VIEW_PADDING - DEFAULT_SCROLLBAR_THICKNESS), | ||
view.bounds.width - VIEW_PADDING * 2, | ||
'horizontal' | ||
); | ||
|
||
// add scroll listening. paper doesn't have a wheel event handler | ||
canvas.onwheel = (event: WheelEvent) => { | ||
scrollbar.onScroll(event); | ||
}; | ||
// paper tools are global, so specific tools need to be activated when a different view is active | ||
view.onMouseEnter = () => { | ||
scrollbar.activateDefaultTool(); | ||
}; | ||
} | ||
|
||
run() { | ||
this.fizzSize = 4; | ||
this.demo.getProject().clear(); | ||
this.ngAfterViewInit(); | ||
} | ||
|
||
reset() { | ||
this.fizzSize = 100; | ||
this.demo.getProject().clear(); | ||
this.ngAfterViewInit(); | ||
} | ||
} |
84 changes: 84 additions & 0 deletions
84
...rc/app/components/misc-scrollbar-demo-component/misc-scrollbar-vertical-demo.component.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,84 @@ | ||
import { AfterViewInit, Component, ViewChild } from '@angular/core'; | ||
import * as paper from 'paper'; | ||
import { DemoComponent } from '../demo-component/demo.component'; | ||
import { LIGHT_GREY, CANVAS_BACKGROUND_COLOR, VAPP_BACKGROUND_COLOR } from '../../../../../src/constants/colors'; | ||
import { ScrollbarComponent } from '../../../../../src/components/scrollbar'; | ||
import { DEFAULT_SCROLLBAR_THICKNESS } from '../../../../../src/constants/dimensions'; | ||
|
||
@Component({ | ||
selector: 'misc-scrollbar-vertical-demo', | ||
template: ` | ||
<demo label="Vertical Scrollbar" height="800" | ||
description="Scrollbar UI component for vertical scrolling with default scrollbar and track." | ||
runnable="true" (run)="run()" (reset)="reset()"></demo> | ||
` }) | ||
export class MiscScrollbarVerticalDemoComponent implements AfterViewInit { | ||
|
||
@ViewChild(DemoComponent) | ||
demo: DemoComponent; | ||
|
||
private fizzSize: number = 100; | ||
|
||
ngAfterViewInit() { | ||
// sets up Paper Project | ||
const proj = this.demo.getProject(); | ||
proj.activate(); | ||
proj.activeLayer.applyMatrix = false; | ||
this.demo.backgroundColor = CANVAS_BACKGROUND_COLOR; | ||
const view = paper.view; | ||
const canvas = this.demo.canvas.nativeElement; | ||
const VIEW_PADDING = 30; | ||
|
||
// create content | ||
const content = new paper.Group(); | ||
for (let i = 0; i < this.fizzSize; i++) { | ||
const textContent = i === 0 | ||
? 0 | ||
: i % 15 === 0 && 'fizzbuzz' || i % 3 === 0 && 'fizz' || i % 5 === 0 && 'buzz' || i; | ||
content.addChildren([ | ||
new paper.Path.Circle({ | ||
position: new paper.Point(view.center.x, (100 + 15) * i + 50), | ||
radius: 50, | ||
strokeWidth: 1, | ||
strokeColor: LIGHT_GREY | ||
}), | ||
new paper.PointText({ | ||
point: new paper.Point(view.center.x, (100 + 15) * i + 60), | ||
content: textContent, | ||
fillColor: LIGHT_GREY, | ||
fontSize: 25, | ||
justification: 'center' | ||
}) | ||
]); | ||
} | ||
content.translate(new paper.Point(0, VIEW_PADDING)); | ||
|
||
// create scrollbar | ||
const scrollbar = new ScrollbarComponent( | ||
{ content: content, containerBounds: view.bounds, contentOffsetEnd: VIEW_PADDING }, | ||
new paper.Point(view.bounds.right - VIEW_PADDING - DEFAULT_SCROLLBAR_THICKNESS, VIEW_PADDING), | ||
view.bounds.height - VIEW_PADDING * 2, | ||
'vertical'); | ||
|
||
// add scroll listening. paper doesn't have a wheel event handler | ||
canvas.onwheel = (event: WheelEvent) => { | ||
scrollbar.onScroll(event); | ||
}; | ||
// paper tools are global, so specific tools need to be activated when a different view is active | ||
view.onMouseEnter = () => { | ||
scrollbar.activateDefaultTool(); | ||
}; | ||
} | ||
|
||
run() { | ||
this.fizzSize = 4; | ||
this.demo.getProject().clear(); | ||
this.ngAfterViewInit(); | ||
} | ||
|
||
reset() { | ||
this.fizzSize = 100; | ||
this.demo.getProject().clear(); | ||
this.ngAfterViewInit(); | ||
} | ||
} |
Oops, something went wrong.