Sortable icon indicating copy to clipboard operation
Sortable copied to clipboard

`_sortablejs.AutoScroll is not a constructor`

Open aried3r opened this issue 5 years ago • 10 comments

Reproduction

Scenario

https://codesandbox.io/s/dry-cloud-co2q9

Describe the bug

Plugins are missing from the default export. Some of the examples in the README do not work. I've seen https://github.com/SortableJS/sortablejs/issues/1929 and https://github.com/SortableJS/sortablejs/issues/1891 but none of them mention the plugins.

Expected behavior

I believe plugins should be available from the default export like described in the README. At the same time, using sortablejs/modular/sortable.core.esm.js as the import, makes TypeScript complain, however I don't exactly know how to make @types/sortablejs recognize this import as well. The error says to amend the types, but I don't know how, but I'm open to sending a PR their way. :)

Version

package version
sortablejs ^1.12.0
@types/sortablejs ^1.10.6

aried3r avatar Oct 22 '20 08:10 aried3r

Also got this issue, anyone got any ideas?

trullock avatar Dec 07 '20 10:12 trullock

@trullock, I forgot in which issue I found the information, but all the plugins are added by default in the latest version so you don't need to manually create an instance.

aried3r avatar Dec 09 '20 16:12 aried3r

ok Great thanks, still can't get it to work though :( as you point out, the examples dont work either

trullock avatar Dec 09 '20 16:12 trullock

We've got it working with AutoScroll, MultiDrag and OnSpill, but haven't finished out implementation yet. Depending on what your issue is, this GitHub issue might not be the right place to ask.

I'd suggest by creating a codesandbox, jsfiddle or similar demonstrating your problem.

aried3r avatar Dec 09 '20 16:12 aried3r

So it does work, now I understand what the default browser scroll is doing vs fallback mode.

To make Chrome scroll you need to be within a few px of the edge and then it scrolls really showly.

Quite shit.

trullock avatar Jan 10 '21 18:01 trullock

Having the same issue - it's insanely finicky about whether it scrolls or not (even after increasing scrollSensitivity). Also often very slow scrolling even with scrollSpeed bumped. @trullock did you ever have any luck?

garrettlancaster avatar Apr 09 '21 21:04 garrettlancaster

IIRC scrollSensitivity and related settings only apply to fallback mode

trullock avatar Apr 10 '21 10:04 trullock

I'm confused as to why the AutoScroll plugin doesn't work as documented. The docs say:

import { Sortable, AutoScroll } from 'sortablejs';

Sortable.mount(new AutoScroll());

But I had to instead do:

import Sortable, { MultiDrag } from 'sortablejs';
import { AutoScroll } from 'sortablejs/modular/sortable.core.esm';

Sortable.mount(new MultiDrag());
Sortable.mount(new AutoScroll());

But this yields the error: sortable.esm.js?aa47:823 Uncaught Sortable: Cannot mount plugin scroll more than once

Ok, so I suppose auto scroll is mounted by default. But that doesn't seem to be the case, because auto scroll doesn't work at all.

This is my call to init Sortable:

      this.sortable = new Sortable(this.$refs.mediaList.$el, {
        animation: 150,
        bubbleScroll: true,
        // @ts-ignore
        forceAutoscrollFallback: true,
        ghostClass: 'v-hidden',
        handle: '.drag-handle.medium',
        multiDrag: true,
        scroll: true,
        scrollFn: () => {
          console.log('hello?');
        },
        scrollSensitivity: 100,
        selectedClass: 'selected-medium',
        onUpdate: this.reorder,
      });

ffxsam avatar Apr 06 '22 17:04 ffxsam

also facing this same issue.

When I have forceFallback: false, then I can drag and drop but NOT scroll. When I have forceFallback: true, then I can drag and scroll but NOT drop.

Sortable.create(cells, {
      animation: 150,
      ghostClass: 'ghost-style',
      forceFallback: false,
      scroll: true,
      // @ts-ignore
      forceAutoscrollFallback: true,
      bubbleScroll: true,
      scrollSensitivity: 100,
      fallbackTolerance: 10,
    });

adobs avatar Jul 07 '22 15:07 adobs