-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Links in sliders aren't working - Error in the latest version of Chrome (73.0.3683.75) #1240
Comments
Same issue. Set Update: check this #1240 (comment) |
Same issue. |
Replace this: if (slider.settings.touchEnabled && !slider.settings.ticker) { initTouch(); } With this: if (navigator.maxTouchPoints > 0) { initTouch(); } This should detect if the device viewing the slideshow has a touch screen before loading support for touch. Note: setting touchEnabled to false didn't work for me and it also turns off all touch support. |
But now you can't swipe images by mouse. It seems we have to choose now - clicking or swiping in newest Chrome. Not both 😕 |
Accorrding to information written above, a have added to initial options of all my sliders next code: touchEnabled : (navigator.maxTouchPoints > 0) - that enable swipe functions on mobile devices and prevent using mouse swipe for desctop browser |
Still can't click on chrome mobile... |
Same here with Chrome 73.0.3683.86 (Official Build) (64 bits) |
Same here. touchEnabled: false seems to fix this on desktop though. |
Getting the following 'Violation' from the console...
But if you try adding For more info |
I have created a code pen with a link in the first slider that shows this problem (link can't be clicked in latest Chrome): |
Adding this disables touch support in iPhone too! |
What I have found is that if you put the link as a first child inside the slide and you have only one link there, then it works just fine with the original setting. Sometimes you have to click twice but both on desktop and phone the link works in the latest Chrome - see http://newhow.archi/ :-) |
@vsindylek That's not going to help me, we have dynamic content inside slides coming from CMS. |
The problem in Chrome seems to be related to use of setPointerCapture() in bxslider. When I comment out the following snippet in jquery.bxslider.js links start working in Chrome and touch capabilities are also preserved both on desktop and mobile.
But this is not a perfect solution since if you drag slides with mouse on desktop Chrome and your mouse moves outside slider boundary you may end up seeing parts of two slides at the same time. |
For me this seems to fix the issue. |
@haseebtirur Be careful with that, you will loose touch functionality on iPhone since Safari doesn't support maxTouchPoints. See browser support for it here: https://developer.mozilla.org/en-US/docs/Web/API/Navigator/maxTouchPoints |
I might have found a reliable fix for this. The problem happens in Chrome because it doesn't fire a click event after pointerup unlike other browsers such as Firefox. This is because bxslider in onTouchStart function sets slider viewport as target of all succeeding pointer events. Now if you have a link inside a slide when you click the link the target of pointerdown is not slider viewport, but the link content and since this target is different from pointerup target (which is slider viewport), then Chrome doesn't fire a click. The solution is to make sure pointerup fires on the same element as pointerdown so that Chrome fires a click. So we need to refactor this snippet:
to this:
This solved the problem for me in Chrome without loss of any functionality in any browser or mobile device. |
I tried this solution and tested on mobile (iphone X with chrome) and I cannot slide left or right. On Desktop, when I slide right or left, the click event is fired automatically. |
@lorguzman I just installed Google Chrome on iOS 12.1.2 and sliding works, but I have noticed issues in Edge/IE11, so this solution is still not good enough. |
Just tested this on Chrome 74.0.3729.28 with the patch applied from above. |
@smohadjer 's possible solution above didn't cover all the bases for me. Links were not clickable in Safari on iPhone X, iPad Pro, iPad Air... so on. Tested in BrowserStack. Although I appreciate his work so thank you for that suggestion. Outside of doing a bunch of conditional checking for user agents which still isn't super reliable or checking for like modernizr.touch which also isn't great. I have decided to just disable touch for right now and try to buy some time to keep poking at this or hopefully someone smarter than me finds the solution. |
@SpatialAnomaly I wouldn't rely on BrowserStack, I tested on actual devices (both iOS and Android phones) and links worked there, but as I said IE11/Edge have problem with this, so we need a better solution. For now I'm going to use my very first suggestion and simply comment out the line with setPointerCapture(). Did you try that or have any problem with it? |
Hi Guys, Here is the workaround I found: First of all you need to move the "slider.hasMove = true;" to different location, so your code in the onTouchMove function needs to be something like this:
And now the code is already there for the click to work just for some reason Chrome doesn't trigger the click element trough jQuery (didn't dig any further just for this) but it does work with the vanila click method in the onTouchEnd like this:
I used try and catch as they say this click method is not that supported on android so in that case we fall back to the original jquery method. I tested this on Chrome, Firefox, Android and seems to be working just fine without breaking anything. Regards, |
Tried the fix as suggested Julius and now swiping on firefox desktop opens the link on swipe. |
I know it's not a good solution, but BxSlider 4.2.1 works fine with the latest version of Chrome as far as I tested. |
@keiichi-takio Did you test this on any mobile platforms as well? |
Actually I rolled back to v4.1.2 and it seems to be working for the most part. Not the greatest, and also not 100% sure why that would be ok versus a later version. |
Also had to roll back to 4.1.2. Sadly, I hope soon we will find a better solution |
In some cases, for example, when using a system like Wordpress or any plugin that does not have direct access to its code, the following code can be added as a temporary solution.
|
I've been used "onclick" instead of href and It has worked for now. For the navigation I did something like that: $('#infoPrev').click(function(event) { |
I've hated to do this, but for the sake of usability, for now, I've abandoned BXslider and have switched to Swiper. |
Easy Solution (bxSlider v4.2.12) PROBLEM: SOLUTION DONE |
Omg, thank you. Couldn't for the life of me figure out what was going on and tried different solutions proposed all over the internet. This one seems to be working both on mobile and in chrome. Thanks a ton |
Another go at a fix – works for me: Replace
This enables tapping on links while keepint the touch behaviour. |
mcnolsen is very good answer, make it correct answer for this |
@philsav that solution - originally provided by @smohadjer - was later confirmed as not working in certain cases so I'd be careful with this. I've since abandoned bxSlider in favour of Slick in case anyone is looking for alternatives. |
Slick is nice, but I think swiper provides the robustness that bx had in the past. a little more bulk, but I foujnd that robustness has helped. |
I started with Swiper (at least in part due to your recommendation back in October) but had problems getting the carousel to work so I switched to Slick. But.... since you posted again (and Slick's touch support seemed a little flaky) I've switched back to Swiper and all is now working. So thanks for making me reconsider! |
This worked for me. Thanks. |
Can someone share a JS file that works? With all the fixes? I don't want to edit the code myself. |
Try this version, we modded it last Oct and have had no complaints yet, thats about 1M users of our WP plugin. |
I dont think that has the function for |
This is the version that is working for me. Thanks. |
Since my last solution stopped working in Chrome 80, I need to expand it a little:
|
can confirm that this has solved my problem (for now anyway) |
Links in Chrome featured slider posts not working although ok with other browsers. |
@charr88 We'd need to know more about your environment to answer that. Sounds like it's probably a CMS of some kind, Wordpress, Concrete5, Joomla... etc. Which theme package? |
I am using Wordpress 5.4.2 with Theme Junkie's Postboard - and have check that the Chrome version (on Windows 10) is the latest. |
I wrap my link text minimum with an But not on touche devices. Additional I add |
If someone also has a problem that the slider on the last slide jumps sharply from the first to the last, then please use this example to fix this problem, and this also solves the problem of non-clickability. if( ! e.target.href ) { if (e.type !== 'touchstart' && e.button !== 0) { |
Just wanted to leave a note that in Dec 2020 we had this problem come back despite applying other fixes that worked in the past. The symptoms were on desktop as follows: You can swipe the carousel left or right with a mouse, but clicking on any carousel item would ignore the click. We applied the fix here: https://github.com/stevenwanderski/bxslider-4/pull/1255/files And can confirm it restored the ability to left click on carousel items. I tested the fix on Chrome Version 87.0.4280.88. It also works fine in Edge Version 87.0.664.66 and Firefox 84.0, although in Desktop Firefox the swipe functionality does not work. All tests were done in Desktop. I hope the same fix helps others. |
Just replace following line: With this code: |
Another solution I've found is to change line 1096 - 1100 from this:
to this:
|
Hello, Thanks |
thanks |
For version v4.2.1d just add this in your jquery.bxslider.js: |
stevenwanderski#1109 remove e.preventDefault(); to fix click on link in slider + mobile + chrome solution for stevenwanderski#1240
This works for me, is force the link event after touch. $('.bxslider').on('touchend', function(event) { |
jquery.bxslider.js -> onTouchStart -> slider.viewport.get (0) .setPointerCapture (slider.pointerId);
Link (a tag) does not work due to source
The text was updated successfully, but these errors were encountered: