miguel-perez / smoothState.js

Unobtrusive page transitions with jQuery.
MIT License
4.43k stars 508 forks source link

Is there a way to differentiate a drag from a click? #382

Open pixelwatt opened 3 years ago

pixelwatt commented 3 years ago

Currently working on a project with tiny-slider being used to highlight a client's projects. Dragging is enabled on the slider so that slides can be navigated through by mouse drags. Only problem is that each draggable element is also a link, so upon completing the drag, the link-wrapped item that was initially clicked on for the drag is triggered. Any way to differentiate between clicks and drags on links?

albertomoreiraluiz commented 1 year ago

I know the answer is way overdue, however it might be of help to the next ones. You can try using the blacklist, that way the smoothstate will ignore that anchors. Something similar happened to me with my context menus, that isn't a valid link, then i add it to a blacklist on the smoothstate options.

$(function () {` 
     'use strict';
     var options = {
         prefetch: true,
         cacheLength: 10,
         blacklist: 'a[href="#"]',
         onStart: { }

[...]