question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Disabling click/touch on certain elements

See original GitHub issue

I’ve added a scrubber and using it like so:

scrubber.onValueChanged = function (value) {
  gallery.goTo(value);
};
gallery.listen('afterChange', function() { scrubber.value(gallery.getCurrentIndex()); });
gallery.listen('close', function() { $('.pswp__scrubber').empty(); });

… it seems to work well except that when I’m interacting with the scrubber, PS slides the images. How do I disable slide/drag only on the .pswp__scrubber element?

I tried this, but the slides still “shake” when I use the scrubber:

gallery.listen('preventDragEvent', function(e, isDown, preventObj) {
    if ( $(".thumb.dragging") ) {
        console.log(1);    
        isDown = false;
        preventObj.prevent = true;
    }
});

(the scrubber handle has class dragging while its being used)

EDIT:

Also tried:

gallery.listen('preventDragEvent', function(e, isDown, preventObj) {
    if (e.target.className === "scrubber" || e.target.className === "track" || e.target.className === "thumb" ) {
        isDown = false;
        preventObj.prevent = true;
        console.log(e.target.className);
    }
});

… but its the same.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
dimsemenovcommented, Nov 11, 2022

@namespace-dave yep, that’s correct, I was typing the same thing before I saw your edit

0reactions
davegreenwpcommented, Nov 11, 2022

@dimsemenov do you have an example for the best approach to unbind pointerdown from .pswp__scroll-wrap ?

UPDATE:

If you are looking to prevent the pointerDown event from firing on specific elements contained within the .pswp__scroll-wrap element. you can do this using the custom pointerDown event hat is dispatched on the scroll wrap; see here .

If you add an event listener for that custom event, carry out a check, and then event.preventDefault() it will work as desired.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to disable / re-enable all click/touch/mouse events on an ...
When a certain link in the parent element is clicked, I'm trying to fade it 50% and disable any further interaction with it...
Read more >
How to Disable Force Click on MacBook Trackpads - OSXDaily
Turning Off Force Click (3D Touch) on Mac TrackPad ... use a firm click when selecting and clicking items as they use the...
Read more >
How to Enable or disable context menu items in Angular ...
You can enable and disable the menu items using the enableItems method in ContextMenu. To enable menuItems, set the enable property in argument...
Read more >
Customize the Touch Bar on Mac - Apple Support
For some apps, you can customize the Touch Bar so that it contains buttons ... click Keyboard in the sidebar, then click Touch...
Read more >
Enhancing The Clickable Area Size - Ahmad Shadeed
The idea is that a pseudo element belongs to its parent, so when we create one with a specific width and height, it...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found