0

I am using smooth scrollbar (https://github.com/idiotWu/smooth-scrollbar/blob/develop/dist/smooth-scrollbar.js) and have implemented this. On Chrome it works okay-ish. Firefox says "SyntaxError: bad method definition main.js 5:8", what am I doing wrong? Totally stuck

Live example: https://saraleszczynska.pl

The code (main.js)

var Scrollbar = window.Scrollbar;



class HorizontalScrollPlugin extends Scrollbar.ScrollbarPlugin
{
    static ScrollbarPluginginName = 'horizontalScroll';

    transformDelta( delta, fromEvent )
    {
        if ( !/wheel/.test( fromEvent.type ) )
            return delta;

        const { x, y } = delta;

        return {
            y: 0,
            x: Math.abs( x ) > Math.abs( y ) ? x : y,
        };
    }
}



Scrollbar.use( HorizontalScrollPlugin );

( function ( $ )
{
    var scroll = Scrollbar.init( document.querySelector( '#gallery' ), {
        alwaysShowTracks: true,
    } );

    scroll.track.yAxis.element.remove();

    $( '.goto' ).on( 'click touchstart', function ( e )
    {
        e.preventDefault();

        $( 'html, body' ).animate( {
            scrollTop: $( this.hash ).offset().top,
        }, 800 );
    } );


Maciej
  • 65
  • 8

1 Answers1

5

Update

Static class fields are now supported since Firefox 75 (released Apr 8, 2020)

Original Answer

That's because Firefox does not support static class fields yet.

Check caniuse.com

Reason:

Public and private field declarations are an experimental feature (stage 3) proposed at TC39, the JavaScript standards committee. Support in browsers is limited, but the feature can be used through a build step with systems like Babel. See the compat information below.

Source: MDN

Wendelin
  • 2,354
  • 1
  • 11
  • 28