mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
Liberalize type of d3.event. Addresses #4590.
This commit is contained in:
parent
066819c65f
commit
cf09bf76ce
@ -873,7 +873,7 @@ function populationPyramid() {
|
||||
// Allow the arrow keys to change the displayed year.
|
||||
window.focus();
|
||||
d3.select(window).on("keydown", function () {
|
||||
switch ((<any> d3.event).keyCode) {
|
||||
switch (d3.event.keyCode) {
|
||||
case 37: year = Math.max(year0, year - 10); break;
|
||||
case 39: year = Math.min(year1, year + 10); break;
|
||||
}
|
||||
@ -1291,12 +1291,12 @@ function forceDirectedVoronoi() {
|
||||
d3.select(window)
|
||||
.on("keydown", function() {
|
||||
// shift
|
||||
if((<any> d3.event).keyCode == 16) {
|
||||
if(d3.event.keyCode == 16) {
|
||||
zoomToAdd = false
|
||||
}
|
||||
|
||||
// s
|
||||
if((<any> d3.event).keyCode == 83) {
|
||||
if(d3.event.keyCode == 83) {
|
||||
simulate = !simulate
|
||||
if(simulate) {
|
||||
force.start()
|
||||
@ -2665,3 +2665,16 @@ function multiTest() {
|
||||
.attr("transform", "translate(0," + height + ")")
|
||||
.call(xAxis);
|
||||
}
|
||||
|
||||
function testD3Events () {
|
||||
d3.select('svg')
|
||||
.on('click', () => {
|
||||
var coords = [d3.event.pageX, d3.event.pageY];
|
||||
console.log("clicked", d3.event.target, "at " + coords);
|
||||
})
|
||||
.on('keypress', () => {
|
||||
if (d3.event.shiftKey) {
|
||||
console.log('shift + ' + d3.event.which);
|
||||
}
|
||||
});
|
||||
}
|
||||
8
d3/d3.d.ts
vendored
8
d3/d3.d.ts
vendored
@ -918,7 +918,13 @@ declare module d3 {
|
||||
}
|
||||
|
||||
/**
|
||||
* The current event's value. Use this variable in a handler registered with selection.on.
|
||||
* Interface for any and all d3 events.
|
||||
*/
|
||||
interface Event extends KeyboardEvent, MouseEvent {
|
||||
}
|
||||
|
||||
/**
|
||||
* The current event's value. Use this variable in a handler registered with `selection.on`.
|
||||
*/
|
||||
export var event: Event;
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user