-
Notifications
You must be signed in to change notification settings - Fork 207
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(g-svg): event should work when matrix is applied, close #428
- Loading branch information
1 parent
e4effb3
commit a74f1d8
Showing
5 changed files
with
79 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// const expect = require('chai').expect; | ||
// import Canvas from '../../src/canvas'; | ||
// import { simulateMouseEvent, getClientPoint } from '../util'; | ||
|
||
// const dom = document.createElement('div'); | ||
// document.body.appendChild(dom); | ||
// dom.id = 'c1'; | ||
|
||
// describe('#428', () => { | ||
// const canvas = new Canvas({ | ||
// container: dom, | ||
// width: 400, | ||
// height: 400, | ||
// }); | ||
|
||
// const el = canvas.get('el'); | ||
|
||
// it('event should work when matrix is applied', () => { | ||
// const group = canvas.addGroup(); | ||
// const circle = group.addShape('circle', { | ||
// attrs: { | ||
// x: 100, | ||
// y: 100, | ||
// r: 50, | ||
// fill: 'red', | ||
// }, | ||
// }); | ||
// circle.translate(100, 0); | ||
|
||
// let clickCalled = false; | ||
// circle.on('click', () => { | ||
// clickCalled = true; | ||
// }); | ||
|
||
// const { clientX, clientY } = getClientPoint(canvas, 200, 100); | ||
// simulateMouseEvent(el, 'mousedown', { | ||
// clientX, | ||
// clientY, | ||
// }); | ||
// simulateMouseEvent(el, 'mouseup', { | ||
// clientX, | ||
// clientY, | ||
// }); | ||
// expect(clickCalled).eqls(true); | ||
// }); | ||
// }); |
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,12 @@ | ||
export function simulateMouseEvent(dom, type, cfg) { | ||
const event = new MouseEvent(type, cfg); | ||
dom.dispatchEvent(event); | ||
} | ||
|
||
export function getClientPoint(canvas, x, y) { | ||
const point = canvas.getClientByPoint(x, y); | ||
return { | ||
clientX: point.x, | ||
clientY: point.y, | ||
}; | ||
} |