-
Notifications
You must be signed in to change notification settings - Fork 202
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* feat: add `dblClickSpeed` init config (#1710) * chore: delete the configuration that was added by mistake * chore: remove redundant code
- Loading branch information
Showing
10 changed files
with
128 additions
and
20 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
import { Circle, Text } from '../../../packages/g'; | ||
|
||
export async function dblClick(context) { | ||
const { canvas } = context; | ||
await canvas.ready; | ||
|
||
let DELAY = 200; | ||
canvas.dblClickSpeed = DELAY; | ||
|
||
const circle0 = new Circle({ | ||
style: { | ||
cx: 100, | ||
cy: 100, | ||
r: 50, | ||
fill: 'red', | ||
cursor: 'pointer', | ||
}, | ||
}); | ||
const circle1 = new Circle({ | ||
style: { | ||
cx: 300, | ||
cy: 100, | ||
r: 50, | ||
fill: 'red', | ||
cursor: 'pointer', | ||
}, | ||
}); | ||
const circle2 = new Circle({ | ||
style: { | ||
cx: 500, | ||
cy: 100, | ||
r: 50, | ||
fill: 'red', | ||
cursor: 'pointer', | ||
}, | ||
}); | ||
const text0 = new Text({ | ||
style: { x: 0, y: 200, text: `current dblclick delay: ${DELAY}ms` }, | ||
}); | ||
const text1 = new Text({ | ||
style: { x: 0, y: 220, text: `action: ` }, | ||
}); | ||
|
||
circle0.addEventListener('mouseenter', () => { | ||
DELAY = 200; | ||
canvas.dblClickSpeed = DELAY; | ||
|
||
text0.attr({ text: `current dblclick delay: ${DELAY}ms` }); | ||
text1.attr({ | ||
text: `action: `, | ||
}); | ||
}); | ||
circle1.addEventListener('mouseenter', () => { | ||
DELAY = 500; | ||
canvas.dblClickSpeed = DELAY; | ||
|
||
text0.attr({ text: `current dblclick delay: ${DELAY}ms` }); | ||
text1.attr({ | ||
text: `action: `, | ||
}); | ||
}); | ||
circle2.addEventListener('mouseenter', () => { | ||
DELAY = 1000; | ||
canvas.dblClickSpeed = DELAY; | ||
|
||
text0.attr({ text: `current dblclick delay: ${DELAY}ms` }); | ||
text1.attr({ | ||
text: `action: `, | ||
}); | ||
}); | ||
|
||
canvas.addEventListener('click', (event) => { | ||
text1.attr({ | ||
text: `action: ${event.detail === 2 ? 'dblclick' : 'click'}`, | ||
}); | ||
}); | ||
|
||
canvas.appendChild(circle0); | ||
canvas.appendChild(circle1); | ||
canvas.appendChild(circle2); | ||
canvas.appendChild(text0); | ||
canvas.appendChild(text1); | ||
} |
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
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