Giter Club home page Giter Club logo

Comments (5)

afc163 avatar afc163 commented on July 18, 2024

旋转木马目前支持的效果很差,后续需要重构。

from switchable.

lizzie avatar lizzie commented on July 18, 2024

暂时是可以这样解决的. 仅限 circular: false 的情况下,

内部有个 length 值表示有多少屏可以切换, 计算是 panels.length / step 上取整. 一般情况下, 配置中的 viewsize (可视区域大小) 应该和每一屏的大小是一致的, 这样在切换时就没有任何空白.

但很多需求不是这样的, 比如切一屏滚动一个, 但可视区域是多个, 这样有时就有空白.

类似于 http://aralejs.org/switchable/examples/carousel-special.html 这个例子, 但这里的配置项:

        step: 2,
        viewSize: [396],
        circular: false,

这里, 可视区域 viewsize 是你切换一屏时切几个 panel 的宽度, 这样就可以推算出, 需要切几屏, 类似例子中的, panels.length为 3 个, 每屏切一个, 避免空白后的屏数 length 应 2 屏, 那么, 可以根据 length == Math.ceil(this.panels.length / this.get('step')) 推算出 step 为 1.5 至 2.

当 panels.length 为 4 个, 每屏还是切一个, 正确地屏数是 3, 那么, 推算出 step 为 1.5 至 1.9.

依次类推. 这个方法是山寨了点, 但没重构前可以这样解决下~~

from switchable.

lizzie avatar lizzie commented on July 18, 2024

重构可参考这个 http://gallery.kissyui.com/slide/1.1/guide/index.html?spm=0.0.0.0.y0MYuZ

from switchable.

leoner avatar leoner commented on July 18, 2024

这个组件最早就是源于 kissy 的. 今年 kissy 按照状态机的模式又重构了一遍,可以按照这个改下呀!

from switchable.

lizzie avatar lizzie commented on July 18, 2024

转到 #24

from switchable.

Related Issues (20)

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.