jQuery Mobile swipe events not fire when using scrollview plugin - jquery-mobile

I use swipe events to change pages when swiping, that worked fine until using ScrollView plugin. I saw the help from jQuery Mobile: scrollview and swipe events but I don't know how to implement it now.
Any code snippets for me?
Thanks in advance.

You just need to comment out e.stopPropagation() in _handleDragStart function() to stop bubbling the parent events, like the JQM swipe events in your case.
OR you can disable according to condition, e.g., for vertical scrollbars, if you want to have swipeLeft and swipeRight events, use this
( this.options.direction == "y" ) ? "" : e.stopPropagation();
this should work.

Related

Vaadin23 IntegerField disable value change on mouse scroll button

Is it possible to disable the value change effect on the mouse scroll for the IntegerField component? If so, could you please show me how it is possible?
The scrolling behaviour comes from the browser and there isn't any direct feature for disabling it. It's still possible to do it with the workaround of listening to client-side scroll events on the element and preventing the default behaviour.
numberField.getElement().executeJs("this.focusElement.addEventListener('mousewheel', function(e) { e.preventDefault(); })");

unable to pause bootstrap carousel in slid or slide event

using the latest bootstrap 5 carousel, I am unable to pause the carousel from inside a slid or slide event.
const myCarouselEl = document.getElementById('carousel-large-background')
myCarouselEl.addEventListener('slid.bs.carousel', function() {
var carousel = new bootstrap.Carousel(myCarouselEl, {
interval: false
})
})
I have tried a variety of different solutions and am able to pause the carousel from the document.ready body, but not inside the slid or slide event.
I wonder if it might be a scope issue, and that the slid event handler has a different scope, but when I console.log(self) inside the event handler, it returns 'window'.
Any help gratefully accepted.
Cheers.
Any code relating to the bootstrap carousel should go inside a $(window).on('load'...) instead of $(document).ready(...)
otherwise any reference that you obtain to the carousel will be null, and calling methods will not work.

Jquery Mobile 1.3 slider conflicts with panel

I am trying to set up a JQuery Mobile 1.3 site that uses a panel and a slider.
Problem is, that using the slider triggers the panel, which opens on a "swiperight" event, as I am moving the slider to the right. The slider will be for pagination, the panel for a menu.
Code here:
http://jsfiddle.net/kMARn/1/
Move the slider to the right and the panel will open.
I have tried using the .not() selector for the panel to not react on the slider:
$(document).not("#slider").on("swiperight", function(event, ui) {
$("#myPanel").panel("open");
});
But it won't work, the panel opens when i move the slider to the right. Tried a bunch of variants too, but I'm lost...
Any ideas?
Thanks!
A bit late to the party, but you can disable swipe-to-close by setting the data-swipe-close attribute to "false" on the panel div.
http://jquerymobile.com/demos/1.3.0-beta.1/docs/panels/options.html
In my case I used this simple code, without data-swipe-close = "false" in panel.
Keeping panel close with swipe right, outside of the slider.
$('#panel').find('#slider')
.on('slidestop',function(e,ui) {
var value = e.target.value;
//...operations with slider value...
})
.parent().on('swiperight',function(e,ui) {
e.stopPropagation(); //block panel close
})
From the 1.3.0b1 Docs for Swipe:
"Triggers when a horizontal drag of 30px or more (and less than 75px
vertically) occurs within 1 second duration"
This applies to and can be configured for swiperight too. You can make the slider small in length and this would ensure that both the slider event stop and the swipe are not triggered at the same time, yet that may not be practical for all scenarios.
What might be better is to bind the swipe right to a DIV or section of the page. By this, I mean if you have a 75 px div box on the left hand side of the display, and when a swipe event occurred within that div, it could trigger the menu.
I feel the logic here might be better controlled by a button, much like used in the Facebook App to display there slide out menu. In the Dolphin browser on Android, this type of event also triggers a bookmark menu, so if a page has a swiperight event and trigger it, I sometimes get both the event and the bookmark menu from the App. Annoying!
I did fork your jsfiddle and will play with it more (http://jsfiddle.net/Twisty/Hg2pw/). FYI, they have JQM 1.3.0b1 in their available frameworks so you don't have to link it in your HTML. If I find some more info, I will comment here.
The following solution is more a workaround. It should be relatively reliable though.
$(document).ready( function () {
var menu_available = true;
$(document).on("swiperight", function(event, ui) {
if (menu_available) $("#myPanel").panel("open");
});
$("#slider").on("slidestop", function( event, ui ) {
menu_available = false;
window.setTimeout(function() {menu_available= true;},250);
});
});
The variable menu_available is false for a 250 milliseconds right after the slide stops. The window.setTimeout block will reset the variable so that the menu is available again.
This is a stupid workaround, but jQuerys function event.stopEventPropagation(), which IMHO would be the correct way to go, didn't work.

PhoneGap: How to use swipe gesture for images in html to make image gallery?

How to display image gallery when user swipe from left or right the images is changed accordingly?
is this possible with Phonegap to make iPad application.
Can any one give me hint for this??
<script>
$("ul").delegate("li", "swiperight", function() {
// The user has swiped to the right on a list view item. Show an edit menu.
//$(this).find(".menu-edit").show();//change here according to your need.
})
</script>
You can use one the many Carousel/Slide galleries that are out there. I have used the Carousel from Bootstrap http://twitter.github.com/bootstrap/javascript.html#carousel and it is good.
You can then combine this with jQuery Mobile events which #vikky has mentioned. This provides swipeleft and swiperight which you can use to trigger the next/previous methods on the Carousel you choose.
http://jquerymobile.com/demos/1.1.0/docs/api/events.html

jQuery Mobile: scrollview and swipe events

I have a basic JQM page which displays a left side sliding menu when swiping (like the facebook mobile app). It worked fine until I started using scrollview (to properly keep the header fixed). The swipe event is not triggered when I swipe over my page content (it still works if I swipe on the header).
$('.ui-page-active').live("swiperight", function() {
if (!menuStatus) {
showMenu();
}
});
Does anyone has any idea on how to make it work?
Cheers!
I think you might find that the event is consumed in the scrollview control. You can override the javascript handler against that control to allow it to keep bubbling.
To override the function you can use this technique: Overriding a JavaScript function while referencing the original
Having a quick look at the file, it looks like this method could hold clues as to what you want:
_handleDragMove: function(e, ex, ey)
specifically:
var svdir = this.options.direction;
if (!this._directionLock)
I was using the version of scrollview shown here: http://jquerymobile.com/test/experiments/scrollview/scrollview-nested.html

Resources