-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
When the mouse is on the grid, the container can't scroll #1926
Comments
So I had a look at the source code and found that there is an event binding on the $elm.bind('wheel mousewheel DomMouseScroll MozMousePixelScroll', function(evt) {
// use wheelDeltaY
evt.preventDefault();
...
}); Is there a reason why the grid needs to disable the browser's native scrolling? And if so, can I disable this? |
Yes it needs to catch those events so it can virtualize properly. That's
|
Oh, thanks for the clarification. What I'm wondering about is why it has to call |
Yes, this is also my issue. |
+1 |
+1 |
+1 |
In case it helps anyone, here's the code I added to fix this issue. It only prevents the page from scrolling when your mouse is in the grid and you haven't reached the top or bottom of the grid yet. I moved the evt.preventDefault() from here: $elm.bind('wheel mousewheel DomMouseScroll MozMousePixelScroll', function(evt) {
// use wheelDeltaY
evt.preventDefault();
...
}); to: $elm.bind('wheel mousewheel DomMouseScroll MozMousePixelScroll', function(evt) {
// use wheelDeltaY
var newEvent = GridUtil.normalizeWheelEvent(evt);
var args = { target: $elm };
if (newEvent.deltaY !== 0) {
var scrollYAmount = newEvent.deltaY * -120;
// Get the scroll percentage
var scrollYPercentage = (containerCtrl.viewport[0].scrollTop + scrollYAmount) / (rowContainer.getCanvasHeight() - rowContainer.getViewportHeight());
if ((newEvent.deltaY == -1 && scrollYPercentage < 1) || (newEvent.deltaY == 1 && scrollYPercentage > 0)) {
evt.preventDefault();
}
... |
@jraadt Thanks for this. I'll take a look at implementing it. I'd be curious how it will affect scrolling within subgrids. |
+1 |
I believe this is now resolved - could people verify? |
It seems that this has been partially fixed. When scrolling up, the page continues scrolling when the grid's scroller reaches the top which is good. But the same doesn't happen when the grid's scroller is at the bottom. See 102 Sorting |
Interesting. Grids with little data such as the 101 tut allow the page to scroll downwards, but not upwards. Grids with more data such as 102 sorting allow the page to scroll upwards (when reaching the end of the scroll), but not downwards. |
Thinking further on this, it could be the case that the grid decides whether to scroll itself or propagate to the parent based on how far through the grid scroll it currently is. If it's 100% and you scroll down, it propagates to the page. If you're at 0% and you scroll up, it propagates to the page. So, when you have a grid with less than a page of data, it's always at 100% scroll. So it won't propagate the scroll up to the page. And currently we have a miscalculation on the vertical scroll so that when you reach the end of the data, you're not at 100% scroll. So when you have more than a page of data, currently you maybe cannot get to 100% so that it propagates the scroll down to the parent. A theory at this stage, no more. |
I'm also getting this problem. I've set the grid to be as tall as needed. We don't want the grid to be scrolling, only the page as a whole. However, whenever the mouse is over the grid, it disabled the whole page scrolling even if the grid itself doesn't scroll any. |
OK, my theory on it not getting to 100% scroll is incorrect, it's a rendering glitch rather than a logic glitch. That is to say, the scroll bar on my Mac doesn't go all the way to the bottom, but if you look closely it's going all the way to the end of the scroll - perhaps it's leaving space for the horizontal to slide in underneath it? I can resolve the scrolling on a grid with little data (no scrollbars) by commenting out the EDIT: it does have an ill-effect - it makes the scrolling "janky" - and so when you scroll using mousewheel quite fast, you get a bit of parent scroll as well as grid scroll. But I can fix the small datasets in another way, by checking scrollTop, in or about the same line of code. But I still can't sort the scrolling off the bottom. It's not hitting the On a crazy hunch, I looked at the pinning tutorial. If you have a pinned left and a pinned right, it propagates fine. If only a body, it doesn't. More accurately, it works if you scroll over the container without a scrollbar - so if you have a right container, then scrolling on body or left container will propagate. If you have no right container, then only scrolling on the left container will propagate. I'm not sure I can fix this, as it's kinda weird. @swalters may have some ideas. But hopefully I've given some pointers to a diagnosis. I'll commit the change for small grids to scroll. |
+1 |
I also had this problem. I managed to fix it by adding 'ui.grid.autoResize' to my module declaration. Hope it helps. |
I was unable to scroll down when pagination was enabled (although I could scroll up just fine). As a workaround, I added a directive to my table element based off of alejandromagnorsky's solution as follows:
Scrolling down appears to work now. This was with version 3.0.7. |
I still has issue with 3.0.7 scroll doesnt work in chrome in Mac |
@shanet |
+1 on 3.1.1 |
Still it does not allow me to scroll till bottom of grid, |
Which directive did you modify ? Or can I unbind the events inside the |
@calebkiage This issue doesn't seem resolved so it should not be closed. |
+1 , |
+1 |
+1 |
+1 |
@alejandromagnorsky Thank you. You’re so helpful. |
this is my solution based on @alejandromagnorsky solution:
that way i dont need to add watchers,directives and extra code for every grid i add. |
I've tried unbinding the events as @avim101, @shanet, and @alejandromagnorsky suggested, but it simply doesn't work. Putting @avim101's example in my app config doesn't do it, and neither does just putting the I can comment out this line in the source and my grid scrolls perfectly, but of course I don't want to modify 3rd party source code. Anyone have any suggestions or hints regarding placement of the unbind within a regular controller? |
@ericsvendsen if you can add plunker / github repo we might help you to solve your problem |
@avim101 right, my bad. I created a test repository that exhibits this behavior: https://github.com/ericsvendsen/grid-test. I'm trying to unbind the events starting on line 209 of gridController. As I say in the readme and in the test app, unbinding seems to work for trackpads, but I can't make it work for mouse scrollwheels. As long as the cursor is over the grid, the page won't scroll down (the side nav should be long enough unless you're using a 4K monitor). Thanks for offering to have a look. |
@ericsvendsen
with
and you need to calculate grid height dynamically: |
@alejandromagnorsky solution worked for me. Thanks! BTW, I execute the code every time the screen is resized.
|
@avim101 your solution was perfectly clear and worked very well for me thank you ! 👍 |
@benjaminW78 glad it helped |
for 3.0.6 , I replaced the line on the ui-grid.js |
The ui-grid uses (3.1.1) an internal event ($destroy) to unbind all events. var callEventToUnbindMouseEventWhenScroll = function() { |
Using 3.2.9, wheel works up and down when the grid has enableFiltering set to true. |
I included 'gridUtil' in my directive and I went gridUtil.on.mousewheel = function() {}; It works. I dont allow scrolling within the datatable anyway. Is this (temporary) solution ok? am I missing something? My problem would occur when I changed paginationSize. |
The solution from @avim101 worked fine to me 👍 🎊 |
+1 |
Maybe this would help someone later: |
Hello, I have disable grid scrolling but when the mouse pointer is in the grid, the container cannot scroll. Any ideas on how I can disable this behavior?
The text was updated successfully, but these errors were encountered: