| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent d011162 commit d8ce04a
39 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -35,32 +35,32 @@ context('Gutter click example page tests', () => { | |||
| 35 | 35 | ||
| 36 | 36 | it('Click gutters to switch area sizes between 0 and X', () => { | |
| 37 | 37 | cy.get('.as-split-gutter').eq(0).click() | |
| 38 | - cy.wait(1500) | ||
| 38 | + cy.wait(2000) | ||
| 39 | 39 | checkSplitDirAndSizes('.split-example > as-split', 'horizontal', W, H, GUTTER, [0, 792, 264]) | |
| 40 | 40 | cy.wait(10) | |
| 41 | 41 | ||
| 42 | 42 | cy.get('.as-split-gutter').eq(0).click() | |
| 43 | - cy.wait(1500) | ||
| 43 | + cy.wait(2000) | ||
| 44 | 44 | checkSplitDirAndSizes('.split-example > as-split', 'horizontal', W, H, GUTTER, [264, 528, 264]) | |
| 45 | 45 | cy.wait(10) | |
| 46 | 46 | ||
| 47 | 47 | cy.get('.as-split-gutter').eq(0).click() | |
| 48 | - cy.wait(1500) | ||
| 48 | + cy.wait(2000) | ||
| 49 | 49 | checkSplitDirAndSizes('.split-example > as-split', 'horizontal', W, H, GUTTER, [0, 792, 264]) | |
| 50 | 50 | cy.wait(10) | |
| 51 | 51 | ||
| 52 | 52 | cy.get('.as-split-gutter').eq(1).click() | |
| 53 | - cy.wait(1500) | ||
| 53 | + cy.wait(2000) | ||
| 54 | 54 | checkSplitDirAndSizes('.split-example > as-split', 'horizontal', W, H, GUTTER, [0, 1056, 0]) | |
| 55 | 55 | cy.wait(10) | |
| 56 | 56 | ||
| 57 | 57 | cy.get('.as-split-gutter').eq(0).click() | |
| 58 | - cy.wait(1500) | ||
| 58 | + cy.wait(2000) | ||
| 59 | 59 | checkSplitDirAndSizes('.split-example > as-split', 'horizontal', W, H, GUTTER, [264, 792, 0]) | |
| 60 | 60 | cy.wait(10) | |
| 61 | 61 | ||
| 62 | 62 | cy.get('.as-split-gutter').eq(1).click() | |
| 63 | - cy.wait(1500) | ||
| 63 | + cy.wait(2000) | ||
| 64 | 64 | checkSplitDirAndSizes('.split-example > as-split', 'horizontal', W, H, GUTTER, [264, 528, 264]) | |
| 65 | 65 | cy.wait(10) | |
| 66 | 66 | ||
@@ -123,7 +123,7 @@ context('Gutter click example page tests', () => { | |||
| 123 | 123 | checkEventCount({ dragStartCount: 2, dragEndCount: 2, gutterClickCount: 4, transitionEndCount: 4 }) | |
| 124 | 124 | ||
| 125 | 125 | // It should fire Click Event on mouseup if the mouse cursor is not moved. | |
| 126 | - cy.get('.as-split-gutter').eq(0).trigger('mousedown', { which: 1, clientX: 0, clientY: 0 }) | ||
| 126 | + cy.get('.as-split-gutter').eq(0).trigger('mousedown', { which: 1, clientX: 0, clientY: 0, button: 0 }) | ||
| 127 | 127 | cy.get('.as-split-gutter').eq(0).trigger('mousemove', { which: 1, clientX: 0, clientY: 0 }) | |
| 128 | 128 | cy.wait(10) | |
| 129 | 129 | checkEventCount({ dragStartCount: 2, dragEndCount: 2, gutterClickCount: 4, transitionEndCount: 4 }) | |
@@ -132,15 +132,23 @@ context('Gutter click example page tests', () => { | |||
| 132 | 132 | cy.wait(2000) | |
| 133 | 133 | checkEventCount({ dragStartCount: 2, dragEndCount: 2, gutterClickCount: 5, transitionEndCount: 5 }) | |
| 134 | 134 | ||
| 135 | - // It should fire dragStart and should not fire Click Event on mousemove if the mouse cursor is moved. | ||
| 136 | - cy.get('.as-split-gutter').eq(0).trigger('mousedown', { which: 1, clientX: 0, clientY: 0 }) | ||
| 135 | + // It should fire click only when moved inside delta (2 pixels) | ||
| 136 | + cy.get('.as-split-gutter').eq(0).trigger('mousedown', { which: 1, clientX: 0, clientY: 0, button: 0 }) | ||
| 137 | 137 | cy.get('.as-split-gutter').eq(0).trigger('mousemove', { which: 1, clientX: 1, clientY: 0 }) | |
| 138 | 138 | cy.wait(10) | |
| 139 | - checkEventCount({ dragStartCount: 3, dragEndCount: 2, gutterClickCount: 5, transitionEndCount: 5 }) | ||
| 139 | + checkEventCount({ dragStartCount: 2, dragEndCount: 2, gutterClickCount: 5, transitionEndCount: 5 }) | ||
| 140 | + cy.get('.as-split-gutter').eq(0).trigger('mouseup', { which: 1, clientX: 0, clientY: 0 }) | ||
| 141 | + cy.wait(20) | ||
| 142 | + checkEventCount({ dragStartCount: 2, dragEndCount: 2, gutterClickCount: 6, transitionEndCount: 6 }) | ||
| 140 | 143 | ||
| 144 | + // It should fire drag start and end only when moved outside delta (2 pixels) | ||
| 145 | + cy.get('.as-split-gutter').eq(0).trigger('mousedown', { which: 1, clientX: 0, clientY: 0, button: 0 }) | ||
| 146 | + cy.get('.as-split-gutter').eq(0).trigger('mousemove', { which: 1, clientX: 3, clientY: 0 }) | ||
| 147 | + cy.wait(10) | ||
| 148 | + checkEventCount({ dragStartCount: 3, dragEndCount: 2, gutterClickCount: 6, transitionEndCount: 6 }) | ||
| 141 | 149 | cy.get('.as-split-gutter').eq(0).trigger('mouseup', { which: 1, clientX: 0, clientY: 0 }) | |
| 142 | 150 | cy.wait(20) | |
| 143 | - checkEventCount({ dragStartCount: 3, dragEndCount: 3, gutterClickCount: 5, transitionEndCount: 5 }) | ||
| 151 | + checkEventCount({ dragStartCount: 3, dragEndCount: 3, gutterClickCount: 6, transitionEndCount: 6 }) | ||
| 144 | 152 | }) | |
| 145 | 153 | ||
| 146 | 154 | it('Test double click event', () => { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -242,16 +242,16 @@ context('Geek demo example page tests', () => { | |||
| 242 | 242 | // SET gutterStep to 10px | |
| 243 | 243 | cy.get('.opts-prop').contains('Gutter step:').parent().contains('10').click() | |
| 244 | 244 | ||
| 245 | - // Move gutter 5px > no move | ||
| 246 | - moveGutterByMouse('.split-example .as-split-gutter', 0, 5, 0) | ||
| 245 | + // Move gutter 4px > no move | ||
| 246 | + moveGutterByMouse('.split-example .as-split-gutter', 0, 4, 0) | ||
| 247 | 247 | checkSplitDirAndSizes('.split-example > as-split', 'horizontal', W, H, GUTTER, [268.484375, 522, 263.5]) | |
| 248 | 248 | ||
| 249 | 249 | // Move gutter 6px > move 10px | |
| 250 | 250 | moveGutterByMouse('.split-example .as-split-gutter', 0, 6, 0) | |
| 251 | 251 | checkSplitDirAndSizes('.split-example > as-split', 'horizontal', W, H, GUTTER, [278.5, 511.984375, 263.5]) | |
| 252 | 252 | ||
| 253 | - // Move gutter 15px > move 10px | ||
| 254 | - moveGutterByMouse('.split-example .as-split-gutter', 0, 15, 0) | ||
| 253 | + // Move gutter 14px > move 10px | ||
| 254 | + moveGutterByMouse('.split-example .as-split-gutter', 0, 14, 0) | ||
| 255 | 255 | checkSplitDirAndSizes('.split-example > as-split', 'horizontal', W, H, GUTTER, [288.515625, 501.984375, 263.5]) | |
| 256 | 256 | ||
| 257 | 257 | // Move gutter 16px > move 20px | |
@@ -266,8 +266,8 @@ context('Geek demo example page tests', () => { | |||
| 266 | 266 | moveGutterByMouse('.split-example .as-split-gutter', 0, 20, 0) | |
| 267 | 267 | checkSplitDirAndSizes('.split-example > as-split', 'horizontal', W, H, GUTTER, [308.515625, 481.984375, 263.5]) | |
| 268 | 268 | ||
| 269 | - // Move gutter 25px > nomove | ||
| 270 | - moveGutterByMouse('.split-example .as-split-gutter', 0, 25, 0) | ||
| 269 | + // Move gutter 24px > nomove | ||
| 270 | + moveGutterByMouse('.split-example .as-split-gutter', 0, 24, 0) | ||
| 271 | 271 | checkSplitDirAndSizes('.split-example > as-split', 'horizontal', W, H, GUTTER, [308.515625, 481.984375, 263.5]) | |
| 272 | 272 | ||
| 273 | 273 | // Move gutter 26px > move 50px | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,7 +1,7 @@ | |||
| 1 | 1 | export function moveGutterByMouse(gutters, num, x, y) { | |
| 2 | 2 | cy.get(gutters) | |
| 3 | 3 | .eq(num) | |
| 4 | - .trigger('mousedown', { which: 1, clientX: 0, clientY: 0 }) | ||
| 4 | + .trigger('mousedown', { which: 1, clientX: 0, clientY: 0, button: 0 }) | ||
| 5 | 5 | .trigger('mousemove', { clientX: x * 0.25, clientY: y * 0.25 }) | |
| 6 | 6 | .trigger('mousemove', { clientX: x * 0.5, clientY: y * 0.5 }) | |
| 7 | 7 | .trigger('mousemove', { clientX: x * 0.75, clientY: y * 0.75 }) | |
@@ -64,28 +64,30 @@ export function checkSplitDirAndSizes(el, dir, w, h, gutter, sizes) { | |||
| 64 | 64 | const total = sizes.reduce((acc, v) => acc + v, 0) + gutter * (sizes.length - 1) | |
| 65 | 65 | // expect(total).to.eq((dir === 'horizontal') ? w : h); | |
| 66 | 66 | ||
| 67 | - const propFlexDir = dir === 'horizontal' ? 'row' : 'column' | ||
| 68 | - cy.get(el).should('have.css', 'flex-direction', propFlexDir) | ||
| 67 | + const propGridDir = dir === 'vertical' ? 'grid-template-rows' : 'grid-template-columns' | ||
| 68 | + cy.get(el).should('have.css', propGridDir).should('include', ' ') | ||
| 69 | 69 | ||
| 70 | 70 | const propSize = dir === 'horizontal' ? 'width' : 'height' | |
| 71 | 71 | const propSize2 = propSize === 'width' ? 'height' : 'width' | |
| 72 | 72 | const propValue2 = propSize === 'width' ? h : w | |
| 73 | 73 | ||
| 74 | + const round = (value) => Math.round(value * 10) / 10 | ||
| 75 | + | ||
| 74 | 76 | cy.get(`${el} > .as-split-gutter`).should('have.length', sizes.length - 1) | |
| 75 | 77 | ||
| 76 | 78 | cy.get(`${el} > .as-split-gutter`).then(($el) => { | |
| 77 | 79 | const rect = $el[0].getBoundingClientRect() | |
| 78 | 80 | ||
| 79 | 81 | expect(rect[propSize]).to.be.eq(gutter) | |
| 80 | - expect(rect[propSize2]).to.be.eq(propValue2) | ||
| 82 | + expect(round(rect[propSize2])).to.be.eq(round(propValue2)) | ||
| 81 | 83 | }) | |
| 82 | 84 | ||
| 83 | 85 | cy.get(`${el} > .as-split-area`) | |
| 84 | 86 | .should('have.length', sizes.length) | |
| 85 | 87 | .each(($li, index) => { | |
| 86 | 88 | const rect = $li[0].getBoundingClientRect() | |
| 87 | 89 | ||
| 88 | - expect(rect[propSize]).to.be.eq(sizes[index]) | ||
| 89 | - expect(rect[propSize2]).to.be.eq(propValue2) | ||
| 90 | + expect(round(rect[propSize])).to.be.eq(round(sizes[index])) | ||
| 91 | + expect(round(rect[propSize2])).to.be.eq(round(propValue2)) | ||
| 90 | 92 | }) | |
| 91 | 93 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -39,10 +39,6 @@ | |||
| 39 | 39 | "zone.js": "~0.14.2" | |
| 40 | 40 | }, | |
| 41 | 41 | "devDependencies": { | |
| 42 | - "lint-staged": "^14.0.1", | ||
| 43 | - "angular-cli-ghpages": "^2.0.0-beta.2", | ||
| 44 | - "husky": "^8.0.3", | ||
| 45 | - "prettier": "^3.0.2", | ||
| 46 | 42 | "@angular-devkit/architect": "^0.1701.0", | |
| 47 | 43 | "@angular-devkit/build-angular": "^17.1.0", | |
| 48 | 44 | "@angular-devkit/core": "^17.1.0", | |
@@ -62,10 +58,14 @@ | |||
| 62 | 58 | "@types/node": "20.5.4", | |
| 63 | 59 | "@typescript-eslint/eslint-plugin": "6.19.0", | |
| 64 | 60 | "@typescript-eslint/parser": "6.19.0", | |
| 65 | - "cypress": "12.17.4", | ||
| 61 | + "angular-cli-ghpages": "^2.0.0-beta.2", | ||
| 62 | + "cypress": "^13.10.0", | ||
| 66 | 63 | "eslint": "^8.56.0", | |
| 64 | + "husky": "^8.0.3", | ||
| 65 | + "lint-staged": "^14.0.1", | ||
| 67 | 66 | "ng-packagr": "^17.0.0", | |
| 68 | 67 | "postcss": "8.4.28", | |
| 68 | + "prettier": "^3.0.2", | ||
| 69 | 69 | "serve": "^14.2.1", | |
| 70 | 70 | "ts-node": "10.9.1", | |
| 71 | 71 | "tslib": "^2.6.2", | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,4 +1,47 @@ | |||
| 1 | - import { InjectionToken } from '@angular/core' | ||
| 2 | - import { IDefaultOptions } from './interface' | ||
| 1 | + import { InjectionToken, Provider, inject } from '@angular/core' | ||
| 2 | + import { SplitDir, SplitDirection, SplitUnit } from './models' | ||
| 3 | 3 | ||
| 4 | - export const ANGULAR_SPLIT_DEFAULT_OPTIONS = new InjectionToken<Partial<IDefaultOptions>>('angular-split-global-config') | ||
| 4 | + export interface AngularSplitDefaultOptions { | ||
| 5 | + dir: SplitDir | ||
| 6 | + direction: SplitDirection | ||
| 7 | + disabled: boolean | ||
| 8 | + gutterDblClickDuration: number | ||
| 9 | + gutterSize: number | ||
| 10 | + gutterStep: number | ||
| 11 | + gutterClickDeltaPx: number | ||
| 12 | + restrictMove: boolean | ||
| 13 | + unit: SplitUnit | ||
| 14 | + useTransition: boolean | ||
| 15 | + } | ||
| 16 | + | ||
| 17 | + const defaultOptions: AngularSplitDefaultOptions = { | ||
| 18 | + dir: 'ltr', | ||
| 19 | + direction: 'horizontal', | ||
| 20 | + disabled: false, | ||
| 21 | + gutterDblClickDuration: 0, | ||
| 22 | + gutterSize: 11, | ||
| 23 | + gutterStep: 1, | ||
| 24 | + gutterClickDeltaPx: 2, | ||
| 25 | + restrictMove: false, | ||
| 26 | + unit: 'percent', | ||
| 27 | + useTransition: false, | ||
| 28 | + } | ||
| 29 | + | ||
| 30 | + export const ANGULAR_SPLIT_DEFAULT_OPTIONS = new InjectionToken<AngularSplitDefaultOptions>( | ||
| 31 | + 'angular-split-global-config', | ||
| 32 | + { providedIn: 'root', factory: () => defaultOptions }, | ||
| 33 | + ) | ||
| 34 | + | ||
| 35 | + /** | ||
| 36 | + * Provides default options for angular split. The options object has hierarchical inheritance | ||
| 37 | + * which means only the declared properties will be overridden | ||
| 38 | + */ | ||
| 39 | + export function provideAngularSplitOptions(options: Partial<AngularSplitDefaultOptions>): Provider { | ||
| 40 | + return { | ||
| 41 | + provide: ANGULAR_SPLIT_DEFAULT_OPTIONS, | ||
| 42 | + useFactory: (): AngularSplitDefaultOptions => ({ | ||
| 43 | + ...inject(ANGULAR_SPLIT_DEFAULT_OPTIONS, { skipSelf: true }), | ||
| 44 | + ...options, | ||
| 45 | + }), | ||
| 46 | + } | ||
| 47 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments