mastering_openlayers3
mastering_openlayers3 copied to clipboard
Uncaught TypeError: this.scrollTo is not a function
I just noticed that I get this error when editing a layer name.
layerSpan.addEventListener('blur', function () {
if (this.contentEditable) {
this.contentEditable = false;
layerDiv.draggable = true;
layer.set('name', this.textContent);
layerDiv.classList.add('ol-unselectable');
layerDiv.title = this.textContent;
this.scrollTo(0, 0);
}
});
The error occurs on the this.scrollTo(0, 0) line.
I tried googling but everything I'm seeing is related to jquery. Do you have any suggestions for a fix?
I think
this.scrollLeft = 0;
will work.
Good catch, I assume you ran into this error using Firefox. It seems like only the window element has a standardised scrollTo method, other elements only have it in WebKit powered browsers, such as Opera or Chrome.
Actually, I'm seeing this in chrome. Haven't checked with other browsers.
I know this is old and possibly unrelated but came across when google searching
scrollTo doesn't seem to exist on chrome version 57 on documents, it does exist on window but using scrollLeft seems to fix the issue for me. As an aside scrollTop also does not exist on documents but does on window in chrome version 57
scrollTo also doesn't work in chrome version 59 on document. But scrollTop can use in chrome version 59.
Thank you for the details. Please feel free to create a PR if you would like to see this fixed ASAP.
scroll and scrollTo don't work on various android browsers. scrollLeft = 0 fixed this issue for me