Coder Social home page Coder Social logo

solid-slider's People

Contributors

amirhhashemi avatar davedbase avatar ishanahuja avatar joeygrable94 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

solid-slider's Issues

Error with Astro

Idk if I'm doing this wrong but I'm getting a very vague error

My code

        <SliderProvider>
            <Slider options={{ loop: true }}>
                <Day {...passProps}/>
                <Month {...passProps}/>
                <Year {...passProps}/>
            </Slider>
            <SliderButton prev>Previous</SliderButton>
            <SliderButton next>Next</SliderButton>
        </SliderProvider>

My Error

web.template is not a function
TypeError: web.template is not a function
    at Object.<anonymous> (/Users/Admin/App/node_modules/solid-slider/dist/index/index.common.js:77:33)
    at Module._compile (node:internal/modules/cjs/loader:1105:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/&#8230;

Scrolling hijack on Astro

Hi, I Implemented this slider into my site with Astro, and now there is scroll hijacking when I scroll down the site. It jitters and kind of goes back up after I scroll past the slider. Before adding the slider everything was fine. Any advice is appreciated!

Use object destruction instead of array

I think using object to destruct createSlider is better for DX than using array since we don't need to remember the array position and can use some specified prop more easier.

const { current } = createSlider();

Trick: How to remove seeing too many images on SSR

I just found a solution for a problem which I had with Solid Slider when using with Solid Start and SSR.

On SSR, the downloaded HTML page already contains all the images which should be in the slider. The issue is that these images are visible UNTIL the slider Javascript is downloaded and executed which can lead to an ugly flickering effect if the slider width and/or height are not properly set or must stay flexible.

The solution:

  1. add the style display:none (or the class "hidden" if you use TailwindCSS) to all images but the first one on the server-rendering to hide them on static page rendering
  2. listen to the created event hook of the slider and when it is created (so its Javascript is downloaded and run) then loop over all remaining images of the slider and remove the style.

During

const sliderOptions = {
    loop: true,
    created: slider => {
      console.log("slider created", slider)
      slider.slides.forEach(slide => {
        slide.classList.remove("hidden")
      })
    }
  }
  const [slider, { current, next, prev, moveTo, details }] = createSlider(sliderOptions)

and in the render return do something like this assuming you have an array of image objects:

return (
<div use:slider>
  <For each={images}>
    {(image: Image, index: Accessor<number>) => (
      <img
        src={image.URL}
        width="370"
        height="247"
        class={index() != 0 && "hidden"}
      />
    )}
   </For>
</div>)

Feel free to take my trick and put a potentially nicer version into the README or so because I guess as more Solid will be used on the server to render as more often the flickering will be reported.

Mapping problem

Hi
i try this code for mapping data in this slide but the problem is :
the slider not working after the mapping data

How can i map a div in this slider ?

import "solid-slider/slider.css";
import {
  createSlider,
} from "solid-slider";
import BidsStyle from "./Bids.module.css";
import {
  FaSolidCircleChevronLeft,
  FaSolidCircleChevronRight,
} from "solid-icons/fa";
import { createSignal, For, createEffect, createResource } from "solid-js";

export default function Bids() {
  const [HotCollection, setHotcollection] = createSignal([]);

  //fetch data
  createEffect(async () => {
    const res = await fetch(`http://localhost:3000/api/bid`);
    const json = await res.json();
    setHotcollection(json);
    console.log(json);
  });

  const [slider, { next, prev }] = createSlider({
    loop: true,
    mode: "free-snap",
    breakpoints: {
      "(max-width:800px)": {
        slides: { perView: 2, spacing: 15 },
      },
      "(max-width:500px)": {
        slides: { perView: 1, spacing: 15 },
      },
    },
    slides: { perView: 4, spacing: 15 },
  });

  return (
    <section>
      <div ref={slider} className="keen-slider">
        {HotCollection().map((e) => (
          <div className="keen-slider__slide number-slide1">{e._id}</div>
        ))}
      </div>

      <button className={BidsStyle.next} onClick={next}>
        <FaSolidCircleChevronRight />
      </button>
      <button className={BidsStyle.prev} onClick={prev}>
        <FaSolidCircleChevronLeft />
      </button>
    </section>
  );
}

Slides being initialized with min/max-width of 1px.

This is nearly a moot issue, as it has not been possible for me to reproduce on StackBlitz . . however there may be cases when using SolidStart that slides are initialized with a 1px width. Any window resize event will trigger a re-initialization so that the slider is then correctly rendered.

In the case where this occurred, the <Slider> is created within a component requiring authentication, that was wrapped in Suspense, and the slides themselves were loaded from a store via Context API.

Could not find a declaration file for module 'solid-slider'.Yhere are types at '/home/andrew/Documents/GFT/node_modules/solid-slider/dist/index/index.d.ts', but this result could not be resolved when respecting package.json "exports". The 'solid-slider' library may need to update its package.json or typings.

Could not find a declaration file for module 'solid-slider'. '/home/andrew/Documents/GFT/node_modules/solid-slider/dist/index/index.module.js' implicitly has an 'any' type.
There are types at '/home/andrew/Documents/GFT/node_modules/solid-slider/dist/index/index.d.ts', but this result could not be resolved when respecting package.json "exports". The 'solid-slider' library may need to update its package.json or typings.

error with vite

i get this error with "vite": "^2.9.5" and "solid-js": "^1.3.16",

image

thx for this lib :)

Package path slider.css is not exported from Package.

Hey, wanted to try this out.
Got an error & I can't seem to get it to work.
Is this known &/or is there a fix?

Package path ./dist/slider.css is not exported from package node_modules/solid-slider (see exports field in /node_modules/solid-slider/package.json)

Autoplay Plugin Import issue

Hi there,

I'm using the component for reference.

When I import autoplay plugin using the recommended format per README.md,
e.g. import autoplay from "solid-slider/plugins/autoplay";

I get IDE error:
"Cannot find module 'solid-slider/plugins/autoplay' or its corresponding type declarations."
The webpage does not load and web-dev console error is as follows:
"Uncaught SyntaxError: The requested module '/node_modules/solid-slider/dist/autoplay/autoplay.jsx' does not provide an export named 'default'"

When I change the import to:
e.g. import { autoplay } from "solid-slider/plugins/autoplay";

I get the same IDE error, however, the webpage loads and autoslide works.

Just bringing this to dev attention so it gets cleaned up to work without any error messages. Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.