Layered elements firing 2 events with one touch - Angular - javascript

I'm using angular for a mobile web project. I have a basic share button, when clicked a share modal pops up. The share modal's Close button lays on top of (higher z-index) the actual share button. The share modal is generated from external HTML so I cannot use an ng-click directive. As a work around I use the following:
document.querySelector('#shareContent .shareClose').addEventListener('touchend', function( e ){
e.stopPropagation();
$scope.$apply(function(){
$scope.showShareOverlay = false;
})
console.log("closing the share", $scope.showShareOverlay)
})
My issue is that when I touchend the .shareClose button, the modal closes for a brief moment before showing again. Somehow the touch event is being transferred to the below share button to launch the modal again. Is there anyway to prevent the event from bleeding through to the share button?

I had a similar issue with the Android stock browser. Whatever was underneath the close button for my modal would also get clicked shortly after tapping the close button.
Using the fastclick library on the app stopped this behaviour from happening, presumably due to the specific way it handles click events.

Related

iOS buttons in overlays fire additional clicks on elements below the overlay

I am facing a strange problem on iOS devices.
When clicking on buttons/links in an overlaying container, the element below fires also a click event. I have a "filter" button that opens an overlaying div with all the filter options. The closing button on the overlay is located directly over the button, that triggers the overlay. When I click on the close button, the overlay closes, and with a small delay, a click on the filter button is executed again and opens the overlay.
This also happend when I build my mobile menu, where I had a burger button on the top right which opens my mobile menu. The closing button was located where the burger button was. When clicking on the closing button, the click on the burger button is executed again and opens the menu.
I tried to bind a stopImmediatePropagation() to the buttons, but this doesn't work out. This only happens on iOS, Android and Desktop is fine. The functionality of the overlays comes from my used e-commerce system (Shopware 6). It is not only happening with buttons, but with other elements like divs and spans with a functionality to hide/close overlays.
Any ideas how to get rid of this?
Best regards,
Alex
I could solve it with fastclick.js
https://github.com/ftlabs/fastclick
Not what is designed for, but fortunately it solved the click issue on iOS.

Firing a function on link click (Seems to work, but not on a popup)

Trying to fire a custom facebook pixel event clicking to an external link (So I can track the analytics of customers going to an external link). I have a function that does work, and I have that attached to a normal link.
Works great on the normal website using onclick="function();" method, but I can't seem to get it working on a popup. I don't have full ability on the popup plugin I am using to modify the HTML around the link, but I can implement Javascript / Jquery on start of the page.
Was hoping there may be an overall method so that all link clicks will fire the event, and it's applied to all links after a delay (giving time for the popup to load.)
You can just listen for clicks on all buttons and a elements:
document.querySelectorAll("a, button").forEach(e => e.addEventListener("click", customEventHandler));

How to keep popover opened in safari extension

For a project I'm building an safari extension. One part of the extension contains the popover part.
When someone clicks the extension toolbar button, a popover window scrolls down to display some information.
This is working as expected but now the following:
The plan is to make some sort of companion popover, so when the user clicks inside a webpage, some elements are selected and displayed in the popover.
The problem is the popover closes when one clicks next to the popover window while it should be left open.
Does anybody know a way to keep the popover window open while browsing pages?
There is a function on the window object:
window.onblur
Which fires an event when the popover closes. Is there a way to cancel the closing operation?

jQuery divert mouse click from VNC to modal

I have created one page, in which on right clicking on some button a modal appears.
When I right click on the modal it doesn't seem to work.
So far, what I got to know is, the mouse click is taken by the UI control which comes underneath that modal and listening to all mouse events and that UI control VNC.
I can click on the part of the modal, which is not above that control.
Is there any way I can force modal to take all mouse events when in focus?
What I want to do is just right click and copy the text from that modal.
Thanks in advance,
Regards,
Ganesh
Just called RFB's _rfb.get_keyboard().ungrab() method when modal is shown and was pretty done.

Add some hooks to Twitter Bootstrap's modal dialog

I have a video inside a modal, which can be opened through many links across the page.
The problem is, when I close the modal with the video running, I can still hear the video... which makes sense, but I don't want it.
Is there a way to implement a hook in Bootstrap's events, like modal? Some event or other thing that allow me to stop the video when the modal is closed.
Handle either hide or hidden event* which modal is triggering before and after close respectively.
$('#myModal').on('hidden', function () {
// stop the video playback
});
*Here are all supported events and methods.

Categories

Resources