Comments (10)
So basically the mouse position should be calculated based on the scrolling container instead of the absolute position on the screen. Is that possible?
At present, this isn't possible. I should be able to implement it, but probably not until >2 weeks from now.
from interact.js.
Here's a workaround that seems to work fine on everything except Internet Explorer.
var prevMouseMove = null;
interact(document)
// keep a reference to the most recent mouse move event
.on('mousemove', function (event) {
prevMouseMove = event;
})
.on('scroll', function () {
if (!interact.currentAction()) { return; }
// create a new event using the previous client and screen coordinates
// the page coordinates will be different because of the scroll
var e = prevMouseMove,
newEvent = document.createEvent('MouseEvents');
newEvent.initMouseEvent('mousemove', true, true, window,
-20, e.screenX, e.screenY, e.clientX, e.clientY,
e.ctrlKey, e.altKey, e.shiftKey, e.metaKey,
e.button, e.relatedTarget);
e.target.dispatchEvent(newEvent);
});
from interact.js.
You sir, are just awesome. Thanks so much.
It should work with IE >9 though, shouldn't it?
http://msdn.microsoft.com/en-us/library/ie/ff975292(v=vs.85).aspx
from interact.js.
You sir, are just awesome. Thanks so much.
You're very welcome. Thanks for helping me to make this project better.
It should work with IE >9 though, shouldn't it?
IE9 has this problem: http://connect.microsoft.com/IE/feedback/details/683322/initmouseevent-does-not-set-pagex-and-pagey-properties-in-ie9 which makes the dragged element get moved to (0, 0)
.
interact on IE10+ on Windows 8 uses pointer events instead of mouse and I think Microsoft forgot to implement a way to create PointerEvents. http://msdn.microsoft.com/en-us/library/ie/hh772109 - document.createEvent('PointerEvent')
isn't listed and throws an exception when called despite there being a PointerEvent#initPointerEvent
method.
I think IE10+ on Windows 7 should work since PointerEvents are avoided by interact due to the missing Gesture API (#17 (comment)).
from interact.js.
It turns out that you can create pointer and gesture events. They need the "MS" prefix to be created.
This code should work in IE10+ and other browsers:
var prevMove = null,
useGestureEvents = (window.MSGesture && window.MSGestureEvent);
interact(document)
// keep a reference to the most recent move event
.on(useGestureEvents? 'MSGestureChange': 'mousemove', function (event) {
prevMove = event;
})
.on('scroll', function () {
if (!interact.currentAction()) { return; }
// create a new event using the previous client and screen coordinates
// the page coordinates will be different because of the scroll
var e = prevMove,
newEvent;
if (useGestureEvents) {
newEvent = document.createEvent('MSGestureEvent');
newEvent.initGestureEvent('MSGestureChange', true, true, window,
-20, e.screenX, e.screenY, e.clientX, e.clientY,
e.offsetX, e.offsetY, e.translationX, e.translationY,
e.scale, e.expansion, e.rotation, e.velocityX, e.velocityY,
e.velocityExpansion, e.velocityAngular, e.hwTimestamp,
e.button, e.relatedTarget);
}
else {
newEvent = document.createEvent('MouseEvent');
newEvent.initMouseEvent('mousemove', true, true, window,
-20, e.screenX, e.screenY, e.clientX, e.clientY,
e.ctrlKey, e.altKey, e.shiftKey, e.metaKey,
e.button, e.relatedTarget);
}
e.target.dispatchEvent(newEvent);
});
from interact.js.
Implementing this is a lot more complicated than I expected and also might cause problems for some big changes that I'm working on. You'll have to stick with the above workaround as I don't think a proper fix is worthwhile. I might come back to this much later.
from interact.js.
Hi @taye I am facing similar issue as is mentioned above.
but the workaround does not seem to get fired or solve
When I drag a div and go outside the autoscroll container then the div does not follow the mouse pointed even though the container is scrolling
from interact.js.
I can't seem to get the scroll event to fire in 1.2.6. Is my setup incorrect?
interact(SchedulerDirectiveService.ACTIVITY_CLASS_DOT + ',' + SchedulerDirectiveService.SHIFT_CLASS_DOT)
.draggable({
onstart: dragStartListener,
onmove: dragOrMoveListener,
onend: dragEndListener,
autoScroll: {
container: $('.schedule-details')[0],
margin: 50,
distance: 5,
interval: 10
},
deltaSource: 'client',
snap: {
targets: [ $window.interact.createSnapGrid({
x: (cellWidth / SchedulerDirectiveService.SNAPS_PER_HOUR)
}) ]
}
})
.on('scroll', function () {
console.log('SCROLLING');
});
the console message never seems to happen. So I'm guessing I don't have my interactable setup properly. Any ideas?
from interact.js.
@scottfwalter interact.js doesn't fire scroll
events when autoScroll happens.
from interact.js.
so don't exist a fix for this problem at all??
from interact.js.
Related Issues (20)
- Missing TypeScript types (e.g. `styleCursor` option) HOT 1
- Issue on dropzones with 1.10.20 release HOT 7
- How to implement elements snapping to each other functionality? HOT 1
- @Interacrt/Interact cannot trigger the move event
- draggable and gesturable div, behavior lock with inertia
- Issue with Module Parsing in Project Using react-multi-crops HOT 3
- Vite production builds fail after v1.10.25
- TypeScript compile errors - version 1.10.26 HOT 4
- Resize modifier - wrong types HOT 1
- Gestures not working in ShadowDom
- Incompatible with Angular (v17) HOT 3
- New Snap syntax not working HOT 1
- Can't drag element when wrap drag item inside div HOT 1
- Restricting a drag with parent as origin. HOT 4
- Set snap on or off by user
- Demo Page down (https://interactjs.io/) HOT 1
- Is there a way to set the z-index of dropactive?
- interactjs.io is down
- mouseButtons typescript type definitions
- Web server is down (interactjs.io) HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from interact.js.