dom-events

FabricJS - Preserve events on saving / getting canvas from JSON

孤街浪徒 提交于 2021-02-19 06:27:04
问题 Is there a way to "preserve" events when saving canvas to JSON and then get them bonded back on loadFromJSON In the link below I've created an element redBox and bonded an event "moving" on it. After "restoring" canvas from JSON that event no longer available and it makes sense why... The problem is, based on requirements, I have no idea what element could be in the JSON and what event was previously applied to it. Basically, I need dynamically apply all possible events on that particular

Delaying default events in Javascript

旧街凉风 提交于 2021-02-19 04:37:10
问题 I would like to be able to delay the default action of an event until some other action has been taken. What it's for: I'm trying to build a reusable, unobtrusive way to confirm actions with a modal-type dialogue. The key wishlist item is that any Javascript handlers are attached by a script, and not written directly inline. To make this truly reusable, I want to use it on different types of items: html links, checkboxes, and even other Javascript-driven actions. And for purely HTML elements

Delay React onMouseOver event

社会主义新天地 提交于 2021-02-18 12:41:14
问题 I have a list of elements, when hovering one of these, I'd like to change my state. <ListElement onMouseOver={() => this.setState({data})}>Data</ListElement> Unfortunately, if I move my mouse over the list, my state changes several times in a quick succession. I'd like to delay the change on state, so that it waits like half a second before being fired. Is there a way to do so? 回答1: Here's a way you can delay your event by 500ms using a combination of onMouseEnter , onMouseLeave , and

Bluetooth headphones button event detection in javascript

风格不统一 提交于 2021-02-18 11:25:37
问题 I am building a web app where I detect the headphones button event. I succeeded in capturing headphones button event when they are plugged in. Now I am trying to capture Bluetooth headphones next button event. Any help on this please? Code for headphone button detection. document.addEventListener('volumeupbutton', () => { //Do something here }, false); I need something similar to this. 回答1: You can use keydown and keyup events for implementing the long press functionality. // Imprementation

Event listeners with arguments

空扰寡人 提交于 2021-02-13 17:36:46
问题 I want to pass arguments to an event listener in Javascript. I have found solutions however I cannot understand why or how they work and why other solutions do not work. I have a C/C++ background, however in Javascript functions perform a lot different. Could you please help me understand how and why the following examples work or not work? Without parameters the code works fine: var clicker = document.getElementById("mainNavToggle"); clicker.addEventListener("click", eventFunction); function

Move dynamically created SVG with mouse

限于喜欢 提交于 2021-02-11 13:53:36
问题 I'm pretty new to HTML and JS, but I'm trying to learn some of the basics. Now I'm experimenting with graphics. I'm trying to create two svg elements dynamically with JS and then move them individually with the mouse. I'm able to create them, and register the mouse events on them individually, but can't get them to move. To try to move there positions, in my dragging() function I assign the svg style.top and style.left to the value of the pointer. I can confirm in the JS console that the

How to share data between browser tabs?

烂漫一生 提交于 2021-02-10 15:56:06
问题 I have to develop a program where I need to get the event from server and want to update the web page. e.g. I have multiple browser tab opened for chat and each chat page have its own thread to fetch the event from the server but once the one thread among the chat will fetch the event than other get empty stack of event due to extract by the another Chat page. So, here my concern is to share event with multiple chat pages without refreshing the page. 回答1: Sound like you could use postMessage

How to share data between browser tabs?

久未见 提交于 2021-02-10 15:55:00
问题 I have to develop a program where I need to get the event from server and want to update the web page. e.g. I have multiple browser tab opened for chat and each chat page have its own thread to fetch the event from the server but once the one thread among the chat will fetch the event than other get empty stack of event due to extract by the another Chat page. So, here my concern is to share event with multiple chat pages without refreshing the page. 回答1: Sound like you could use postMessage

How to share data between browser tabs?

给你一囗甜甜゛ 提交于 2021-02-10 15:54:07
问题 I have to develop a program where I need to get the event from server and want to update the web page. e.g. I have multiple browser tab opened for chat and each chat page have its own thread to fetch the event from the server but once the one thread among the chat will fetch the event than other get empty stack of event due to extract by the another Chat page. So, here my concern is to share event with multiple chat pages without refreshing the page. 回答1: Sound like you could use postMessage

How to make SHDocVw.InternetExplorer fire events that get caught with JS addEventListener?

拈花ヽ惹草 提交于 2021-02-10 04:15:54
问题 The following problems: I need to simulate a double-click on a div element. I need to use/handle MS Internet Explorer 11. I cannot change the source code of the target site. My solution so far: I use C# and SHDocVw.InternetExplorer and mshtml I can fire "click" events al right, they show up in all handlers When trying to simulate the double-click: the "ondoubleclick" event gets triggered. the el.addEventListener('dblclick', handler); does NOT get triggered To reduce the complexity of the