GeekyAnts / infinite-carousel-flutter

Carousel in flutter. Supports features like infinite looping, friction effect, multiple scroll physics and control over item anchor and velocity.
https://pub.dev/packages/infinite_carousel
MIT License
47 stars 29 forks source link

The carousel don't detect the mouse for scrolling on the web #7

Closed andreskiu closed 2 years ago

andreskiu commented 2 years ago

Hello, I'm trying to use this package for a web page. The carousel doesn't scroll on the desktop browser but it do it right in the cellphone browser. I experienced this issue in other scrolls (like the page view) and the problem was that the scroll was not recognizing the mouse. The solution in that case was to set the scroll behavior like follows (but I couldn't find a parameter to set it on this widget):

scrollBehavior: ScrollConfiguration.of(context).copyWith(
            dragDevices: {
              // Allows to swipe in web browsers
              PointerDeviceKind.touch,
              PointerDeviceKind.mouse
            },
          ),

The code I have right now is the following:

return Container(
      height: _cardHeight * 1.5,
      child: InfiniteCarousel.builder(
        itemCount: widget.assetsList.length,
        itemExtent: _cardWidth,
        center: true,
        anchor: 0.0,
        velocityFactor: 0.2,
        onIndexChanged: (index) {},

        // controller: controller,
        axisDirection: Axis.horizontal,
        loop: true,
        itemBuilder: (context, itemIndex, realIndex) {
          return Container(
            alignment: Alignment.center,
            child: GestureDetector(
              behavior: HitTestBehavior.opaque,
              child: Image.asset(
                '${LandingConstants.carouselImagesPath}${widget.assetsList[itemIndex]}',
                width: _cardWidth,
              ),
            ),
          );
        },
      ),
    );
manuindersekhon commented 2 years ago

Hi @andreskiu, Just published the new version of package now to set scrollBehavior. It will be available in 1.0.2. Thanks for letting me know of this. https://pub.dev/packages/infinite_carousel/versions/1.0.2