Closed jsBiztech closed 3 years ago
@nagdevbharat thanks for reporting! Could you please provide a reduced test case in e.g. codepen or codesandbox so people can tinker with the code and test what is the problem?
@niklasramo , Please find the stackblitz url: https://stackblitz.com/edit/ionic-mwjdis?file=pages/home/home.ts In this you can drag elements using the drag_indicator button. Try scrolling it outside the window and it should scroll the window but it does not.
@nagdevbharat in that demo the documentElement
and the body
element do not seem to be scrollable. I think you should target the .scroll-content
element instead of the window in this case.
I have tried with that and the error in console still comes and auto scroll is not working.
That error occurs because the elements you are trying to provide as the dragContainer
and autoscroll target are both null
. You can see it yourself if you log the results of your DOM queries just before this.layoutConfig
definition. E.g. add these lines after line 21:
console.log('dragContainer', document.querySelector('.drag-container'));
console.log('scrollTarget', document.getElementById('dragContainer'));
Muuri requires actual DOM element references to work. You need to figure out the correct place/time to query the DOM in the framework you are using to make sure the elements are actually rendered in the DOM before querying the DOM.
It is actually valid to provide null
as dragContainer (which is also the default value), but I'm guessing that's not the intention here.
Thank you for the guidance. I have done the necessary changes. Now in the console, it says scroll started and stopped but the scroll is not working. Can you please check what is wrong with this?
Are you sure the scrollable element you are targeting in autoScroll options is correct?
Yes, even the scroll start and scroll stop events are being logged in console.
Okay, after checking it out it seems that wrong scrollable element is targeted in the autoScroll options. You should target the .scroll-content
element within the drag container in your current setup.
You can easily validate the scrollability of the element in this case by running this code in console:
document.querySelector('#dragContainer').scrollTop = 100
(no scrolling happens)
vs
document.querySelector('.scroll-content').scrollTop = 100
(scrolling happens)
Thank you so much for your inputs. I have figured it out to impletment it as below:
@ViewChild(Content) content: Content;
targets: [
{
element: this.content.getScrollElement(),
priority: 1,
axis: Muuri.AutoScroller.AXIS_Y
}
]
Closing this. Thanks again!
When using auto-scroll with given configurations, it gives error of
element.getBoundingClientRect is not a function
.Config:
Error:
Environment: