草庐IT

data-events

全部标签

javascript - d3.event 在 debounced 函数中为 null

尝试使用mousemove事件处理程序的去抖动版本时,d3.event为null。我想在此去抖动处理程序中使用d3.mouse对象,但d3.event返回null并引发错误。如何在以下代码中访问d3.event://asimpledebouncefunctionfunctiondebounce(func,wait,immediate){vartimeout;returnfunction(){varcontext=this,args=arguments;varlater=function(){timeout=null;if(!immediate){func.apply(context,a

javascript - 猎犬.js : Transform the data returned by a remote source?

我正在使用带有远程API的Bloodhound,我需要转换从远程API返回的结果。APIURL是https://www.googleapis.com/books/v1/volumes?q=quilting它返回一个具有items属性的对象,该属性是一个列表。我需要将该列表返回给Typeahead,而不是顶级对象。Bloodhound文档说thereisatransformfunctionthatissupposedtodothis,但我无法让它工作。这是我的代码:varbooks=newBloodhound({datumTokenizer:function(d){returnBlood

javascript - Google Maps API data.setStyle 不在 map 上显示图标

我正在尝试使用GoogleMapsJSAPI创建一个小应用程序。我正在使用数据层从GeoJSON文件加载一堆点。该文件似乎正在正确加载,map正在显示,但在map.data.setstyle()中设置的图标不会显示...下面是我的HTML、CSS和JS。我已经看了2天了,但我不知道出了什么问题。提前致谢!HTMLCSShtml{height:100%}body{height:100%;margin:0;padding:0}#map-canvas{height:100%}JS$(document).ready(function(){varmap;functioninitialize(){

javascript - D3 数据映射 : OnClick Events on Bubbles

我正在关注数据map文档,我正在尝试为我在svg上呈现的气泡设置一个onClick监听器。现在,svgdiv具有以下子标签:....文档说对于map上列出的国家/地区,应该按以下方式完成:done:function(datamap){datamap.svg.selectAll('.datamaps-subunits').on('click',function(){alert("hello");});}这在尝试点击map上的特定区域时效果很好。尝试将相同的监听器附加到bubbles类没有任何效果..done:function(datamap){datamap.svg.selectAll(

javascript - Phaser JS 如何停止从 textButton.events.onInputDown 事件到 game.input.onDown 事件的事件传播(触发)?

这是JSFiddle.我这里有两个事件。game.input.onDown执行一些逻辑(在我的示例中生成粒子)是textButton.events.onInputDown,其中textButton是一个Phaser.Text对象实例,执行另一个逻辑。问题是:当我点击我的textButton时,这两个事件都被触发了1和2。问题是,当我点击textButton时,如何防止事件1触发?部分代码:...//Thiseventisfiredonclickanywhereevent#1game.input.onDown.add(particleBurst,this);//ThisisClickab

javascript - 使用 event.target.id 从 bind(this) 获取 id 时意外使用 'event' no-restricted-globals

此代码适用于Codepen:参见https://codepen.io/pkshreeman/pen/YQNPKB?editors=0010然而,我试图在我自己的“create-react-app”中使用它,并且“no-restricted-globals”的错误是由event.target.id触发的。有什么解决方法。除了使用事件目标之外,您如何从“this”中获取id?constElem=(props)=>{return(GoodMorning!{props.name}{props.last}Thisisphasethree{props.text}SecondButton);};cl

javascript - 如何从 dojo.data.ItemFileReadStore 检索值

首先,我在这里阅读了这个简短的帮助主题:CLICK它使用与PHP一起构建的JSON文件,看起来像这样:{name:'Italy',type:'country'},{name:'NorthAmerica',type:'continent',children:[{_reference:'Mexico'},{_reference:'Canada'},{_reference:'UnitedStatesofAmerica'}]},{name:'Mexico',type:'country',population:'108million',area:'1,972,550sqkm',children:

javascript - 跨浏览器替换使用event.layerX和event.layerY的方案

我正在尝试从一个使用Raphael的简单应用程序中改编一些代码,以允许用户在Canvas上绘制圆形和矩形。(原始代码在https://gist.github.com/673186)原始代码使用旧版本的jQuery并且运行良好。参见http://jsfiddle.net/GHZSd/但是,使用更新版本的jQuery会破坏示例。参见http://jsfiddle.net/GHZSd/1/这是因为新版本的jQuery中不再定义event.layerX和event.layerY。我的问题是-我可以使用什么代码来替换这些值?我只是通过做一些数学尝试了一些事情(event.originalEven

javascript - google.maps.event.addDomListener(window, 'load' , initialize); 的作用是什么?

我正在尝试使用Googlemap。我找到了这个声明。google.maps.event.addDomListener(window,'load',initialize);该语句的作用是什么? 最佳答案 它向window对象添加一个监听器,一旦触发load事件(即“页面已完成加载”),它就会执行函数初始化。即它会延迟与Googlemap相关的脚本,直到页面加载完成。 关于javascript-google.maps.event.addDomListener(window,'load',in

javascript - 仅使用 event.target 定位父对象?

HTML:CSS:#parent{background-color:blue;width:100%;height:100px;}#child{background-color:green;width:50%;height:inherit;}.myClass{background-color:red!important;}JS:functiondoSomething(){event.target.className=('myClass');}正如您在thisJSFIDDLE中看到的那样,在单击子项时,不是将该类应用于触发该功能的父项,而是将其应用于子项。我想知道如何避免这种情况并将其应用