jQuery UI Draggable div sticks to mouse - javascript

I am using a div as a popup which is draggable as follows
$("#popup").draggable();
The problem is if we mouseclick on this div and leave the click, then the div sticks to the mouse in some IE versions, especially on Windows 7. The div moves with the mouse even if its not click & drag action (its just a mouseover action). Please let me know if this is jQuery bug or some OS/browser bug with proper solution?
I am using jquery-ui-1.8.6 js with jquery-1.4.2 js.

i will recommend you to use the latest versions of both jquery-ui and jquery library file..
the code you provide has not much enough to be debate about but as you mentioned, it could be because of the older version of files.
i am using latest versions of both files (jquery-ui-1.8.21/jquery-1.7.1) and dragging is working fine in all ie versions.
but when you are using iframes, things went little different. because some browsers specially ie handles iframes differently, i might be guessing but it could be the case! :)

Related

Prevent 'select' input on iOS 15 Safari from hiding and showing address bar?

This is really curious. Interacting with select inputs seems to hide/show address bar based on 'perceived scrolling' by the browser.
I understand the behavior for normal content related page scroll, but it doesn't make sense for the address bar to hide/show based on scroll direction when a select input is being interacted with. This is on ios 15.x and while the example below is on an emulator, the original 'bug' was caught on an actual ios device.
Changing scroll position via JS seemingly does nothing in this case, nor does updating overscroll-behavior or touch-action css attributes on the dom elements.
Here's the behavior in question:
Looks like it is a bug in the iOS 15+ on Safari. There is no issue like that on Chrome.
Nevertheless I've found a workaround for this.
I've made an example, you can test it here. Just open the link on your iOS device. You can find a git repository with the example on my GitHub.
It is not a good practice, it is just a workaround, so there is your choice whether use it or not.
Also, just for your information: I've discussed with other developers who close to me and we have agreed that it is not very good practise to have scrollable element inside scrollable page. On other platforms also might happen some not predictable glitches. it is better to have another UI elements for that if possible.

CSS & JQuery browser compatibility

So I've been working on browser compatibility. Unfortunately, when I first designed my site, I desigend the CSS aesthetically for Firefox only. Now I'm having all sorts of trouble trying to get it to look good in the other major browsers. However, when I fix the CSS positioning such as floating a box object to the right, IE8 forces it left. I checked my code on W3C and it's okay semantically. I use little to no javascript. It's a portfolio website. The screensize shifts everything around no matter what browser, yet there is no perfect CSS for this so how does one get things to stay in place? I'm not too familiar with JQuery, but this seems to be the closest I can get to an answer. Where would I plug this into my site to see if this works?

Any drawbacks of using Hammer.js on desktop browsers?

I have started to use Hammer.js to implement drag functionality for mobile browsers. I have noticed that this functionality also works on desktop browsers (which is confirmed by this compatibility table https://github.com/EightMedia/hammer.js/wiki/Compatibility ).
Are there any drawbacks of using Hammer.js for desktop browsers as well?
As an example; let's say I want to implement a scrollbar (from scratch) where the "thumb" can be dragged. Instead of implementing this using onmousedown/up, onmousemove and set/release mousecapture I can simply use the dragstart, drag and dragend events of Hammer.js.
Hammer.js does a pretty good job on detecting whether it is running on a multitouch enabled system or not.
In most cases it also works pretty well when you have both, a mouse and a touch display. We are developing a desktop web-application based on hammer.js, which should work both, with mouse and multitouch interaction and it mostly works fine. However, it seems that this scenario is not as well tested as the use on mobile devices. See for example this open bug, when hammer.js triggers a tap event twice on Chrome (https://github.com/EightMedia/hammer.js/issues/302) which got closed in between, because no activity was detected.
Note also, that it is often needed to fine tune the behaviour of hammer.js, by fiddling with the user_select, user_drag and prevent_default parameters (see for example this question ). On Google Chrome we also had to enable the experimental touch-actions : none. I do not know, how much of this is specific to desktop systems though.
Summary
Hammer.js is written with desktop systems in mind and does quite a good job in providing sensible behaviour on both mouse and touch based systems. In detail it requires sometime fine tuning to make everything work as expected.

Creating a "sticky" fixed-position item that works on iOS Safari

On iOS safari, one-finger panning doesn’t generate any events until the user stops panning. An onscroll event is only generated when the page stops moving and redrawn.
I need a way to detect real time scrolling. Specifically, I want to make a sticky menu that will also work on iOS safari. On non-mobile browsers, sticky menu can be done by switching between "position relative" to "position fixed" on the element while listening to the onscroll events. This method won't work on mobile browser because onscroll events are not continuously fired. What can I do?
Answering my own question. iOS7 now support position:sticky
Demo: http://html5-demos.appspot.com/static/css/sticky.html
I've recently spent many hours trying to come up with a practical solution for the same problem. There's no right way to do this, although there are a few decent hacks (most of them mentioned already). The problem is that JavaScript is paused while the user is scrolling. It makes sense when you consider the implications, but it makes it damn hard to implement fixed positioned element.
The best thing that I've been able to find is this wonderful post by the folks at Google. You can check out http://gmail.com in mobile safari to see it in action.
https://developers.google.com/mobile/articles/webapp_fixed_ui
Hope this helps.
I had a similar issue and bound handlers to touchstart/touchmove/touchend using jquery to detect the single finger scrolling and it worked perfectly. In my case I needed to move another element the same amount as the attempted move of another element and it updated nicely as the scroll was attempted so it ought to be suitable for your requirement.
If all you want is a sticky menu, you can save yourself some headaches by using an existing library. I've had success with iScroll:
http://cubiq.org/iscroll
At the very least, you can take a look at how this works and base your solution around that.
Happy hacking!
Old topic for sure, but I can see alot of visits here. If all you want, is a sticky menu, you can use fixed positioning. No need for iScroll there.

JavaScript: Capturing right click and disabling menu only within certain element

I have coded a jquery script where there is a small grid on screen and using drag and drop users can place tiles on the grid (snaps in place). Currently if you hover over a tile it fades in the option to rotate, but I would much prefer it if you could right click to rotate (making it more natural). I understand blocking right click completely is often frowned upon so was wondering if it was possible just within a particular element, then capturing that event, doing something in JS and disabling the context menu? - that works in every browser.
On a side note, currently I am using jQuery for effects and custom javascript for drag and drop, is it worth looking at a jQuery plugin for drag and drop?
Many thanks,
For capturing the right click, you can use this jquery:
$('#gridID').bind('contextmenu', function(e) {
// do stuff here instead of normal context menu
return false;
});
This works in chrome, firefox, and safari. Haven't tested IE. Works in IE too. Only caveat is it doesn't work in Opera apparently. So if you can live with that...
I'm not a fan of using the right mouse button on web pages. However, if you really want to do it, you could trap the right mouse button as described here. You could block the right mouse button (in other words return false in your event handler) conditionally if the mouse is over your grid cells.
Regarding your bonus question: jquery ui has drag & drop functionality. It's probably easier to use that than rolling your own.
"is it worth looking at a jQuery plugin for drag and drop?"
Only if you don't intend your application to be used on the iPhone O.S with safari, i.e. including iPad, see Safari Web Content Guide: Handling Events

Categories

Resources