Vaadin23 IntegerField disable value change on mouse scroll button - vaadin

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(); })");

Related

Why OnHScrollChange is not fired in stringgrid in Firemonkey?

Why OnHScrollChange is not fired in stringgrid in Firemonkey? How should i catch the scrolling event in Stringgrid?
OnHScrollChange is fired when you scroll with the scrollbar thumbgrip or its buttons. It is however not fired by changing the selection with the left and right arrow keys, even if that would result in the thumbgrip of the scrollbar being moved.
If your question is about the latter situation, I kind of agree with you that it should trigger the OnHScrollChange, but then again, I have no idea of any design decisions. You may want to enter a report at Embarcadero's Quality Portal and see how they respond.
Another possibility is to use the OnViewportPositionChange event instead which fires however the viewport position changes. The caveat is that it fires also on vertical scrolling. If this is ok for you then that is your solution.

Click on a disabled Jquery UI Slider goes to top of page

When you click on a JQuery UI slider that is disabled and the page has been scrolled down, the page goes back to the top.
This is happening because the slider widget is implemented with an anchor tag containing an Href of #.
This is my hack solution.
$(".ui-slider-disabled").on("click",
".ui-slider-handle",
function () {return false;});
It works well but, is there a native (API) way to stop this?
How about this (you may need to change the class, depending on how you set it up)
$(".ui-slider").click(function(e){
e.stopPropagation()
});

How to prevent default cursor style in Dart, Dartium

I am trying to prevent the default cursor style for dragging in Dart. In the onDragStart method, I set the cursor style to 'move', and then revert back to the default in onDragEnd:
onDragStart(e) {
prevCursor = placeholder.style.cursor;
placeholder.style.cursor = 'move';
}
onDragEnd(e) {
placeholder.style.cursor = prevCursor;
}
When dragging, the cursor still defaults to the 'not-allowed' style. I have tried many methods to prevent this, such as preventing the default to onSelectStart in the onDragStart method, which was recommended as a fix for chromium in javascript, but does not work in Dart:
document.onSelectStart.listen( (e) {
e.preventDefault();
return false;
});
I have also tried setting the default in CSS, which is not how I would like to accomplish this, but it still doesn't work:
a:drag {
cursor:move;
}
Any suggestions?
Hmm...just a guess but maybe try to see if maybe you need to also handle onDragEnter?
The drop target sets the cursor icon to "not allowed", if its handlers canceled drag enter event etc.
Writing the handlers for the drop-zone is the easiest solution.
To circumvent the issue,a mouse down event, mouse move event and so on may be captured and used to move the element like I did here:Moving elements by dragging in Dart
This guy explains the related issue in more detail: http://mereskin.github.io/dnd/
Sort of irrelevant, but with some browsers only use the default cursor icon is available while dragging an element and there is no way to change that default.

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.

How to animate the opening and closing of collapsible objects with jquery mobile?

I'm using Jquery mobile and doing some custom stuff.
The default collapsible object just seems to 'show' the hidden content instantly, which I find a bit user unfriendly. A few problems occur with this in that if the button is at the bottom of the screen, and the hidden content is off screen, then the user might not know that anything has even happened.
In my mind two things should happen.
The content should slideDown().
I should have the option to have the page scroll down so that the button finds itself at the top of the screen, in doing so guaranteeing the the previously hidden content is visible.
Any pointers in how I might go about doing either of these?
If I understood you correctly you are talking about a collapsible content block and when a user taps on the header it should scroll down a bit so that the body part is shown to the user.
You can do it by attaching a click event to the header that triggers a scrolling. In the code below I have done it as an animation. I also have adjusted the scroll position with -40px so that the user still sees some part of the elements that are on top of the header.
$('.ui-collapsible-heading-collapsed').on('click.scrollintoview', function (event) {
$('body').animate({ scrollTop: $(event.target).offset().top - 40}, 500);
});

Resources