mastering_openlayers3 icon indicating copy to clipboard operation
mastering_openlayers3 copied to clipboard

Uncaught TypeError: this.scrollTo is not a function

Open WillieMaddox opened this issue 9 years ago • 7 comments
trafficstars

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?

WillieMaddox avatar Sep 11 '16 00:09 WillieMaddox

I think

this.scrollLeft = 0;

will work.

WillieMaddox avatar Sep 11 '16 00:09 WillieMaddox

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.

GaborFarkas avatar Sep 12 '16 12:09 GaborFarkas

Actually, I'm seeing this in chrome. Haven't checked with other browsers.

WillieMaddox avatar Sep 13 '16 02:09 WillieMaddox

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

lukejpreston avatar Oct 12 '17 12:10 lukejpreston

scrollTo also doesn't work in chrome version 59 on document. But scrollTop can use in chrome version 59.

rudyxu1102 avatar Oct 20 '17 08:10 rudyxu1102

Thank you for the details. Please feel free to create a PR if you would like to see this fixed ASAP.

GaborFarkas avatar Nov 21 '17 08:11 GaborFarkas

scroll and scrollTo don't work on various android browsers. scrollLeft = 0 fixed this issue for me

yossi-shasho avatar May 31 '18 12:05 yossi-shasho